Shop OBEX P1 Docs P2 Docs Learn Events
Encoder Stepper motor interface!! — Parallax Forums

Encoder Stepper motor interface!!

ArchiverArchiver Posts: 46,084
edited 2003-07-08 17:38 in General Discussion
hi,
i'm trying to interface a shaft encoder with a stepper motor such that the
stepper motor follows the speed of the encoder and turns at the same rate as the
encoder! i'm using a Iwatsu/CUI optical encoder with a resolution of 200
cycles per revolution.
and i'm using the stepper motor which i got from parallax which comes standard
with stamp works kit!
here is a Code I have written for this but sucess is still far though I have
achieved partial control
i'm facing problem that even when the encoder moves a little distance(not one
full revolution) the stepper still moves one full revolution and speed control
is still a issue in this code i'm not at all sure of the speed control.. The
motor motion is also not smooth!!
i'm a newbie in stamp programming ! but i think this approach is taking me in
right direction!!!!!!!!!
Please suggest improvements in the code!
please also tell any websites/publications where i can fine useful stuff
regarding this
'{$STAMP BS2p}
INPUT 1
PB1 VAR IN1
IsLow CON 0
IsHigh CON 1
Coils VAR OutB
speed VAR word
x VAR Byte
sAddr VAR Byte
diff VAR word
rpm VAR word
Counts VAR word
'EEPROM DATA
Step1 DATA %1100
Step2 DATA %0110
Step3 DATA %0011
Step4 DATA %1001
Read_RPM:
COUNT 1,100,Counts
RPM=(Counts*600)/200
DEBUG DEC rpm,CR
IF (Counts<>0) THEN initialize
IF (Counts=0) THEN Read_RPM
GOTO Read_RPM
initialize:
DirL=%11110000
Main:
FOR x=1 TO 100
GOSUB Step_FWD
NEXT
'Subroutines
Step_FWD:
sAddr=sAddr+1//4
READ (step1+sAddr),Coils
PAUSE rpm
'DEBUG DEC speed,CR
'GOTO Step_FWD
RETURN


'{$STAMP BS2p}
INPUT 1
PB1 VAR IN1
IsLow CON 0
IsHigh CON 1
Coils VAR OutB
speed VAR word
x VAR Byte
sAddr VAR Byte
diff VAR word
rpm VAR word
Counts VAR word
'EEPROM DATA
Step1 DATA %1100
Step2 DATA %0110
Step3 DATA %0011
Step4 DATA %1001

Read_RPM:
COUNT 1,100,Counts
RPM=(Counts*600)/200
DEBUG DEC rpm,CR
IF (Counts<>0) THEN initialize
IF (Counts=0) THEN Read_RPM
GOTO Read_RPM
initialize:
DirL=%11110000
Main:
FOR x=1 TO 100
GOSUB Step_FWD
NEXT
'Subroutines
Step_FWD:
sAddr=sAddr+1//4
READ (step1+sAddr),Coils
PAUSE rpm
'DEBUG DEC speed,CR
'GOTO Step_FWD
RETURN




SMS using the Yahoo! Messenger;Download latest version.

[noparse][[/noparse]Non-text portions of this message have been removed]
Sign In or Register to comment.