stepper phase problems

hi to all
I would like some help please on how I can shift the phase of signals to control a stepper motor in full step 2 phase mode.
no matter what i try the 2 phases never seem to be in step with a 90 deg phase shift.

see attached pic

2 phase full step.jpg

my code is

dirs = %00010111
symbol step1 = %00010100
symbol step2 = %00000110
symbol step3 = %00000011
symbol step4 = %00010001
symbol stepcount = b0
symbol delay =5




main:

do
if stepcount = 0 then main1
if stepcount = 1 then main2
if stepcount = 2 then main3
if stepcount = 3 then main4
end

loop

main1:

pinsc = step1
pause delay
inc stepcount
goto main

main2:

pinsc = step2
pause delay
inc stepcount

goto main

main3:

pinsc = step3
pause delay
inc stepcount
goto main

main4:

pinsc = step4
pause delay
stepcount = 0
goto main

im still quite a noob at all this and i am sure many of you will look at this and think of at least a dozen ways to make it more simple.
but i am learning all the time which is the main thing.

thanks for your help

steve
 

hippy

Ex-Staff (retired)
The Blue and Green traces seem the inverse of each other, as are Red and Yellow, while the Blue/Green and Red/Yellow seem 90 degree out of phase which seems to be what you are after.

Perhaps you simply need to move coil assignments to different I/O pins, alter the 'Symbol stepN=' bits or re-order the 'pins=stepN' assignments.

If it's something else then perhaps show what you want to see on your scope.
 

AllyCat

Senior Member
Hi Steve,

Any asymmetry is not obvious in your scope waveforms, so it's probably just the structure of your main program loop. Remember that each PICaxe instruction typically takes as long as a "Pause 1".

When stepcount is 3, then the main loop has to execute all four "IF"s before jumping to main4, but on the next phase (stepcount = 0), the jump occurs on the first "IF".

Probably the easiset solution is just to jump directly (or "fall through") from the main1 code to main2, etc..

Cheers, Alan.

PS: I'm not sure what that "end" is doing within the main loop (but it does seem to simulate ok).
 
The Blue and Green traces seem the inverse of each other, as are Red and Yellow, while the Blue/Green and Red/Yellow seem 90 degree out of phase which seems to be what you are after.

Perhaps you simply need to move coil assignments to different I/O pins, alter the 'Symbol stepN=' bits or re-order the 'pins=stepN' assignments.

If it's something else then perhaps show what you want to see on your scope.
the traces are indeed the inverse of each other which is good but the phase only seems to be shifted 45 deg along from the other.
what i would like to acheive is in the pic attached
 

Attachments

AllyCat

Senior Member
Hi Steve,

With 360 degrees to a "full revolution" (i.e. repetition of the waveforms), your original traces do have a 90 degrees phase shift (give or take any minor timing delays). Your second (required?) waveforms have basically two in-phase and two shifted by 180 degrees (i.e. inverted) signals , which AFAIK are not suitable for any stepper motor.

If you actually want non-symmetrical pulse waveforms (e.g. ON for 90 degrees, OFF for 270 degrees) then you would need to change the "step" image bytes. To create 45 degree spaced transitions would need an 8-phase routine (e.g. main1: to main8: ).

Cheers, Alan.
 
Top