Help with pwm and servos.
Angel
Posts: 4
Would someone help me, I can't get to work the SX for controlling a hobby servo , I tried the PWM command, but its giving me some error that says "byte parameter expected"
what I wrote., well actually I used the template that comes in the help.
**********
'
' Device Settings
'
DEVICE········· SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
FREQ··········· 4_000_000
'
' IO Pins
'
Sio············ VAR···· Ra.0··················· ' 1 IO pin
'
· INTERRUPT
'
ISR_Start:
· ' ISR code here
ISR_Exit:
· RETURNINT ' {cycles}································
' =========================================================================
· PROGRAM Start
' =========================================================================
Pgm_ID:
· DATA· "SX/B Template", 0
'
' Program Code
'
Start:
· ' initialization code here
Main:
· ' main code here
pwm RA.0, .0015, 8· 'What I expect here is that on port RA.0 i will get a PWM signal with .0015 seconds of duty cycle and for 8 seconds of duration.
· GOTO Main
********************
the idea·of the·project·is to control a robot and to vary the times on each servo to make it move while the other servos stay in the same position..., I know I am far from that, but, well I gotta make 1 servo move first lol..
thanks.
what I wrote., well actually I used the template that comes in the help.
**********
'
' Device Settings
'
DEVICE········· SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
FREQ··········· 4_000_000
'
' IO Pins
'
Sio············ VAR···· Ra.0··················· ' 1 IO pin
'
· INTERRUPT
'
ISR_Start:
· ' ISR code here
ISR_Exit:
· RETURNINT ' {cycles}································
' =========================================================================
· PROGRAM Start
' =========================================================================
Pgm_ID:
· DATA· "SX/B Template", 0
'
' Program Code
'
Start:
· ' initialization code here
Main:
· ' main code here
pwm RA.0, .0015, 8· 'What I expect here is that on port RA.0 i will get a PWM signal with .0015 seconds of duty cycle and for 8 seconds of duration.
· GOTO Main
********************
the idea·of the·project·is to control a robot and to vary the times on each servo to make it move while the other servos stay in the same position..., I know I am far from that, but, well I gotta make 1 servo move first lol..
thanks.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Angel,
Here's a little SX/B program that operates a servo. This was just for testing the movement for various positions, should be commented enough to determine it's operation.
Mike
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"OEM NMEA GPS Module" Now available on ebay for only $17.49
Product web site: http://www.allsurplus.net/Axiom/
Post Edited (Mike Cook) : 3/2/2006 11:38:17 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax