Controlling a Stepper Motor with a BS2
geometrix
Posts: 27
Dear Guru's,
I am trying to control a Shinano·2 phase bipolar 2 phase exciting stepper motor (this is the description of the motor from the spec sheet) part no. SST36C0030.· See the attached spec sheet for this motor.
I finally gave up on trying to adapt an example piece of code from the Parallax website·to my application and wrote my own piece of code.· I pretty much understood the code from the Parallax website and I am not sure why·I couldn't·get it to·work.· I finally got the motor to turn with my own code, as "basic" is it may be!
I now have a few problems for which·somebody may have some suggestions:
1.··· The motor speed is extremely slow, approximately 50 to 60 rpm.· With a rating of 2250 pulses per second·MAX, I should be able to achieve 337.5rpm MAX.· I have varied the delay from 0 to 500 milliseconds and it only really works with delays around the 2 to 4 milliseconds.
2.··· The motor rpm’s are VERY inconsistent as it speeds up and slows down, very jumpy.
3.··· The torque is EXTREMELY low.· I have no way to measure the torque, however a very light pinch with my fingers is enough to stop the motor from turning (motor is rated for 35.2mN m for holding torque and 3.92 mN m detent torque. ·I am not sure which one of these numbers is supposed to represent the active driving torque of the motor.
4.··· I have tried driving this motor through a Darlington Transistor Array (ULN2803A).· I have only successfully been able to drive the motor from the outputs of the Basic Stamp 2 (BS2) microcontroller, but not from the outputs of ULN2803A.
5.··· I am not sure exactly how much voltage and current I get from an ACTIVE HIGH state of one of the pins on the BS2.· I may need an amplifier.
Thanks in advance,
Neal, 954-649-9399
My source code looks something like this:
' {$STAMP BS2}
' {$PBASIC 2.5}
'
' Connections:
'
' P4 -> ULN2003.1, ULN2003.16 -> Phase 1 (Brown)
' P5 -> ULN2003.2, ULN2003.15 -> Phase 2 (Red)
' P6 -> ULN2003.3, ULN2003.14 -> Phase 3 (Orange)
' P7 -> ULN2003.4, ULN2003.13 -> Phase 4 (Yellow)
'
'
[noparse][[/noparse] I/O Definitions ]
senseMotion·· PIN 0
closure······ PIN 1
manualAdvance PIN 2
cutoff······· PIN 3
brown········ PIN 4
red·········· PIN 5
orange······· PIN 6
yellow······· PIN 7
INPUT senseMotion
INPUT closure
INPUT manualAdvance
INPUT cutoff
OUTPUT brown
OUTPUT red
OUTPUT orange
OUTPUT yellow
'
[noparse][[/noparse] Constants ]
'
[noparse][[/noparse] Variables ]
idx·········· VAR···· Byte··················· ' loop counter
stpDelay····· VAR···· Byte··················· ' delay for speed control
_steps······· VAR···· Word··················· ' number of steps required
'
[noparse][[/noparse] Initialization ]
· stpDelay = 2···························· ' set step delay in milliseconds
'
[noparse][[/noparse] Program Code ]
DO
· IF (senseMotion = 1 AND closure = 1) THEN·· ' dispense 14 inch piece of·string
··· _steps=150···········································' when motion is detected and
··· GOSUB DriveMotor································· ' cover is closed
··· senseMotion = 0
··· closure = 0
· ELSEIF (manualAdvance=1) THEN········ ' manually advance·string with pushbutton sw
··· DO WHILE (manualAdvance=1)
····· _steps=16
····· GOSUB DriveMotor
··· LOOP
··· manualAdvance = 0
· ELSEIF (cutoff=1) THEN··············· ' advance 1 inch after·string is cut
··· _steps=104
··· GOSUB DriveMotor
··· cutoff = 0
'· ELSE
'··· NAP 3
'··· END
· ENDIF
LOOP
'
[noparse][[/noparse] Subroutines ]
DriveMotor:
· FOR idx = 1 TO _steps/4····· ' cycle through different phases
··· HIGH brown
··· HIGH red
··· LOW orange
··· LOW yellow
··· PAUSE stpDelay
··· LOW brown
··· HIGH red
··· HIGH orange
··· LOW yellow
··· PAUSE stpDelay
··· LOW brown
··· LOW red
··· HIGH orange
··· HIGH yellow
··· PAUSE stpDelay
··· HIGH brown
··· LOW red
··· LOW orange
··· HIGH yellow
··· PAUSE stpDelay
· NEXT
· RETURN
I am trying to control a Shinano·2 phase bipolar 2 phase exciting stepper motor (this is the description of the motor from the spec sheet) part no. SST36C0030.· See the attached spec sheet for this motor.
I finally gave up on trying to adapt an example piece of code from the Parallax website·to my application and wrote my own piece of code.· I pretty much understood the code from the Parallax website and I am not sure why·I couldn't·get it to·work.· I finally got the motor to turn with my own code, as "basic" is it may be!
I now have a few problems for which·somebody may have some suggestions:
1.··· The motor speed is extremely slow, approximately 50 to 60 rpm.· With a rating of 2250 pulses per second·MAX, I should be able to achieve 337.5rpm MAX.· I have varied the delay from 0 to 500 milliseconds and it only really works with delays around the 2 to 4 milliseconds.
2.··· The motor rpm’s are VERY inconsistent as it speeds up and slows down, very jumpy.
3.··· The torque is EXTREMELY low.· I have no way to measure the torque, however a very light pinch with my fingers is enough to stop the motor from turning (motor is rated for 35.2mN m for holding torque and 3.92 mN m detent torque. ·I am not sure which one of these numbers is supposed to represent the active driving torque of the motor.
4.··· I have tried driving this motor through a Darlington Transistor Array (ULN2803A).· I have only successfully been able to drive the motor from the outputs of the Basic Stamp 2 (BS2) microcontroller, but not from the outputs of ULN2803A.
5.··· I am not sure exactly how much voltage and current I get from an ACTIVE HIGH state of one of the pins on the BS2.· I may need an amplifier.
Thanks in advance,
Neal, 954-649-9399
My source code looks something like this:
' {$STAMP BS2}
' {$PBASIC 2.5}
'
' Connections:
'
' P4 -> ULN2003.1, ULN2003.16 -> Phase 1 (Brown)
' P5 -> ULN2003.2, ULN2003.15 -> Phase 2 (Red)
' P6 -> ULN2003.3, ULN2003.14 -> Phase 3 (Orange)
' P7 -> ULN2003.4, ULN2003.13 -> Phase 4 (Yellow)
'
'
[noparse][[/noparse] I/O Definitions ]
senseMotion·· PIN 0
closure······ PIN 1
manualAdvance PIN 2
cutoff······· PIN 3
brown········ PIN 4
red·········· PIN 5
orange······· PIN 6
yellow······· PIN 7
INPUT senseMotion
INPUT closure
INPUT manualAdvance
INPUT cutoff
OUTPUT brown
OUTPUT red
OUTPUT orange
OUTPUT yellow
'
[noparse][[/noparse] Constants ]
'
[noparse][[/noparse] Variables ]
idx·········· VAR···· Byte··················· ' loop counter
stpDelay····· VAR···· Byte··················· ' delay for speed control
_steps······· VAR···· Word··················· ' number of steps required
'
[noparse][[/noparse] Initialization ]
· stpDelay = 2···························· ' set step delay in milliseconds
'
[noparse][[/noparse] Program Code ]
DO
· IF (senseMotion = 1 AND closure = 1) THEN·· ' dispense 14 inch piece of·string
··· _steps=150···········································' when motion is detected and
··· GOSUB DriveMotor································· ' cover is closed
··· senseMotion = 0
··· closure = 0
· ELSEIF (manualAdvance=1) THEN········ ' manually advance·string with pushbutton sw
··· DO WHILE (manualAdvance=1)
····· _steps=16
····· GOSUB DriveMotor
··· LOOP
··· manualAdvance = 0
· ELSEIF (cutoff=1) THEN··············· ' advance 1 inch after·string is cut
··· _steps=104
··· GOSUB DriveMotor
··· cutoff = 0
'· ELSE
'··· NAP 3
'··· END
· ENDIF
LOOP
'
[noparse][[/noparse] Subroutines ]
DriveMotor:
· FOR idx = 1 TO _steps/4····· ' cycle through different phases
··· HIGH brown
··· HIGH red
··· LOW orange
··· LOW yellow
··· PAUSE stpDelay
··· LOW brown
··· HIGH red
··· HIGH orange
··· LOW yellow
··· PAUSE stpDelay
··· LOW brown
··· LOW red
··· HIGH orange
··· HIGH yellow
··· PAUSE stpDelay
··· HIGH brown
··· LOW red
··· LOW orange
··· HIGH yellow
··· PAUSE stpDelay
· NEXT
· RETURN
Comments
I dont see _Steps default value
Do you have a load on the motor while testing it if not it will cavitate
Are you running at least 2x the voltage rating, if not you cant get the rated speed
BS2 can only execute 2000 lines of code per second so your max step rate is 2000 per second / 5 lines of code per step
Usually the amount of current is the problem for faster speeds, that is why you push it with higher voltage as the winding takes time to get up to full power.
Using a big capacitor on the power supply can help as well.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think outside the BOX!
www.simplestep.com <- is a great place for cheap effective motor drivers
related post:
http://forums.parallax.com/forums/default.aspx?f=5&m=121488&g=121643#m121643
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Ryan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ryan Clarke
Parallax Tech Support
RClarke@Parallax.com