Wiki source code of 2RC Communication Protocol

Last modified by Eric Nantel on 2022/10/31 11:34

Show last authors
1 (% class="wikigeneratedid" %)
2 The following commands are available in the 2RC Mode, provided the microcontroller is running the Lss2IO Arduino sketch and the switch is set to the "2RC" position. Should the code be changed by the user (a new sketch uploaded via the Arduino IDE for example), these commands will not be valid. The 2IO sample code allows up to three RC Servos and/or three analog sensors to interface with an LSS Bus so they can be controlled and queried in the same way as Lynxmotion Smart Servos (LSS). Below is a list of the available serial commands for the 2RC Mode of the 2IO Board which is a shorter version of the [[LSS Communication Protocol>>doc:lynxmotion-smart-servo.lss-communication-protocol.WebHome||rel="noopener noreferrer" target="_blank"]]. It is important to note that the LSS-2IO module does not provide power to the RC servos (sensors only). As such, the LSS-5VR is suggested in addition to the LSS-2IO to provide the RC servos with regulated 5V.
3
4 (% class="wikigeneratedid" %)
5 //A special thanks goes to C. Mackenzie for his contributions to this project.//
6
7 = Command List =
8
9 |= #|=Description|=(% style="width: 73px;" %) Action|=(% style="width: 69px;" %) Query|=(% style="width: 67px;" %) Config|=(% style="width: 229px;" %) Units|=(% style="width: 665px;" %) Notes|=(% style="width: 113px;" %)Default Value
10 |1|[[**L**imp>>doc:||anchor="H1.Limp28L29"]]|(% style="width:73px" %) L|(% style="width:69px" %) |(% style="width:67px" %) |(% style="width:229px" %)none|(% style="width:665px" %)Used for RC servos connected on the 2IO|(% style="text-align:center; width:113px" %)
11 |2|[[Position in (% class="wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink" %)**P**ulse>>path:#H2.PositioninPulse28P29]]|(% style="width:73px" %) P|(% style="width:69px" %) QP|(% style="width:67px" %) |(% style="width:229px" %)microseconds|(% style="width:665px" %)(((
12 Inherited from SSC-32 serial protocol
13 )))|(% style="text-align:center; width:113px" %)
14 |3|[[Position in (% class="wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink" %)**D**egrees>>path:#H3.PositioninDegrees28D29]]|(% style="width:73px" %) D|(% style="width:69px" %) QD|(% style="width:67px" %) |(% style="width:229px" %)tenths of degrees |(% style="width:665px" %) |(% style="text-align:center; width:113px" %)
15 |4|[[(% class="wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink" %)**LED** Color>>path:#H4.LEDColor28LED29]]|(% style="width:73px" %) LED|(% style="width:69px" %) QLED|(% style="width:67px" %) CLED|(% style="width:229px" %)none (integer from 0 to 7)|(% style="width:665px" %)0=Off (black); 1=Red 2=Green; 3=Blue; 4=Yellow; 5=Cyan; 6=Magenta; 7=White.|(% style="text-align:center; width:113px" %)0 (OFF)
16 |5|[[(% class="wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink" %)**G**yre direction (**G**)>>path:#H5.GyreRotationDirection28G29]]|(% style="width:73px" %) G|(% style="width:69px" %) QG|(% style="width:67px" %) CG|(% style="width:229px" %)none |(% style="width:665px" %)Gyre / rotation direction: 1= CW (clockwise) -1 = CCW (counter-clockwise)|(% style="text-align:center; width:113px" %)1
17 |6|[[(% class="wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink" %)**ID** #>>path:#H6.IdentificationNumber28ID29]]|(% style="width:73px" %) |(% style="width:69px" %) |(% style="width:67px" %) CID|(% style="width:229px" %)none (integer from 0 to 250)|(% style="width:665px" %)Note: ID 254 is a "broadcast" which all servos / modules respond to. |(% style="text-align:center; width:113px" %)
18 |7|[[(% class="wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink" %)**B**aud rate>>path:#H7.BaudRate]]|(% style="width:73px" %) |(% style="width:69px" %) QB|(% style="width:67px" %) CB|(% style="width:229px" %)none (integer)|(% style="width:665px" %) |(% style="text-align:center; width:113px" %)115200
19 |8|[[(% class="wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink" %)**M**odel **S**tring>>path:#H8.QueryModelString28QMS29]]|(% style="width:73px" %) |(% style="width:69px" %)QMS|(% style="width:67px" %) |(% style="width:229px" %)none (string)|(% style="width:665px" %) |(% style="text-align:center; width:113px" %)
20 |9|[[(% class="wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink" %)**RESET**>>path:#H9.RESET]]|(% style="width:73px" %)RESET|(% style="width:69px" %) |(% style="width:67px" %) |(% style="width:229px" %)none|(% style="width:665px" %)Soft reset. See command for details.|(% style="text-align:center; width:113px" %)
21 |10|[[(% class="wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink" %)**DEFAULT**>>path:#H10.DEFAULT]]|(% style="width:73px" %) |(% style="width:69px" %) |(% style="width:67px" %) |(% style="width:229px" %)none|(% style="width:665px" %)Revert to firmware default values. See command for details.|(% style="text-align:center; width:113px" %)
22 |11|[[(% class="wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink wikiinternallink" %)**A**nalog>>path:#H11.Analog]]|(% style="width:73px" %) |(% style="width:69px" %)QA|(% style="width:67px" %) |(% style="width:229px" %)Analog |(% style="width:665px" %)**QA** : returns raw value / **QA1**: calculated distance (mm) for Sharp GP2Y0A41SK0F / **QA2**: distance (mm) for Sharp GP2Y0A21YK0F / **QA3**: distance (mm) for Sharp GP2Y0A02YK0F|(% style="text-align:center; width:113px" %)
23
24 == Details ==
25
26 ====== __1. Limp (**L**)__ ======
27
28 Example: #209L<cr>
29
30 This action causes the RC servo connected to the LSS-2IO's pin D9 to go "limp". The broadcast ID #254 can also be used with as an emergency safety feature should the robot not be doing what it is supposed to or risks damage: #254L<cr>.
31
32 ====== __2. Position in Pulse (**P**)__ ======
33
34 Example: #209P2334<cr>
35
36 The pulse command corresponds to what a normal RC servo would receive in order to determine which position to move to. The code handles repeating the pulse so the servo remains at the desired position. Most RC servos can rotate ±90.0 degrees where 1500 microseconds (us) is centered, 500us is -90.0 degrees and +2500us is +90.0. This total travel can also be thought of as 180.0 degree total travel. Therefore a pulse of 2334 would set the RC servo connected to pin D9 to 75.1 degrees. Valid values for P are [500, 2500]. Values outside this range are corrected / restricted to the end points.
37
38 Query Position in Pulse (**QP**)
39
40 Example: #209QP<cr> might return *209QP2334
41
42 This command queries the angular position of the RC servo connected to pin D9 in PWM "units".
43
44 ====== __3. Position in Degrees (**D**)__ ======
45
46 Example: #209D1456<cr>
47
48 This moves the RC servo connected to pin D9 to an angle of 145.6 degrees. Negative values (ex. -176 representing -17.6 degrees) are used. A full circle / rotation would be from -1800 to 1800 degrees.
49
50 Query Position in Degrees (**QD**)
51
52 Example: #209QD<cr> might return *209QD132<cr>
53
54 This means the RC servo connected to pin D9 is located at 13.2 degrees. Note that this query relates to the last command sent to that servo as opposed to reading an angular sensor (potentiometer or encoder) to obtain the actual position. If the RC servo selected has a position feedback pin / cable, this can be connected to one of the analog pins to read the value.
55
56 ====== __4. LED Color (**LED**)__ ======
57
58 Ex: #207LED3<cr>
59
60 This action sets the onboard RGB LED color for that session.The LED can be used for aesthetics, or (based on user code) to provide visual status updates. Using timing can create patterns. This command works only with the 2IO Master ID (207 by default) and the broadcast ID (254).
61
62 0=Off (black); 1=Red 2=Green; 3=Blue; 4=Yellow; 5=Cyan; 6=Magenta; 7=White;
63
64 Query LED Color (**QLED**)
65
66 Ex: #207QLED<cr> might return *207QLED5<cr>
67
68 This simple query returns the indicated 2IO's RGB LED color. This command works only with the 2IO Master ID (207 by default) and the broadcast ID (254).
69
70 Configure LED Color (**CLED**)
71
72 Configuring the LED color via the CLED command sets the startup color after a reset or power cycle. Note that it also changes the session's LED color immediately as well. This command works only with the 2IO Master ID (207 by default) and the broadcast ID (254).
73
74 ====== __5. Gyre Rotation Direction (**G**)__ ======
75
76 "Gyre" is defined as a circular course or motion. The effect of changing the gyre direction is as if you were to use a mirror image of a circle. Clockwide (CW) = 1; Counter-clockwise (CCW) = -1. The factory default is clockwise (CW).
77
78 Ex: #209G-1<cr>
79
80 This command will cause RC servo connected to pin D9 positions to be inverted, effectively causing the servo to rotate in the opposite direction given the same command. Note that this command also works for analog sensors inverting the sensor's analog raw value.
81
82 Query Gyre Direction (**QG**)
83
84 Ex: #209QG<cr> might return *209QG-1<cr>
85
86 The value returned above means the servo/analog sensor is in a counter-clockwise gyration.
87
88 Configure Gyre (**CG**)
89
90 Ex: #209CG-1<cr>
91
92 This changes the gyre direction as described above and also writes to EEPROM.
93
94 ====== __6. Identification Number (**ID**)__ ======
95
96 A servo or analog sensor's identification number connected to the 2IO Board must be configured via the CID command described below. The factory default ID (as per the sketch loaded at the factory) for all 2IO pins is indicated in the Pin / ID  table below. Since LSS/2IO devices are intended to be daisy chained, in order to respond differently from one another, the user must set a different ID number for each pin. Devices connected to pins which use the same ID and baud rate will therefore all receive and react to the same commands.
97
98 Configure ID (**CID**)
99
100 Ex: #209CID1<cr>
101
102 This command will change the ID of the RC servo connected to pin D9 from 209 to 1. Setting an RC servo or an analog sensor ID in EEPROM is done via the CID command.
103
104 Ex: #203CID2<cr>
105
106 This command will change the ID of the pin A3 from 203 to 2 (and by extension the sensor connected to that pin can be thought of as having that ID). Setting an RC servo or an analog sensor ID in EEPROM is done via the CID command.
107
108 **Pin / ID Default Assignment**
109
110 The code uploaded to the board for use in 2RC mode uses the following ID for each function / pin:
111
112 (% style="width:200px" %)
113 |**PIn/Device**|**ID**
114 |2IO Master ID|207
115 |Pin A3|203
116 |Pin A4|204
117 |Pin A5|205
118 |Pin D9|209
119 |Pin D10|210
120 |Pin D11|211
121
122 {{warningBox warningText="**NOTE:** This is user modifiable with the 2RC Mode communication protocol using the CID command"/}}
123
124
125
126
127
128 ====== __7. Baud Rate__ ======
129
130 Using the suggested code, the default baud rate of the 2IO Board is 115200. Since the 2IO is intended to be daisy chained with LSS, in order to respond to the same serial bus, all LSS/2IOs in a project should be set to the same baud rate. Setting different baud rates may create issues. Available baud rates are: 9600 bps, 19200 bps, 38400 bps, 57600 bps, 115.2 kbps, 230.4 kbps, 250.0 kbps, 460.8 kbps, 500.0 kbps. 2IO Board is shipped with a baud rate set to 115200. The baud rate commands are only restricted to the 2IO Master ID (207 by default).
131
132 Query Baud Rate (**QB**)
133
134 Ex: #207QB<cr> might return *207QB115200<cr>
135
136 Since the command to query the baud rate must be done at the 2IO's existing baud rate, it can simply be used to confirm the CB configuration command was correctly received.
137
138 Configure Baud Rate (**CB**)
139
140 Ex: #207CB9600<cr>
141
142 Sending this command will change the baud rate associated of the 2IO associated with ID 207 to 9600 bits per second.
143
144 Important Note: the 2IO's new baud rate takes effect immediately after sending the CB command.
145
146 ====== __8. Query Model String (**QMS**)__ ======
147
148 Ex: #209QMS<cr> might return *209QMSLSS-2IO-D9<cr>
149
150 This reply means that ID 209 is associated to the 2IO's pin D9.
151
152 Ex: #203QMS<cr> might return *203QMSLSS-2IO-A3<cr>
153
154 This reply means that ID 203 is associated to the 2IO's pin A3.
155
156 ====== __9. **RESET**__ ======
157
158 Ex: #207RESET<cr>
159
160 This command does a "soft reset" (no power cycle required) and reverts all commands to those stored in EEPROM (default values). This command works only with the 2IO Master ID (207 by default) and the broadcast ID (254).
161
162 ====== __10. **DEFAULT**__ ======
163
164 Ex: #207DEFAULT<cr>
165
166 This command sets in motion the reset of all values of the 2IO to defaults and takes effect immediately. This command works only with the 2IO Master ID (207 by default) and the broadcast ID (254).
167
168 ====== __11. **A**nalog__ ======
169
170 This command is not used in the standard LSS protocol.
171
172 Ex: #203QA<cr> might return *203QA364<cr>
173
174 This command queries and returns the raw analog value of a 0V to 5V analog sensor connected to pin A3, which is associated with ID 203.
175
176 As many customers will be using Sharp infrared distance sensors on their robots, the following three commands are used with specific sensors in order to provide a distance measurement.
177
178 Ex: #203QA1<cr> might return *203QA50<cr>
179
180 This command returns the distance (in mm) of the Sharp GP2Y0A41SK0F analog IR sensor connected to pin A3.
181
182 Ex: #204QA2<cr> might return *204QA100<cr>
183
184 This command returns the distance (mm) of the Sharp GP2Y0A21YK0F analog IR sensor connected to pin A4.
185
186 Ex: #205QA3<cr> might return *205QA150<cr>
187
188 This command returns the distance (mm) of the Sharp GP2Y0A02YK0F analog IR sensor connected to pin A5.
Copyright RobotShop 2018