2 pin stepper motor control

Maleny

New Member
Hi,
Never done this before. it took me ages to even work out how to post a new thread, hope I got it right now.

I can drive a 6 wire unipolar stepper in dual-phase mode with an 08M via a ULN2003 using 4 ouputs no problem. The code:

main:
b1 = 10 'pause
let dirs = %10111 'set pins 0,1,2,4 as outputs

let pins = %10001 'coils 0 and 4
pause b1
let pins = %00011 'coils 0 and 1
pause b1
let pins = %00110 'coils 1 and 2
pause b1
let pins = %10100 'coils 2 and 4
goto main

What I want to do is drive the motor with 2 pins as per the circuit on page 15 of manual 3

!!!!!!!!!!!!!!!!! I don't know what happened there I thought I hit the space bar and everything disappeared ??????? Had to spend ages trying to get back again.

The 4 input to the ULN2003 and resultant output commands to the motor when I test them are:

pin 1 hi and pin 2 hi = 00110
pin 1 hi and pin 2 lo = 00101
pin 1 lo and pin 2 lo = 10001
pin 1 lo and pin 2 hi = 10010

As you can see the commands don't match. Can anyone see where I got crossed up ?

:confused:
 

westaust55

Moderator
Welcome to the PICAXE forum.

Firstly, you have posted in the "sandbox" which is more a test area and likely not checked regularly by many.

You would do better to post in the ACTIVE forum area at:
http://www.picaxeforum.co.uk/forumdisplay.php?f=2


I am a little confused as to your actual problem.

1. you say you have the 4 output method working -which I take it is as per Manual3 page 4.

2. You then say you want to use the 2 wire method as per page 15.


There is an exmaple program at the bottom of page 15 for the two wire method.


The last 4 lines of your post have:
pin 1 hi and pin 2 hi = 00110
pin 1 hi and pin 2 lo = 00101
pin 1 lo and pin 2 lo = 10001
pin 1 lo and pin 2 hi = 10010
These match the steps on the bottom of page 15.

I note you have bit 0 also toggled - highlighted in red above. Is this for anything else - but should not affact the stepper motor operation.

Can you post your own wiring schematic if you have redrawn the schematic or a good hi-res photo so we can look at your wiring.

Can you also post your actual program for the 2-wire stepper control.


Maybe one of the moderators can move this thread to the active area as well.


EDIT:
@Maleny,
You can always go back into an exisiting post (use the edit button at bottom right of screen) and continue or correct a typing error rather than start a new thread if you save too early or "crash" out.
 
Last edited:

Maleny

New Member
Welcome to the PICAXE forum.

Firstly, you have posted in the "sandbox" which is more a test area and likely not checked regularly by many.

You would do better to post in the ACTIVE forum area at:
http://www.picaxeforum.co.uk/forumdisplay.php?f=2


I am a little confused as to your actual problem.

1. you say you have the 4 output method working -which I take it is as per Manual3 page 4.

2. You then say you want to use the 2 wire method as per page 15.


There is an exmaple program at the bottom of page 15 for the two wire method.


The last 4 lines of your post have:


These match the steps on the bottom of page 15.

I note you have bit 0 also toggled - highlighted in red above. Is this for anything else - but should not affact the stepper motor operation.

Can you post your own wiring schematic if you have redrawn the schematic or a good hi-res photo so we can look at your wiring.

Can you also post your actual program for the 2-wire stepper control.


Maybe one of the moderators can move this thread to the active area as well.


EDIT:
@Maleny,
You can always go back into an exisiting post (use the edit button at bottom right of screen) and continue or correct a typing error rather than start a new thread if you save too early or "crash" out.

Thanks for your advice with regard to using the forum.

My final intention is to use the 2 pin control circuit on page 15. However in working towards this goal I started by using the ULN2003 only for it's darlington ability using 4 wire control. If I am correct the motor commands from the table on page 14 are:

00101 coils 1 and 3
10001 coils 1 and 4
10010 coils 2 and 4
00110 coils 2 and 3

Problem is I couldn't get this to work, so by observing the reaction of the motor when different coils were energised and using the following table I got it to work fine (this sequence also makes sense to me)

coil1 coil2 coil3 coil4
pin0 pin1 pin2 pin4
pulse commands
1 x x 00011
2 x x 00110
3 x x 10100
4 x x 10001

As you say correctly the motor command options available from my 'static' testing of the circuit on page 15 do line up with the motor commands from the table on page 14 but I can't get these commands to work only the ones above. I must be missing something obvious but I just can't see it.
 

westaust55

Moderator
AH yes,

You are using an 08M.

With the 08M, pin 3 can only be an input so as you have done, you must use pins 0, 1, 2 and 4.

Great to see that you have worked it out for yourself.
 

Maleny

New Member
AH yes,

You are using an 08M.

With the 08M, pin 3 can only be an input so as you have done, you must use pins 0, 1, 2 and 4.

Great to see that you have worked it out for yourself.

I will tidy up the comments maybe that will help you see my problem.

My code, which makes sense to me, works fine with 4 wire control, but the commands are not available from the 2 wire circuit on page 15.

main:
b1 = 10 'pause
let dirs = %10111 'set pins 0,1,2,4 as outputs

let pins = %10001 'coils 1 and 4
pause b1
let pins = %00011 'coils 1 and 2
pause b1
let pins = %00110 'coils 2 and 3
pause b1
let pins = %10100 'coils 3 and 4
goto main



The code below taken from the table on page 14 and who's commands are available from the from the 2 wire circuit on page 15 I don't understand nor can I get to work

main:
b1 = 10 'pause
let dirs = %10111 'set pins 0,1,2,4 as outputs

let pins = %00101 'coils 1 and 3
pause b1
let pins = %10001 'coils 1 and 4
pause b1
let pins = %10010 'coils 2 and 4
pause b1
let pins = %00110 'coils 2 and 3
goto main

For instance step 1 of the code above has coils 1 and 3 energised, at no stage in my code are these coils energised at the same time.
 

westaust55

Moderator
I will tidy up the comments maybe that will help you see my problem.

My code, which makes sense to me, works fine with 4 wire control, but the commands are not available from the 2 wire circuit on page 15.
but they are at the bottom of page 15:
Code:
steps: toggle 1 ‘ Toggle pin 1
pause 200 ‘ Wait 200 ms
toggle 2 ‘ Toggle pin 2
pause 200 ‘ Wait 200ms
goto steps ‘ Loop:
Which two pins are you using for the two wire circuit?

lets say you are using pins 0 and 1, and if you want to do it in the same format as the 4-wire code then try:


main:
b1 = 200 'pause duration
let dirs = %00011 'set pins 0,1, as outputs

Code:
let pins = %00000 
pause b1
let pins = %00001 
pause b1
let pins = %00011 
pause b1
let pins = %00010 
goto main
 
Last edited:

eclectic

Moderator
@Maleny.

I don't know if this will help, but...

I connected a 6-wire Unipolar motor as the circuit on M3 page 15, except that
my wires sequence was Black / Brown / Orange / Yellow.

It worked, in one direction with page 15 code.
Code:
steps: toggle 1 ‘ Toggle pin 1
pause 200 ‘ Wait 200 ms
toggle 2 ‘ Toggle pin 2
pause 200 ‘ Wait 200ms
goto steps ‘ Loop
I then made a small adaption, so that it works in both directions.

Code:
;Forum 091109
;http://www.picaxeforum.co.uk/showthread.php?t=13804

#picaxe 08m

symbol delay = 20
let dirs = %00000111

main:
oneway:
High 0 ;indicator LED
Low 1
gosub steps

pause 1000


otherway:
High 1  ; Outputs start in opposite state
Low 0
gosub steps

pause 1000
goto main


steps:
for b0 = 1 to 100
	toggle 1  
pause delay
	toggle 2 
pause delay
next
return
e
 
Last edited:
Top