Stepper motor code action oddity

lauriet

Member
I have a small bipolar stepper motor conventionally connected via an L293 to an 08M, using this code:

#picaxe 08m
LOW C.0,C.1,C.2,C.4
main:
do
b1 = b1 & %00000011 ' mask lower two bits of b1
lookup b1,(%00010010,%00010001,%00000101,%00000110),b0 ' lookup code into b0
pins = b0 'output b0 onto control lines
pause 200
let b1 = b1 + 1 'add 1 to variable b1
debug
loop

The motor action is not good.
In the simulator b0 returns 18, 17, 5 or 6, as expected. (00010010, 00010001, 00000101 or 00000110)
But when running the code, the debug command only returns b0 as 18 or 6.
I'm baffled. Can anyone think of an unbafflement clue?
thanks
 

hippy

Ex-Staff (retired)
I do not have an 08M to hand to test with but it worked okay and as expected with an 08M2 and PE6 6.0.8.3 ( no actual stepper connected ).

It could be that C.0 is being used to control the motor and that is also the download interface serial out used to send DEBUG data back to the PC. The two values which are not sent back are those which set C.0 high which may be disrupting the DEBUG data returned.

That the DEBUG is using C.0 may also explain why the motor operation is not as good as it could be.
 

Technical

Technical Support
Staff member
The debug also makes the step delay (speed of motor) much longer as well as corrupting C.0

Add #no_debug at the top of your program and do a download - is the motor better then?
 

lauriet

Member
Cheers.

I have a tiny, tiny stepper motor revolving quite nicely now. (fingernail size, from a printer, quite basic.)
(Even half-stepping.)
EXCEPT it rotates in 10 distinct steps, which blows my understanding of stepper motors out of the water; I thought it must be 8. (or other multiples of 4)
I think I'll have to think it out again.
 

hippy

Ex-Staff (retired)
For the 10 steps explanation it's probably best to imagine the motor rolled out flat and extended with an infinite number of poles. The 'two phase' stepping control moves it along a certain number of poles but how many make up one revolution depends on where that infinite roll is cut and rolled into a cylinder in the motor, how many poles are in the motor.

One site which looked to have a reasonable explanation of the basics was this one -

http://www.orientalmotor.com/technology/articles/step-motor-basics.html

There are probably others too.
 

lauriet

Member
Sorry, baffled again ...
I am using a micro stepper motor, generically similar to this:
http://www.ebay.com/itm/2-phase-4-wire-stepper-motor-MCU-learning-Board-6mm-Canon-micro-step-motor-/181357823970
It runs very nicely using the lookup sequence LOOKUP b2, (%10010, %10001, %00101, %00110), b3
(From browsing, this seems the agreed sequence.)
I thought that, to run in the other direction, the sequence would be reversed, but it just judders. I cannot find any sequence that produces reverse running.
Does anyone have useful information or experience on this type of device?
Thanks.
 
Top