Radio Control
1.0ms full reverse.· 1.5ms stop.· 2.0ms full forward.· Is this the only standard, or one among many?· Is this same format used between xmtr and rcvr?· What about an RC airplane?· With a unidirectional motor, is it a special motor speed controller which ignores anything below 1.5ms?
Comments
I've not heard of a unidirectional servo motor. There are some motor controllers that accept servo pulses for control of a DC motor. It may be that they can be set for unidirectional use in which case they probably ignore pulses that would be too short or too long.
My understanding is, in model aviation or R/C car use the transmitter sends out a repeated signal reflecting the positions of the joysticks on the 'remote'. And 1.0 mSec (or a little less, actually) is 'far left', and 2.0 mSec is 'far right' (I could have the directions reversed, but you get the idea). 1.5 mSec is 'centered'.
So, the 'remote' is sending multiple 'channels' of these signals. The RC reciever on the plane recieves these signals, and breaks them out into their 'channels' -- Aileron, rudder, etc -- and sends these signals to the connected Servo's. The electronics in the Servo's then move the output shaft position to match the commanded input pulse width -- and there you go.
I haven't personally had to use an ESC yet (Electronic Speed Control), so you'd probably have to look at the documentation for one to see how it interprets this 'command signal'.
Now, the "Modified" servo's are modified so they don't just swing through 180 degrees, but instead spin forward or reverse. The 'modification' removes any mechanical stops preventing full rotation, and disconnects the feed-back variable resistor in the Servo, so the SERVO alway's thinks the shaft is at 'center point'. Command full left, and the servo spins the shaft continuously in the full-left direction. Command 1.5 mSec, and the servo thinks the shaft is centered and stops. Command 1.0 mSec, and the servo spins the shaft continuously in the full-right direction.
Since this signal IS used between the Rcvr and its servo's, in theory you can put a BS2 between the Rcvr and its servo's. The BS2 recieves (with a PULSIN) what the Rcvr is commanding, and then decides what to send on to the Servo's (with a PULSOUT).
Some of the transmitter/receivers I've used generate values pretty close to 1.0 - 1.5 - 2.0 MS, but some have varied as much as 10-20 percent... the current transmitter/receiver I'm using gives me real values of aprox 1.15 MS - 1.9 MS. If you know what values you are really getting, then you can "map" those values to the full forward/reverse pulse values of your servos, motor controller, whatever. You can also set your trims on the joysticks to give you a good center (off) value.
Additionally, when a transmitter is turned off, depending on the receiver, one or more channels will go to "0" -- this is a way you can have your program check to see if the transmitter is actually turned on (if you are getting "0" on any of your channels the transmitter is off or you have a bad connection -- either way your platform is not receiving signal from the remote at that moment).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
Randy
'
[noparse][[/noparse] Title ]
' Toddler Program 43.1: Turning with Radio commands
' Demonstrates basic turning process which requires four movements
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[noparse][[/noparse] I/O Definitions ]
TiltServo······ CON···· 13····················· ' Tilt servo on P12
StrideServo···· CON···· 12····················· ' Stride servo on P13
'
[noparse][[/noparse] Constants ]
MoveDelay······ CON···· 15····················· ' in micrcoseconds
TiltStep······· CON···· 9······················ ' TiltServo step size set value 5-9
StrideStep····· CON···· 9······················ ' StrideServo step size set value 5-9
RightTilt······ CON···· 620···················· ' Tilt limits
CenterTilt····· CON···· 750
LeftTilt······· CON···· 880
RightStride···· CON···· 650···················· ' Stride limits
CenterStride··· CON···· 750
LeftStride····· CON···· 850
'
[noparse][[/noparse] Variables ]
MoveLoop······· VAR···· Nib···················· ' Loop for repeat movements
Pulses········· VAR···· Word··················· ' Pulse variable
CurrentTilt···· VAR···· Word
CurrentStride·· VAR···· Word
NewValue······· VAR···· Word
Dx············· VAR···· Pulses
Mx············· VAR···· Word
Direction······ VAR···· Word
Turn··········· VAR···· Word
Checktime······ VAR···· Word
'
[noparse][[/noparse] EEPROM Data ]
'
' The following state tables are lists of movement state numbers.
' A xx indicates the end of a list.
' These are used with the Movement routine.
TL············· CON···· 0
TC············· CON···· 1
TR············· CON···· 2
SL············· CON···· 3
SC············· CON···· 4
SR············· CON···· 5
xx············· CON···· 255
WalkForward···· DATA··· TR, SL, TL, SR, xx
WalkBackward··· DATA··· TR, SR, TL, SL, xx
TurnLeft······· DATA··· TL, SR, TC, SL, xx
WideTurnLeft··· DATA··· TL, SR, TC, SL, TR, SL, TL, SR, xx
TurnRight······ DATA··· TR, SL, TC, SR, xx
PivotRight····· DATA··· TR, SL, TC, SR, TL, SL, TC, SR, xx
PivotLeft······ DATA··· TL, SR, TC, SL, TR, SR, TC, SR, xx
FinishForward·· DATA··· TR, SC, TC, xx
'
[noparse][[/noparse] Main Routine ]
······ GOSUB ResetCC
··· Direction = 766
··· Turn = 766
··· Again:
··· Direction = 766
··· Turn = 766
··· Checktime = 0
··· PULSIN 1,1, Direction 'measure· positive pulse pin 1
··· PULSIN 2,1, Turn 'Measure positive pulse pin 2
··· 'Use (1) FOR logic HIGH OR (0) FOR logic LOW
··· 'IF Time=0 THEN· cleanup·· 'if 0 try again
··· 'IF time=1 THEN cleanup
··· RCTIME 1,1,Checktime
··· 'test for valid signal with rctime
··· IF Direction· > 1000 AND Direction < 1040 THEN Forward
··· IF Direction <· 600 AND Direction > 490 THEN· Backward
··· IF Turn· > 1000 AND Turn < 1040 THEN Slowright
··· IF Turn <· 600 AND Turn > 490 THEN Slowleft
··· 'IF Checktime· > 1040 THEN cleanup
··· 'IF Checktime <· 485 THEN cleanup
··· GOTO Again
Main_Program:
· GOSUB ResetCC
··· Forward:
··· 'FWD walking
···· 'FOR MoveLoop = 1 TO 2
····· Mx = WalkForward
····· GOSUB Movement
··· 'NEXT
···· Mx = FinishForward
· GOSUB Movement
··· RETURN
··· Backward:
····· 'Bkwrd walking
···· 'FOR MoveLoop = 1 TO 2
····· Mx = WalkBackward
····· GOSUB Movement
····· Mx = FinishForward
· GOSUB Movement
··· 'NEXT
··· RETURN
··· Slowright:
······ GOSUB ResetCC
····· 'Quick right turn
··· FOR MoveLoop = 1 TO 5
····· Mx = PivotRight
····· GOSUB Movement
··· NEXT
··· RETURN
····· Slowleft:
···· 'Quick· left turn
··· FOR MoveLoop = 1 TO 5
····· Mx = PivotLeft
····· GOSUB Movement
··· NEXT
···· RETURN
····· GOSUB ResetCC
······ 'Slow right turn
··· 'FOR MoveLoop = 1 TO 5
····· Mx = TurnRight
····· GOSUB Movement
··· 'NEXT
··· RETURN
··· 'Slow left turn
··· GOSUB ResetCC
··· 'FOR MoveLoop = 1 TO 5
····· Mx = TurnLeft
····· GOSUB Movement
··· 'NEXT
··· RETURN
··· 'FOR MoveLoop = 1 TO 5
····· 'Mx = WideTurnLeft
····· 'GOSUB Movement
··· 'NEXT
· Mx = FinishForward
· GOSUB Movement
END
'
[noparse][[/noparse] Subroutines ]
'
Movement: Move feet using DATA table referenced by Mx
'
' Input: Mx = table index, table ends in xx
Movement:
· READ Mx, Dx·································· ' read next action
· Mx = Mx + 1
· IF Dx = xx THEN MovementDone················· ' skip if end of list
· GOSUB DoMovement····························· ' execute movement
· GOTO Movement································ ' loop until done
DoMovement:
· BRANCH Dx,[noparse][[/noparse]TiltLeft,TiltCenter,TiltRight,StrideLeft,
··············· StrideCenter,StrideRight]
··············································· ' will fall through if
··············································· ' invalid index
MovementDone:
· RETURN
' ----· Movement routines can be called directly ----
TiltLeft:
· NewValue = LeftTilt
· GOTO MovementTilt
TiltCenter:
· NewValue = CenterTilt
· GOTO MovementTilt
TiltRight:
· NewValue = RightTilt
MovementTilt:
· FOR Pulses = CurrentTilt TO NewValue STEP TiltStep
··· PULSOUT TiltServo,·· Pulses
··· PULSOUT StrideServo, CurrentStride
··· PAUSE MoveDelay
· NEXT
· CurrentTilt = NewValue
· RETURN
StrideLeft:
· NewValue = LeftStride
· GOTO MovementStride
StrideCenter:
· NewValue = CenterStride
· GOTO MovementStride
StrideRight:
· NewValue = RightStride
MovementStride:
· FOR Pulses = CurrentStride TO NewValue STEP StrideStep
··· PULSOUT TiltServo,·· CurrentTilt
··· PULSOUT StrideServo, Pulses
··· PAUSE MoveDelay
· NEXT
· CurrentStride = NewValue
· RETURN
'
Move feet to initial center position
ResetCC:
· CurrentTilt·· = CenterTilt
· CurrentStride = CenterStride
· FOR Pulses = 1 TO 100 STEP StrideStep
··· PULSOUT TiltServo, CenterTilt
··· PULSOUT StrideServo, CenterStride
··· PAUSE MoveDelay
· NEXT
DoReturn:
· RETURN
Post Edited By Moderator (Chris Savage (Parallax)) : 12/13/2006 9:04:40 PM GMT
Post Edited (Warrlok) : 12/13/2006 5:05:28 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST