cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G0B1 MCU controlling unipolar stepper motor with PWM

Gergo Santha
Associate II

Hi all,

I'm working on a project where I want to control a unipolar stepper motor (5-wire, 4 phase, drive mode 4 - 2 -1 , center-tapped, datasheet attached) using the STM32G0B1 microcontroller. In the past, I used the PCA9629A stepper driver IC, which worked well, but now I'm looking to simplify the design by replacing it with direct control via the STM32 and a Darlington array (ULN2003-style).

My goal is to drive the stepper in both directions, ideally using PWM to control timing and phase switching more precisely. I'm aware that bit-banging is one way to do it, but I’d prefer to use hardware timers and PWM channels to offload the CPU and make it more efficient.

What I’m currently struggling with is:

  • Can I synchronize multiple PWM channels on the STM32G0B1 to implement unipolar stepper waveforms (full-step or half-step)?

  • Any tips or example configurations using TIMx channels for this kind of stepper motor?

Any advice, experiences, or even links to relevant STM32CubeMX setups or example code would be greatly appreciated.

Thanks!
Gergo

1 REPLY 1
KnarfB
Principal III

It should be possible using 4 channels of say TIM1 in output compare mode with toggle on match and attach 4 circular DMA channels which act on the individual channel's update event and update the channel's capture/compare registers to the time of the next edge.

Maybe it is simpler to start with a software state machine driven by a periodic interrupt.

hth

KnarfB