Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:30 24 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Stepper Motor

     Page 3 of 3    
Author Message
BobDevries

Senior Member

Joined: 08/06/2011
Location: Australia
Posts: 266
Posted: 09:35am 07 Oct 2011
Copy link to clipboard 
Print this post

Martin, try this, and let me know if it works:



10 DIM A$(4):DIM PN(3)
20 MAX=100:DLY=5:REM adjust to taste
30 CW=0:REM CW=1 for CCW rotation. Set to 1 or 0 depending on which direction to start in
40 FOR X=0 TO 3:READ PN(X):NEXT X:REM read which pin numbers to use into array PN()
50 DATA 15,16,17,18: REM PIN numbers used to drive stepper motor
60 FOR X=0 TO 3:SETPIN PN(X),8:NEXT X:REM set pins in PN() array to digital output
70 DATA "0111","1011","1101","1110".1111":REM codes to drive pins on or off
80 FOR X=0 TO 4:READ A$(X):NEXT X:REM read codes into string array A$()
90 DO:REM main loop
100 IF CW=0 THEN 110 ELSE 130:REM CW=0 for clockwise, non-zero for CCW rotation
110 FOR STP=0 TO 4:REM there are 4 steps to do; refer line 70
120 GOTO 140
130 FOR STP=4 TO 0 STEP -1:REM as for line 110 but reverse direction
140 FOR Y=0 TO 3
150 PIN(PN(Y))=VAL(MID$(A$(STP),Y+1,1)):REM extract binary 0 or 1 from a$() array element
160 NEXT Y
170 PAUSE DLY: REM increase PAUSE value to SLOW rotation.
180 I$=INKEY$:IF I$="" THEN 230:REM read keypress
190 IF I$="Q" OR I$="q" THEN PRINT"STOPPED":END
200 IF I$="R" OR I$="r" THEN CW=NOT(CW):PRINT"REVERSE"
210 IF I$="F" OR I$="f" THEN PRINT"FASTER":DLY=DLY - 1: IF DLY<0 THEN DLY=0
220 IF I$="S" OR I$="s" THEN PRINT"SLOWER":DLY=DLY+1: IF DLY>MAX THEN DLY=MAX
230 NEXT STP:REM next step loop
240 LOOP:REM end of main loop


Regards,
Bob Devries
Dalby, QLD, Australia
 
BobDevries

Senior Member

Joined: 08/06/2011
Location: Australia
Posts: 266
Posted: 09:37am 07 Oct 2011
Copy link to clipboard 
Print this post

Ah, I should have read your post before sending mine. Still, it's good that it works.
Let me know if my version is better, please.

Regards,
Bob Devries
Dalby, QLD, Australia
 
heppy36

Regular Member

Joined: 29/07/2011
Location: Australia
Posts: 54
Posted: 09:47am 07 Oct 2011
Copy link to clipboard 
Print this post

I get error line 80 no more data to read
?
Heppy
 
BobDevries

Senior Member

Joined: 08/06/2011
Location: Australia
Posts: 266
Posted: 09:53am 07 Oct 2011
Copy link to clipboard 
Print this post

Sorry about that, a typo in line 70. It should be:

70 DATA "0111","1011","1101","1110"."1111":REM codes to drive pins on or off

Regards,
Bob Devries
Dalby, QLD, Australia
 
heppy36

Regular Member

Joined: 29/07/2011
Location: Australia
Posts: 54
Posted: 10:12am 07 Oct 2011
Copy link to clipboard 
Print this post

Thats it!!,all works great,no stops, back and forward works ,Best its worked
Bob you nailed it!
Cheers
Heppy
 
thetinkerer

Regular Member

Joined: 16/06/2011
Location: Australia
Posts: 68
Posted: 10:16am 07 Oct 2011
Copy link to clipboard 
Print this post

Hello Heppie,
In regards to the stepper stopping as you go faster.
As you speed up a stepper, the current drops off and so does the torque and eventually the motor has so little torque that it just vibrates. To get over this, people use constant current sources along with higher supply voltages so that the current stays high even when the stepper speeds up.

Hope this helps

 
BobDevries

Senior Member

Joined: 08/06/2011
Location: Australia
Posts: 266
Posted: 10:19am 07 Oct 2011
Copy link to clipboard 
Print this post

Thanks for the kudos, Martin.

I love the challenge..... NEXT, please

Regards,
Bob Devries
Dalby, QLD, Australia
 
Dinosaur

Guru

Joined: 12/08/2011
Location: Australia
Posts: 311
Posted: 12:16am 08 Oct 2011
Copy link to clipboard 
Print this post

Hi all

As I said in a previous post, You cant get the speed.
As you speed up a stepper, the current drops off and so does the torque and eventually the motor has so little torque that it just vibrates. To get over this, people use constant current sources along with higher supply voltages so that the current stays high even when the stepper speeds up.
The commercial version will increase the voltage to keep current constant at the motor's rated curent.But by increasing the voltage the Torque increases.
They also change the duty cycle of the square wave to keep the Torque constant.

RegardsEdited by Dinosaur 2011-10-09
Regards
Hervey Bay Qld.
 
Talbit
Senior Member

Joined: 07/06/2011
Location: Australia
Posts: 210
Posted: 09:53am 13 Oct 2011
Copy link to clipboard 
Print this post

Gents,
Re the August 2011 issue - Circuit Notebook. - Maximite Stepper Motor Interface.
The correct Maximite program for the Silicon Chip stepper motor has been placed on the Silicon Chip download page for August 2011. Thanks to Leo Simpson for following it up.
Regards
Talbit
Talbit
 
johnbig

Newbie

Joined: 23/06/2011
Location: Australia
Posts: 21
Posted: 01:40am 16 Oct 2011
Copy link to clipboard 
Print this post

Hi Talbit,
Have you tried this code with the circuit in Silicon Chip Magazine.

John Leate
 
heppy36

Regular Member

Joined: 29/07/2011
Location: Australia
Posts: 54
Posted: 05:00am 16 Oct 2011
Copy link to clipboard 
Print this post

Hi ,It works with my stepper
Martin
Heppy
 
johnbig

Newbie

Joined: 23/06/2011
Location: Australia
Posts: 21
Posted: 05:08am 16 Oct 2011
Copy link to clipboard 
Print this post

Thanks Heppy,

John
 
Talbit
Senior Member

Joined: 07/06/2011
Location: Australia
Posts: 210
Posted: 02:07am 17 Oct 2011
Copy link to clipboard 
Print this post

Sorry I'm a bit late but it looks like Heppy tried it okay. I haven't tried it.
Talbit
Talbit
 
     Page 3 of 3    
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024