alistairsam
Senior Member
Hi,
I needed help with writing code for a stepper control application that includes acceleration and deceleration, and the option of different square wave outputs to send to a seperate stepper driver depending on keypad selections.
(I'm completely new to picaxe's)
I need the picaxe to just output square waves as I have a dedicated stepper driver.
Is it an incorrect approach to use a simple for next loop to increase the time as a variable in a pulsout command thereby providing linearly increasing pulse freq to an external stepper driver.
for example,
for a 1Hz square wave, the o/p pin would have to be high for 500msec and low for 500msec.
so for 30Hz, that would be 500/30 = 16600 usec (pulsout 1,16600)
and for 1500Hz, that would be 500/1500 = 330 usec (pulsout 1,330)
so if a variable is used for the value of "time", would something like the following work?
so the pulsewidth would start at 16600, and then reduce to 330usecs in steps of 10. thats 50 steps. might be too small. but just trying to understand the concept.
I'll be using a 14M Picaxe at 4MHz
I have a keypad encoder that can output 5 bit nibbles, so if that is connected to the picaxe input pins, can the bits at 3 pins be monitored every few msecs to call 3 different subroutines, with each subroutine coded to output a set freq with acceleration?
I needed help with writing code for a stepper control application that includes acceleration and deceleration, and the option of different square wave outputs to send to a seperate stepper driver depending on keypad selections.
(I'm completely new to picaxe's)
I need the picaxe to just output square waves as I have a dedicated stepper driver.
Is it an incorrect approach to use a simple for next loop to increase the time as a variable in a pulsout command thereby providing linearly increasing pulse freq to an external stepper driver.
for example,
for a 1Hz square wave, the o/p pin would have to be high for 500msec and low for 500msec.
so for 30Hz, that would be 500/30 = 16600 usec (pulsout 1,16600)
and for 1500Hz, that would be 500/1500 = 330 usec (pulsout 1,330)
so if a variable is used for the value of "time", would something like the following work?
Code:
FOR PL=16600 to 330 step -10
pulsout 1,PL
next PL
pulsout 1,330
I'll be using a 14M Picaxe at 4MHz
I have a keypad encoder that can output 5 bit nibbles, so if that is connected to the picaxe input pins, can the bits at 3 pins be monitored every few msecs to call 3 different subroutines, with each subroutine coded to output a set freq with acceleration?