Problem using LOOKUP with bipolar stepper motor

Gunnar

New Member
I`m trying to use a RKP18 board with a 18M2 and L293D motor driver to drive a small Mitsumi bipolar stepper motor from a scanner.

Outputs b.4-b.7 is used for this. When setting each pin high or low in the correct sequence the motor runs as expected, see code.

Code:
dirsB=%11111111
main:
for b1=0 to 23
low b.4
high b.5
low b.6
high b.7
pause 4

high b.4
low b.5
low b.6
high b.7
pause 4

high b.4
low b.5
high b.6
low b.7
pause 4

low b.4
high b.5
high b.6
low b.7
pause 4

next b1

pause 1000
goto main
but the following code using lookup moves the motor, but in "larger steps" as the first. Seems that the torque is less also.
I can`t see why the result is different?

Code:
dirsB=%11111111
main:
for b1 = 0 to 23
b1=b1 & %00000011								' mask lower two bits of b1
lookup b1,(%10100000,%10010000,%01010000,%01100000),b2 	' lookup code into b2
pinsB=b2
pause 4
next b1

pause 1000
goto main
 

SAborn

Senior Member
Try

Code:
dirsB=%11111111
main:
for b1 = 0 to 3
								
lookup b1,(%10100000,%10010000,%01010000,%01100000),b2 	' lookup code into b2
pinsB=b2
pause 4
next b1

pause 1000
goto main

Edit:- you might want to remove the "pause 1000" from the code, as it make it do 4 steps and pause for 1 second then 4 steps again......
 
Last edited:

IronJungle

Senior Member
Just after a quick look....

I think it may be that you are changing the value of B1 inside the loop. The for/next is asking B1 to range from 0 to 23, but the statement:

"b1=b1 & %00000011" effects B1 as well.

That and maybe try it with a longer pause just for debug. My stepper projects have been "pause" sensitive.
 

Gunnar

New Member
Try

Code:
dirsB=%11111111
main:
for b1 = 0 to 3
								
lookup b1,(%10100000,%10010000,%01010000,%01100000),b2 	' lookup code into b2
pinsB=b2
pause 4
next b1

pause 1000
goto main

Edit:- you might want to remove the "pause 1000" from the code, as it make it do 4 steps and pause for 1 second then 4 steps again......
Tried this, and removed the pause 1000, but still the same problem. Motor moves, but not smooth
 

Gunnar

New Member
Just after a quick look....

I think it may be that you are changing the value of B1 inside the loop. The for/next is asking B1 to range from 0 to 23, but the statement:

"b1=b1 & %00000011" effects B1 as well.

That and maybe try it with a longer pause just for debug. My stepper projects have been "pause" sensitive.
Yes, I realized this... The result is an infinte loop, but correcting this didn`t improve on the jumpy movement. Strange...
 

SAborn

Senior Member
In most cases i would think the "pause 4 " might be too short, try making it "pause 20" as the program change may be increasing the operation speed and not allowing enough time for the procedure.
I have struck too fast of a stepping rate before and encounted all sorts of strange results.
 
Top