Driving Bipolar Stepper Motors and Trying to Move the Motor a Bit Faster/PRU or UART?

Ah yes - bit banging from the PRU, and yes you decide the speed. Also guess you could vary the duty period as well - to get whatever average voltage out you want.

On the eHRPWM from reading got the idea it was always 50% duty cycle, and done at the speed of the input clock (so raw 100MHz, but it goes down by the dividers - so guess could get it down to 100kHz, but then be very limited in the speed you could do the motor steps).

Just looked up the TRM page 2379. The chopper uses sysclockout and divides that by 8 then into a another divider and duty cycle control. The duty cycle can be programmed for 7 increments ranging from 12.5 - 87.5%. The width of the first pulse can be programmed to any of 16 possible pulse width values. The width or period of the first pulse is given by: T1stpulse = TSYSCLKOUT × 8 × OSHTWTH.

The PRU’s have access to the APWMO. I use it for my motor controller.

And for the original poster, just came across the below when browsing for another product. Its worth looking at, just to see what it does and how!

I am going to give up on finding a solution to enabling the CONTROL_MOD pwm clocks. I will incorporate a your code with a class that I have used for years that run’s on Linux that uses reads and writes to export the pins and enable the pwm outputs. I can use the same thing for the PRU’s.

Mean while I am being asked by the Forum to let others have a chance at this topic. So I will take a break and order parts for my cape.

Are you on discord? If so how can I message you. I am known as Wireman.

Not yet on discord - but I’ll register there. Have 20 minutes break now before putting fish pie in the oven …

That was easy - seem to be on there now as DavidSummers

OK CM_PER[CM_PER_EPWMSS*_CLKCTRL] is wierd. I only seem to be able to set it to 0x2 or 0x30000 - don’t think I’ve ever managed to switch it anything else. Can’t find anything in the documentation on this, so I’ve asked the TI forum.

Ah its quite simply, only bit 2 is writeable …

Few minor corrections to my code - and for ease of understanding output (for Ken) have shown the current frequency on the output (both target frequency, and that achieved with the constrains of the pwm - note achieved is always slightly higher than target in current implementation)

pwm.c (10.3 KB)

pwm.h (4.5 KB)