hossein_rahimi
Posts: 1
Joined: Sat Dec 09, 2017 2:26 pm

High frequency stepper motor

Sat Dec 09, 2017 2:36 pm

Hello everybody

I'm writing a program which controls 3 steppers motors. I tried to use time.delay to control the speed of my steppers. My problem is that one of my motors need a delay less than 15us and from what I've calculated with a timer, it seems the delay function itself has a delay around 70us. Is there any way I can achieve the speed I want for stepper? I tried to use PWM functions but they also seem to have a limit for frequency.

User avatar
joan
Posts: 12907
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: High frequency stepper motor

Sat Dec 09, 2017 4:04 pm

The hardware PWM (there are two channels) can certainly generate much higher frequencies (down to pulses a few tens of nanoseconds long).

pigpio waves can work in that region (1µs resolution) and can keep count of the pulses transmitted if you use a wave chain.

Have a look at http://abyz.me.uk/rpi/pigpio/examples.h ... wavePWM_py for a Python example of using waves.

p.torabi
Posts: 6
Joined: Fri Nov 06, 2015 10:18 am

Re: High frequency stepper motor

Wed Dec 13, 2017 3:01 pm

I also have the same problem, I tested the pigpio library with python, I monitored the output with an oscilloscope, it seems this library is slower than gpio. the delay was around 125 us.

User avatar
joan
Posts: 12907
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: High frequency stepper motor

Wed Dec 13, 2017 3:39 pm

p.torabi wrote:
Wed Dec 13, 2017 3:01 pm
I also have the same problem, I tested the pigpio library with python, I monitored the output with an oscilloscope, it seems this library is slower than gpio. the delay was around 125 us.
Were you using waves?

p.torabi
Posts: 6
Joined: Fri Nov 06, 2015 10:18 am

Re: High frequency stepper motor

Thu Dec 14, 2017 6:37 am

I just used PWM.

p.torabi
Posts: 6
Joined: Fri Nov 06, 2015 10:18 am

Re: High frequency stepper motor

Thu Dec 14, 2017 7:42 am

I used PWM, with even 1 us wave and it helped. Thank you very much.
This link also helped me:
https://raspberrypi.stackexchange.com/q ... -generator

p.torabi
Posts: 6
Joined: Fri Nov 06, 2015 10:18 am

Re: High frequency stepper motor

Sun Dec 17, 2017 8:28 am

joan wrote:
Sat Dec 09, 2017 4:04 pm
The hardware PWM (there are two channels) can certainly generate much higher frequencies (down to pulses a few tens of nanoseconds long).

pigpio waves can work in that region (1µs resolution) and can keep count of the pulses transmitted if you use a wave chain.

Have a look at http://abyz.me.uk/rpi/pigpio/examples.h ... wavePWM_py for a Python example of using waves.
It seems wave chain, counter is an integer so it has a limit of 65535. Is there a way to break this limit so I can repeat my wave longer or should I create a wave and repeat it?

Return to “Python”

Who is online

Users browsing this forum: Danilk and 23 guests