2023-10-16 08:11 AM - edited 2023-10-16 08:15 AM
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:
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.
2024-11-07 07:33 AM
I think the best way for you to do it is by useing HRTIMx that is high resolution timer.