250g granules is about 350ml volumeNow I can see a whole new range of PICAXE sex toy projects, or is my corrupted mind?
Only joking. Looks very attractive for making robotic objects as well as for getting one of protoypes off the ground. I followed up a link to supply Polymorph, but working out volumes of the item (pellets) to be useable is difficult to work out. Be good if the volumes were shown related to a finished cubic volume.
Thanks
First of Boris, Thank you very much for posting a code us newbies can work with right away. I would need a few more lifetimes before I could write code at your level, but reading it and following what it does helps a lot.Code to test same:
Code:#Picaxe 08m2 'Stepper motor driver test 'Boris Burke May 2012 setfreq m8 dirs=%00010111 do b1=b1+2 max 3//3 'b1 is direction control, 2=CW 0=CCW for w1=1 to 2060 'seems to be about the right number of steps for 360 degrees b0=b0+b1-1//4 'b0 cycles from 0 to 3 for CW and from 3 to 0 for CCW lookup b0,(%00011,%00110,%10100,%10001),pinsC pause 1 next w1 pause 4000 loop
The code is for a motor that has 5.625 / 64 step angle at the shaft. The step angle is fixed. ( except for microstepping or half stepping) That means that each "step" by definition will be ~ .088 degrees at the shaft. You can't just jump a stepper motor to a certain position or arbitrarily change the step angle. In order for the motor to rotate, the coils must be pulsed in sequence (usually) one step at a time.Which variable would I change if I wanted a slowly increasing/ decreasing angle of rotation, say going from 5 degrees up to 20 in 4 steps ?
I noticed that this code produces 1 full turn in one direction, but only half in the other ? Was there a reason in the code for this that I missed out ?
doesn't w1 dictate 1 to 2060 in both directions ? unquote!
Boris, So sorry, had a brain fart ! Forgot to switch the jumper to output 0. Works beautifully now !
Ready to go 2803 board for 2 steppers for $5.89: http://www.ebay.com/itm/ULN2803-Stepper-Motor-Driver-Controller-Board-fr-2-4-Phase-stepper-motor-Arduino-/320999701510?pt=LH_DefaultDomain_0&hash=item4abd12bc06Want to make my own board using ULN2803 IC. with more outputs. Thanks
Cheaper to buy 2 of the http://www.ebay.co.uk/itm/5V-Stepper...-/271005201851 and get the steppers for freeReady to go 2803 board for 2 steppers for $5.89: http://www.ebay.com/itm/ULN2803-Stepper-Motor-Driver-Controller-Board-fr-2-4-Phase-stepper-motor-Arduino-/320999701510?pt=LH_DefaultDomain_0&hash=item4abd12bc06
pause 1000
output c.0, c.1, b.3, b.5
symbol delay = 6 'Must be at least 3 or motor will not turn; probably should be at least 4 in order
b4=delay
start:
for b4 = 233 to 13 step -10
cw:
high b.1
'for b2 = 1 to 2 'Sets number of complete revolutions clockwise.
for w0 = 64 to 1 step -1
high c.0: low c.1: low b.3: high b.5
pause delay
'low c.0: low c.1: low b.3: low b.5 'Removing power from the motor allows cooling.
'pause b4
'high c.0:
high c.1: 'low b.3:
low b.5
pause delay
'low c.0: low c.1: low b.3: low b.5 'Removing power from the motor allows cooling.
'pause b4
low c.0:
'high c.1:
high b.3:
' low b.5
pause delay
'low c.0: low c.1: low b.3: low b.5 'Removing power from the motor allows cooling.
'pause b4
'low c.0:
low c.1:
'high b.3:
high b.5
pause delay
'low c.0: low c.1: low b.3: low b.5 'Removing power from the motor allows cooling.
'pause b4
next w0
'next b2
low c.0: low c.1: low b.3: low b.5 'Removing power from the motor allows cooling.
high b.2
pause 1
for w0 = 255 to 1 step -1
high c.0: low c.1: low b.3: high b.5
pause delay
'low c.0: low c.1: low b.3: low b.5 'Removing power from the motor allows cooling.
'pause b4
'high c.0:
high c.1: 'low b.3:
low b.5
pause delay
'low c.0: low c.1: low b.3: low b.5 'Removing power from the motor allows cooling.
'pause b4
low c.0:
'high c.1:
high b.3:
' low b.5
pause delay
'low c.0: low c.1: low b.3: low b.5 'Removing power from the motor allows cooling.
'pause b4
'low c.0:
low c.1:
'high b.3:
high b.5
pause delay
'low c.0: low c.1: low b.3: low b.5 'Removing power from the motor allows cooling.
'pause b4
next w0
'next b2
low c.0: low c.1: low b.3: low b.5 'Removing power from the motor allows cooling.
pause 1
low b.1
high b.2
ccw:
' for b2 = 1 to 2 'Sets number of complete revolutions counter-clockwise.
for w0 = 128 to 1 step -1 '360 degrees counter-clockwise.
low c.0: low c.1: high b.3: high b.5
pause b4
'low c.0: low c.1: low b.3: low b.5 'Removing power from the motor allows cooling.
'pause b4
'low c.0:
high c.1: '
'high b.3:
low b.5
pause b4
'low c.0: low c.1: low b.3: low b.5 'Removing power from the motor allows cooling.
'pause b4
high c.0:
'high c.1:
low b.3:
'low b.5
pause b4
'low c.0: low c.1: low b.3: low b.5 'Removing power from the motor allows cooling.
'pause b4
'high c.0:
low c.1:
'low b.3:
high b.5
pause b4
'low c.0: low c.1: low b.3: low b.5 'Removing power from the motor allows cooling.
'pause b4
next w0
' next b2
low c.0: low c.1: low b.3: low b.5 'Removing power from the motor allows cooling.
pause 1
low b.2
for w0 = 512 to 1 step -1
high c.0: low c.1: low b.3: high b.5
pause delay
'low c.0: low c.1: low b.3: low b.5 'Removing power from the motor allows cooling.
'pause b4
'high c.0:
high c.1: 'low b.3:
low b.5
pause delay
'low c.0: low c.1: low b.3: low b.5 'Removing power from the motor allows cooling.
'pause b4
low c.0:
'high c.1:
high b.3:
' low b.5
pause delay
'low c.0: low c.1: low b.3: low b.5 'Removing power from the motor allows cooling.
'pause b4
'low c.0:
low c.1:
'high b.3:
high b.5
pause delay
'low c.0: low c.1: low b.3: low b.5 'Removing power from the motor allows cooling.
'pause b4
next w0
'next b2
low c.0: low c.1: low b.3: low b.5 'Removing power from the motor allows cooling.
pause 1
low b.1
next b4
'for b2 = 1 to 2 'Sets number of complete revolutions counter-clockwise.
for w0 = 128 to 1 step -1 '360 degrees counter-clockwise.
low c.0: low c.1: high b.3: high b.5
pause b4
'low c.0: low c.1: low b.3: low b.5 'Removing power from the motor allows cooling.
'pause b4
'low c.0:
high c.1: '
'high b.3:
low b.5
pause b4
'low c.0: low c.1: low b.3: low b.5 'Removing power from the motor allows cooling.
'pause b4
high c.0:
'high c.1:
low b.3:
'low b.5
pause b4
'low c.0: low c.1: low b.3: low b.5 'Removing power from the motor allows cooling.
'pause b4
'high c.0:
low c.1:
'low b.3:
high b.5
pause b4
'low c.0: low c.1: low b.3: low b.5 'Removing power from the motor allows cooling.
'pause b4
next w0
' next b2
low c.0: low c.1: low b.3: low b.5 'Removing power from the motor allows cooling.
pause 1
goto start
#Picaxe 08m2
'Stepper motor driver test with acceleration
'Boris Burke May 2012
symbol prefinish=w0 'controls the start of deceleration
symbol finish=w1 'number of steps to the finish
symbol steps=w2 'counts the steps
symbol direction=b6 '2=CW 0=CCW
symbol phase=b7 'counts from 0 to 3 for CW and from 3 to 0 for CCW
symbol speed=W6 'changes with acceleration/deceleration (lower is faster, min 1)
symbol slow_limit=w7 'destination speed when starting and stopping (higher is slower)
setfreq m8 'double the Picaxe clock speed
pause 1000 'wait for the new clock speed to settle (1000=500mS at m8)
dirs=%00010111 'bit 3 cannot be used because I'm using an 08m2
slow_limit=32 'upper limit for slowest step speed during acceleration/deceleration
finish=4096 'number of steps to take
direction=2 'direction switch 0=CW 2=CCW
do
direction=direction+2 max 3//3 'alternate direction, comment this line for single direction
speed=slow_limit 'set delay
for steps=1 to finish 'beging rotation loop
prefinish=finish-steps+1 'set deceleration point
if steps<slow_limit then 'if starting
speed=speed-1 min 1 'then accelerate
elseif prefinish<slow_limit then 'if stopping
speed=speed+1 max slow_limit 'then decelerate
endif 'end acceleration adjustmet to SPEED
pause speed 'speed of rotation pause
phase=phase+direction-1//4 'work out the next output bit pattern
lookup phase,(%00011,%00110,%10100,%10001),pinsC 'move stepper motor
next steps 'end of rotation loop
pause 4000 'wait 2 seconds
loop
This code has acceleration and deceleration with a fixed number of steps from start to finish. Tweak the values to suit.
Thank you, the code works beautifully, and the acceleration and deceleration is noticeable. I will tweak it to suit.
Jim Perry's code also works, though I had to change the pin designations and make small corrections on the syntax - haven't played with it yet, only tried it.
Need to speed it up quite a bit.
But what I realize now is that I had not clearly stated what I was trying to achieve, and I have used the terms acceleration/deceleration incorrectly.
What I want to do is to operate a Carnival Swing Ride as realistically as possible. Hence, on the first swing, I want the shaft to turn 10 degrees CW and 10 CCW. Then the next swing 15 degrees, etc. increasing in 5 degree (approximate) increments.
Then when it reaches 30 degrees forward and backward, to hold this amplitude for 5 to 10 times, then reverse the process.
Now, I have achieved changing the angle of rotation at the shaft using Boriz's original code, and I know what variable controls this.
But how to I string them together ?
1) I tried making a counter change the controlling word variable but it rejected as incorrect syntax
2) I have tried using sub-routines where each gosub had incremental change in w0, but that too was rejected.
I don't know enough about coding, so I don't know where to proceed from here. Would appreciate advice on the direction I should be taking.
I have done this with DC motors, but I would like to try it with these cheap steppers because then I can adapt other rides, and even design my own. The slow output shaft speed, the high torque, and the cheap price make them perfect as a teaching tool for kids to get into this motor technology as well as PICAXEs.
Thanks ahead !
;5V 4 phase 5 line 28BYJ-48 5VDC Stepper Motor 25CM 28BYJ48 high torque run 1RPM
#picaxe 08m
do
high 0 high 1 low 2 low 4
pause ? ;delay
low 0 high 1 high 2 low 4
pause ? ;delay
low 0 low 1 high 2 high 4
pause ? ;delay
high 0 low 1 low 2 high 4
loop
Dear orcaclewell from the info in thread i would just do the maths.
60 / 1019 = 0.056 seconds.
so a pause 55 or 56 should do the job, how accurate does it need to be, how smooth and will you be testing and timing to get best results
I opened one up a 5V stepper to check out the odd gear ratio. Probably a one-way trip, but it was worth $2.50 to satisfy my curiosity.
The metal case is staked in 4 places. Some gentle tapping with a hammer and small chisel is in order to open her up, then the flat mounting plate comes off with the output gear. All small nylon gears, with enough total backlash to be annoying. $2.50 doesn't buy perfection.
The motor & 9T pinion have 16 steps per revolution. 3 compound gears: 32x11, 22x9, 26x10 and the oddball output gear has 31 (yes, 31) teeth. So the overall gear ratio is 31/10 x 26/9 x 22/11 x 32/9 = 63.68395062 or 25792/405.
That times 16 steps per motor revolution yields a maddening 1018.94321 steps per output shaft revolution. Call it 1019. I had seen previous guestimates of 1024, about half a percent off. Pics attached.
the info in eros' post, however i presumed you were using the same motor, seems you may having something different if you are only getting 6 steps per rotationDear orcacle
Thank you so much for your helpful. With my bad in the math ',could you help me more to know where is 1019 ?for calculating And if for motor run 6 turns per minute how to change 1019.please
Dear oracaclethe info in eros' post, however i presumed you were using the same motor, seems you may having something different if you are only getting 6 steps per rotation