cancel
Showing results for 
Search instead for 
Did you mean: 

H-bridge control with PWM from different timers and channels

HØdeg.1
Associate

I would like to point out that I'm fairly new to STM programming and SMT32CubeIDE, but I have a problem to solve that I need help with:

I am making a speed controller for a 3-phase BLDC motor, with 6 N-channel mosfets (two for each phase). These mosfets has to be turned on in a specific sequence, and therefore I decided to use a specific timer and channel for each of the 6 mosfets, so that I can control each mosfet individually. (I have printet circuit board, so this is the configuration I am stuck with for now). This is the configuration I have using the NUCLEO STM32G474RE board:

  • U-phase HI-SIDE mosfet = PC_1 (pin) = Timer 1, Channel 2
  • U-phase LO-side mosfet = PC_0 (pin) = Timer 1, Channel 1
  • V-phase HI-SIDE mosfet = PC_2 (pin) = Timer 1, Channel 3
  • V-phase LO-SIDE mosfet = PA_1 (pin) = Timer 2, Channel 2
  • W-phase HI-SIDE mosfet = PC_3 (pin) = Timer 1, Channel 4
  • W-phase LO-SIDE mosfet = PA_0 (pin) = Timer 2, Channel 1

Everything will run at 20 kHz, so that is not a problem. My problem is as follows:

I want to run, based on hall-sensor inputs, U-phase HI-SIDE and V-phase LO-SIDE mosfets together, with one being complimentary to the other, and preferably with a dead-time in between. (When one signal is HIGH, the other is LOW, and vice versa, with dead time in between). Then when the "next" hall sensor inputs come along, we switch tothe mosfets: U-phase HI-SIDE an W-phase LO-side, and this continues (in a specific pattern).

None of theese pins "is" the complimentary for each other by default. (e.g.  PC_1 is by default connected to Timer 1, channel 1, and PA_7 is the complimentary pin (by default)).

So my question is really: How can I (in software) make one PWM signal the complimentary of another PWM signal, and they are not of the same timer and/or channel (with a dead-time in between), and the it is switching between different timers and channels?

 

I have a hardware-based solution: using a multiplexer to guide the PWM and complimentary PWM to where it needs to go, but then I would have to re-design my circuit-board, and order a new one. I want to know if this is "fairly" simple to do using software first.

0 REPLIES 0