Servo motor problems,please help!!
Hi,
I'm doing the 2DOF·hexapod walking robot.
This is the program that I used to test on the servo motor. But somehow the servos keep on moving to the same direction regardless of how I tune it inside the program. 750 is the middle value and the range is 500 to 1000.
·
'
[noparse][[/noparse] TestPscchannel.BS2 ]
' {$STAMP BS2px}
' {$PBASIC 2.5}
'
' Use this program to test PSC channels
·
'
[noparse][[/noparse] I/O Definitions ]
PSC············ PIN···· 7············· ' PSC module
PSC········· ···PIN···· 8············· ' PSC module
·
·
#SELECT $STAMP
· #CASE BS2SX, BS2P
··· Baud······· CON···· 1021 + $8000
· #CASE BS2PX
··· Baud······· CON···· 1646 + $8000
· #CASE #ELSE
··· Baud······· CON···· 396 + $8000
#ENDSELECT
·
·
'---- [noparse][[/noparse]Walking Variables]
servoPosition·· VAR···· Word················· ' Servo Position
servoAddr······ VAR···· Byte················· ' Servo addresses
ramp········· ··VAR···· Byte················ ' Ramp used in SEROUT
·
'_________________________________________________________________________
·
Main:
'---- [noparse][[/noparse] Move channel 7 & 8 to normal position ]
· ramp = 8·············· 'Rotation speed (ramp)
· servoAddr = 7········· ·'PSC channel 7
· servoPosition = 750··· ········ ·'Position
· GOSUB Write_PSC····· 'Write to PSC
·
· ramp = 8·············· 'Rotation speed (ramp)
· servoAddr = 8········· ·'PSC channel 8
· servoPosition = 750··· ········ 'Position
· GOSUB Write_PSC····· 'Write to PSC
· PAUSE 1000············ 'Wait 1 seconds to provide
························ 'servos time to reach position
·
'---- [noparse][[/noparse] Move channel 7 & 8 to 900 ]
· ramp = 8·············· ··· 'Rotation speed (ramp)
· servoAddr = 7········· ··········· ··········· 'PSC channel 7
· servoPosition = 550··· ········ ··········· 'lift the leg
· GOSUB Write_PSC······· 'Write to PSC
·
· ramp = 8·············· ··· 'Rotation speed (ramp)
· servoAddr = 8········· ······················· 'PSC channel 8
· servoPosition = 550··· ········ 'forward the leg
· GOSUB Write_PSC····· ······ 'Write to PSC
· PAUSE 1000············ ··········· 'Wait 1 seconds to provide
························ ·········· 'servos time to reach position
GOTO Main
·
'_________________________________________________________________________
·
Write_PSC:
· SEROUT PSC,Baud,[noparse][[/noparse]"!SC",servoAddr,
········ ramp,servoPosition.LOWBYTE,
········ servoPosition.HIGHBYTE, CR]
RETURN
I'm doing the 2DOF·hexapod walking robot.
This is the program that I used to test on the servo motor. But somehow the servos keep on moving to the same direction regardless of how I tune it inside the program. 750 is the middle value and the range is 500 to 1000.
·
'
[noparse][[/noparse] TestPscchannel.BS2 ]
' {$STAMP BS2px}
' {$PBASIC 2.5}
'
' Use this program to test PSC channels
·
'
[noparse][[/noparse] I/O Definitions ]
PSC············ PIN···· 7············· ' PSC module
PSC········· ···PIN···· 8············· ' PSC module
·
·
#SELECT $STAMP
· #CASE BS2SX, BS2P
··· Baud······· CON···· 1021 + $8000
· #CASE BS2PX
··· Baud······· CON···· 1646 + $8000
· #CASE #ELSE
··· Baud······· CON···· 396 + $8000
#ENDSELECT
·
·
'---- [noparse][[/noparse]Walking Variables]
servoPosition·· VAR···· Word················· ' Servo Position
servoAddr······ VAR···· Byte················· ' Servo addresses
ramp········· ··VAR···· Byte················ ' Ramp used in SEROUT
·
'_________________________________________________________________________
·
Main:
'---- [noparse][[/noparse] Move channel 7 & 8 to normal position ]
· ramp = 8·············· 'Rotation speed (ramp)
· servoAddr = 7········· ·'PSC channel 7
· servoPosition = 750··· ········ ·'Position
· GOSUB Write_PSC····· 'Write to PSC
·
· ramp = 8·············· 'Rotation speed (ramp)
· servoAddr = 8········· ·'PSC channel 8
· servoPosition = 750··· ········ 'Position
· GOSUB Write_PSC····· 'Write to PSC
· PAUSE 1000············ 'Wait 1 seconds to provide
························ 'servos time to reach position
·
'---- [noparse][[/noparse] Move channel 7 & 8 to 900 ]
· ramp = 8·············· ··· 'Rotation speed (ramp)
· servoAddr = 7········· ··········· ··········· 'PSC channel 7
· servoPosition = 550··· ········ ··········· 'lift the leg
· GOSUB Write_PSC······· 'Write to PSC
·
· ramp = 8·············· ··· 'Rotation speed (ramp)
· servoAddr = 8········· ······················· 'PSC channel 8
· servoPosition = 550··· ········ 'forward the leg
· GOSUB Write_PSC····· ······ 'Write to PSC
· PAUSE 1000············ ··········· 'Wait 1 seconds to provide
························ ·········· 'servos time to reach position
GOTO Main
·
'_________________________________________________________________________
·
Write_PSC:
· SEROUT PSC,Baud,[noparse][[/noparse]"!SC",servoAddr,
········ ramp,servoPosition.LOWBYTE,
········ servoPosition.HIGHBYTE, CR]
RETURN
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
On a BS2, there's 2 uSec per 'tick', so a value of 750 'ticks' is 1.5 mSec. I believe the BS2px has a different sized 'tick' -- you'll have to check the manual under PULSOUT to find the right number of 'ticks' for 1.5 mSec on the BS2px.
[noparse][[/noparse] I/O Definitions ]
PSC PIN 7 ' PSC module
PSC PIN 8 ' PSC module
Is this what you intended? I don't know the psc syntax
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
This section of your code should generate a symbol already defined error since you're trying to use the same label for more than one value.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Actually we have tried the program that I have·posted earlier on and it works·just fine in the beginning. The hexapod walking robot legs are able to move front and back.·However, there·is·an accident. The servo controller got burn.
Does this incident affect other electrical components like BOE, servo motor wires? Since that incident, our servo motors did not function in the way·that we have wanted. We always thought that our programs are having problems.
We even tried with a new servo controller. The problem still·remains the same.