Any way to phase shift channels of one timer in STM32? - Page 1
Forum section: electronics / general

author: Amper
author_rank: Frequent Contributor
timestamp: July 09, 2024, 01:05:22 pm
content: 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?

author: wek
author_rank: Frequent Contributor
timestamp: July 09, 2024, 04:33:24 pm
content: 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

author: Amper
author_rank: Frequent Contributor
timestamp: July 09, 2024, 05:53:30 pm
content: 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...

author: wek
author_rank: Frequent Contributor
timestamp: July 09, 2024, 06:14:26 pm
content: 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

author: Amper
author_rank: Frequent Contributor
timestamp: July 09, 2024, 06:36:09 pm
content: full ack

author: jnk0le
author_rank: Regular Contributor
timestamp: July 09, 2024, 08:17:59 pm
content: BTW, HRTIM (in e.g. f3, g4) offers this exact way of phase shifting channels. L4 is out of luck.

author: Amper
author_rank: Frequent Contributor
timestamp: July 10, 2024, 02:33:03 pm
content: I have a few f303 left, they should be pin compatible to my board, maybe thats an idea, thank you.

author: jnk0le
author_rank: Regular Contributor
timestamp: July 10, 2024, 04:36:39 pm
content: for F3 family it's in f334 only.

author: jnk0le
author_rank: Regular Contributor
timestamp: July 10, 2024, 05:04:48 pm
content: also, the GPTIM sometimes have dead time insertion (e.g. TIM15/16/17 on f303)