You can improve your motor performance in two ways:
1) Use half step sequence ( here a sample code)
Code:
HStep var byte [8] ' Half step sequence array
B0 var byte
C0 var byte
P0 var byte
W0 var word
TRISB = 0
P0 = 50 ' incrementing the delay will reduce the motor speed (max 255)
C0 = 0
B0 = 0
HalfMode:
If C0 = 0 then gosub CW
C0 = C0 + 1
if C0 = 2 then C0 = 0
If C0 = 0 then gosub CW
If C0 = 1 then gosub CCW
for W0 = 0 to 8192 ' one turn of the gear shaft ( 64 motor turns)
PortB = HStep[B0]
B0 = B0+1
if B0 = 8 then B0=0
pause P0
next W0
Goto HalfMode
CW: ' half step sequence (clockwise)
HStep[0] = 1
HStep[1] = 3
HStep[2] = 2
HStep[3] = 6
HStep[4] = 4
HStep[5] = 12
HStep[6] = 8
HStep[7] = 9
return
CCW: ' half step sequence (counter clockwise)
HStep[0] = 9
HStep[1] = 8
HStep[2] = 12
HStep[3] = 4
HStep[4] = 6
HStep[5] = 2
HStep[6] = 3
HStep[7] = 1
return
end
2) Use a constant current setup to your motor. The simple way is to use a LM317 configured as costant current supply. See the attached schematic (Resistor 33 Ohms 1 watt. Use 24 V dc as an input to the LM317)
cheers
Al.
Last edited by aratti; - 5th September 2011 at 22:31.
Thks,all for help!!!
I tired testing all code,I hope I do something!
Just one question,
Is possible make some code in picbasic,
When I start step motor,to start every time to one position,
example:
If step motor work some,go to left,go to right,.......
and I stop power,and turn again,is possible,motor back in some start position,and continue work some function!
Last edited by dragan77; - 6th September 2011 at 03:20.
Hi,
If it looks like a reset it probably is. There's no bypass capacitor in the schematic, if you don't have that in your circuit make sure you add one. 0.1uf right across the Vdd/Vss pins.
Thks man! I make this, you mean across + an -,from power!
I see that many time in shema,why is that nessery?
Now I testing this code:
Code:
Delay VAR BYTE
i VAR WORD
TRISB = 0 ' All outputs.
Delay = 8
pause 1000
For i = 1 to 512 '512 steps forward.
PORTB =9
Pause Delay
PORTB =3
Pause Delay
PORTB =6
Pause Delay
PORTB =12
Pause Delay
NEXT
pause 2500
For i = 1 to 256 '256 steps reverse.
PORTB =12
Pause Delay
PORTB =6
Pause Delay
PORTB =3
Pause Delay
PORTB =9
Pause Delay
NEXT
Pause 2500
For i = 1 to 256 '256 steps reverse.
PORTB =12
Pause Delay
PORTB =6
Pause Delay
PORTB =3
Pause Delay
PORTB =9
Pause Delay
NEXT
Pause 1500
For now, working 2 hour fine,is precison,and dont have some reset,we will se for now!
And one more question,is possible make some code for picbasic for this:
If step motor work some,go to left,go to right,.......
and I stop power,and turn again,is possible,motor back in some start position,(some zero posicion),and continue work same function,before stoping!
Last edited by dragan77; - 6th September 2011 at 17:42.
Yes, between pin 14 and 5 on the PIC as close to the chip as possible.
It's needed because as the current thru the circuit fluctuates (rises and falls) quickly (which it does in digital circuits, not to mention motor control and other "high power" circuits) the resistance and inductance of the wires and/or PCB traces that "feeds" the chip makes the voltage at the chip unstable.
If you look at ANY profesional PCB/circuit you'll see a bypass capacitor right next to EVERY chip for this particular reason.
I wrong for last questin,I mean:
And one more question,is possible make some code for picbasic for this:
If step motor work some,go to left,go to right,.......
and I stop power,and turn again,is possible,motor back in some start position,(some zero posicion),and continue work same function,FROM START CODE!
Bookmarks