My Gertbot board does not support ramp up for stepper motors. Will this be supported in the future? I am wondering if I need to write some code to do this manually or if it will be supported natively in the near future.
Thanks!
Code: Select all
import gertbot as gb
import time
def ramp(BOARD, MOTOR, freq, numsteps):
if freq > 0 :
gb.open_uart(0)
maxloop = 10
ramptime = 0.2 * abs(numsteps) / freq
ramploop = ramptime / maxloop
gb.freq_stepper(BOARD,MOTOR,0 )
gb.move_stepper(BOARD,MOTOR,numsteps)
# ramp up
for i in range (0, maxloop - 1 ):
gb.freq_stepper(BOARD,MOTOR,freq / (maxloop - i) )
time.sleep(ramploop)
# constant velocity
time.sleep( 0.6 * abs(numsteps) / freq);
# ramp down
for i in range (0, maxloop - 1 ):
gb.freq_stepper(BOARD,MOTOR,freq / (i + 1) )
time.sleep(ramploop)
# stop motor
gb.move_stepper(BOARD,MOTOR,0)
Code: Select all
import gertbot as gb
import gertramp as gr
BOARD = 0
MOTOR = 0
gb.open_uart(0)
gb.set_mode(BOARD,MOTOR,gb.MODE_STEPG_PWR)
gr.ramp(BOARD,MOTOR,2000,4000)
Ooops yes, I forgot to mention that.With this routine I was able to get the stepper motor to run at a much higher frequency than without the ramping.