Author Topic: Any way to phase shift channels of one timer in STM32?  (Read 435 times)

0 Members and 2 Guests are viewing this topic.

Offline AmperTopic starter

  • Frequent Contributor
  • **
  • Posts: 290
  • Country: 00
Any way to phase shift channels of one timer in STM32?
« on: July 09, 2024, 01:05:22 pm »
Hi!
Im a bit desperate and it seems like what im asking is not going to be possible by what i know about the timers and what i found on the internet but as a last straw i want to ask the community.

I have a working 3 phase motor inverter board taht is tested and works well, it uses the STM32L412 to do everything and has everything on board to drive bldc motors but im also using it to boost three phases of a boost converter to charge 48V batteries from 410W 30V solar panels. For this purpose there is a storage inductor and a dc link cap on every phase and the output is the DClink of the motor inverter itself.

The issue now is, everything works well but since its based on motor control im using center aligned PWM, 3 channels, so all 3 are in phase. For the 3 phase boostconverter i woul realy lie to have the PWM of the channels to be 120° shifted to have true 3phase and take load of the dclink capacitor.

All solutions to obtain pahse shift PWM involve usng 3 timers and shifting them, this will not allow me to use the outputs of TIM1 though, so im losing the ability to generate deadtime and the inverted channel.

Did i miss anything or am i just out of luck with those controllers?
 

Offline wek

  • Frequent Contributor
  • **
  • Posts: 506
  • Country: sk
Re: Any way to phase shift channels of one timer in STM32?
« Reply #1 on: July 09, 2024, 04:33:24 pm »
Probably not in up-down (center-aligned) mode.

In center-aligned mode, to achieve phase shift, you can use the Asymmetric modes, but those group CH1-CH2 and CH3-CH4 together, so at the end you have only 2 channels available for output.

In "non-center-aligned" modes, you could use Combined modes, where you would group CH3-CH4, apply "distortion" from CH5 to CH2 (see TIM1_CCR5.GC5C2), and use CH1 "undistorted".

Devil is as usually in the details, and maybe this combination would, maybe won't fit your particular application.

JW
 
The following users thanked this post: glenenglish

Offline AmperTopic starter

  • Frequent Contributor
  • **
  • Posts: 290
  • Country: 00
Re: Any way to phase shift channels of one timer in STM32?
« Reply #2 on: July 09, 2024, 05:53:30 pm »
Center aligned is not really needed, its just what im coming from as a basis.
Ill try to figure out what you suggested, to be honest, im a HAL Script kiddie, i know my way around the ol atmegas in a register level but for the stms i need abstraction...
 

Offline wek

  • Frequent Contributor
  • **
  • Posts: 506
  • Country: sk
Re: Any way to phase shift channels of one timer in STM32?
« Reply #3 on: July 09, 2024, 06:14:26 pm »
First, read the TIM chapter. Skim through, focus perhaps on the registers subchapter a bit.

Then experiment with the TIM registers. You can start with some (preferrably simpler) Cube-clicked example, stop execution in debugger, and directly play with the registers while observing outputs, to see the effect.

Then re-read the TIM chapter and try focus on PWM and related.

Then experiment.

And experiment.

And experiment.

And write the register-based code.

Cube may be a good way to do "typical" things, i.e. those Cube authors deemed to by "typical" and can be easily clicked in CubeMX; but if you try to depart from the "typical", Cube may get heavily into your way.

JW
 

Offline AmperTopic starter

  • Frequent Contributor
  • **
  • Posts: 290
  • Country: 00
Re: Any way to phase shift channels of one timer in STM32?
« Reply #4 on: July 09, 2024, 06:36:09 pm »
full ack
 

Online jnk0le

  • Regular Contributor
  • *
  • Posts: 68
  • Country: pl
Re: Any way to phase shift channels of one timer in STM32?
« Reply #5 on: July 09, 2024, 08:17:59 pm »
BTW, HRTIM (in e.g. f3, g4) offers this exact way of phase shifting channels. L4 is out of luck.
 

Offline AmperTopic starter

  • Frequent Contributor
  • **
  • Posts: 290
  • Country: 00
Re: Any way to phase shift channels of one timer in STM32?
« Reply #6 on: July 10, 2024, 02:33:03 pm »
I have a few f303 left, they should be pin compatible to my board, maybe thats an idea, thank you.
 

Online jnk0le

  • Regular Contributor
  • *
  • Posts: 68
  • Country: pl
Re: Any way to phase shift channels of one timer in STM32?
« Reply #7 on: July 10, 2024, 04:36:39 pm »
for F3 family it's in f334 only.
 

Online jnk0le

  • Regular Contributor
  • *
  • Posts: 68
  • Country: pl
Re: Any way to phase shift channels of one timer in STM32?
« Reply #8 on: July 10, 2024, 05:04:48 pm »
also, the GPTIM sometimes have dead time insertion (e.g. TIM15/16/17 on f303)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf