Wiki source code of 2RC Communication Protocol

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

Hide last authors
Brahim Daouas 180.1 1 (% class="wikigeneratedid" %)
Coleman Benson 191.3 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.
Brahim Daouas 180.1 3
Coleman Benson 191.3 4 (% class="wikigeneratedid" %)
5 //A special thanks goes to C. Mackenzie for his contributions to this project.//
6
Brahim Daouas 175.1 7 = Command List =
8
Coleman Benson 191.3 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" %)
Eric Nantel 198.1 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" %)(((
Coleman Benson 93.1 12 Inherited from SSC-32 serial protocol
13 )))|(% style="text-align:center; width:113px" %)
Eric Nantel 198.1 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" %)
Eric Nantel 159.1 23
Coleman Benson 191.2 24 == Details ==
Brahim Daouas 181.10 25
Eric Nantel 160.1 26 ====== __1. Limp (**L**)__ ======
27
Brahim Daouas 180.5 28 Example: #209L<cr>
Eric Nantel 160.1 29
Coleman Benson 191.3 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>.
Eric Nantel 160.1 31
Eric Nantel 162.3 32 ====== __2. Position in Pulse (**P**)__ ======
Eric Nantel 160.1 33
Brahim Daouas 181.4 34 Example: #209P2334<cr>
Eric Nantel 160.1 35
Coleman Benson 191.5 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.
Eric Nantel 160.1 37
38 Query Position in Pulse (**QP**)
39
Brahim Daouas 181.4 40 Example: #209QP<cr> might return *209QP2334
Eric Nantel 160.1 41
Coleman Benson 191.5 42 This command queries the angular position of the RC servo connected to pin D9 in PWM "units".
Eric Nantel 160.1 43
Eric Nantel 162.3 44 ====== __3. Position in Degrees (**D**)__ ======
Eric Nantel 160.1 45
Brahim Daouas 181.5 46 Example: #209D1456<cr>
Eric Nantel 160.1 47
Coleman Benson 191.5 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.
Eric Nantel 160.1 49
50 Query Position in Degrees (**QD**)
51
Brahim Daouas 181.6 52 Example: #209QD<cr> might return *209QD132<cr>
Eric Nantel 160.1 53
Coleman Benson 191.5 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.
Eric Nantel 160.1 55
Eric Nantel 162.3 56 ====== __4. LED Color (**LED**)__ ======
Eric Nantel 160.1 57
Brahim Daouas 181.8 58 Ex: #207LED3<cr>
Eric Nantel 160.1 59
Coleman Benson 191.5 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).
Eric Nantel 160.1 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
Brahim Daouas 181.9 66 Ex: #207QLED<cr> might return *207QLED5<cr>
Eric Nantel 160.1 67
Brahim Daouas 185.9 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).
Eric Nantel 160.1 69
70 Configure LED Color (**CLED**)
71
Coleman Benson 191.5 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).
Eric Nantel 160.1 73
Eric Nantel 162.3 74 ====== __5. Gyre Rotation Direction (**G**)__ ======
Eric Nantel 160.1 75
Coleman Benson 191.5 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).
Eric Nantel 160.1 77
Brahim Daouas 181.12 78 Ex: #209G-1<cr>
Eric Nantel 160.1 79
Coleman Benson 191.5 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.
Eric Nantel 160.1 81
82 Query Gyre Direction (**QG**)
83
Brahim Daouas 181.13 84 Ex: #209QG<cr> might return *209QG-1<cr>
Eric Nantel 160.1 85
Brahim Daouas 181.14 86 The value returned above means the servo/analog sensor is in a counter-clockwise gyration.
Eric Nantel 160.1 87
88 Configure Gyre (**CG**)
89
Brahim Daouas 181.15 90 Ex: #209CG-1<cr>
Eric Nantel 160.1 91
92 This changes the gyre direction as described above and also writes to EEPROM.
93
Eric Nantel 162.3 94 ====== __6. Identification Number (**ID**)__ ======
Eric Nantel 160.1 95
Coleman Benson 191.6 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.
Eric Nantel 160.1 97
98 Configure ID (**CID**)
99
Brahim Daouas 182.8 100 Ex: #209CID1<cr>
Eric Nantel 160.1 101
Brahim Daouas 182.8 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.
Eric Nantel 160.1 103
Brahim Daouas 182.8 104 Ex: #203CID2<cr>
105
Coleman Benson 191.6 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.
Brahim Daouas 182.8 107
Brahim Daouas 188.2 108 **Pin / ID Default Assignment**
109
Coleman Benson 191.6 110 The code uploaded to the board for use in 2RC mode uses the following ID for each function / pin:
111
Brahim Daouas 188.2 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
Brahim Daouas 191.1 122 {{warningBox warningText="**NOTE:** This is user modifiable with the 2RC Mode communication protocol using the CID command"/}}
123
124
Brahim Daouas 193.1 125
Brahim Daouas 194.1 126
Eric Nantel 198.1 127
Eric Nantel 162.3 128 ====== __7. Baud Rate__ ======
Eric Nantel 160.1 129
Coleman Benson 191.3 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).
Eric Nantel 160.1 131
132 Query Baud Rate (**QB**)
133
Brahim Daouas 182.12 134 Ex: #207QB<cr> might return *207QB115200<cr>
Eric Nantel 160.1 135
Brahim Daouas 182.14 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.
Eric Nantel 160.1 137
138 Configure Baud Rate (**CB**)
139
Brahim Daouas 182.15 140 Ex: #207CB9600<cr>
Eric Nantel 160.1 141
Brahim Daouas 182.15 142 Sending this command will change the baud rate associated of the 2IO associated with ID 207 to 9600 bits per second.
Eric Nantel 160.1 143
Brahim Daouas 182.16 144 Important Note: the 2IO's new baud rate takes effect immediately after sending the CB command.
Eric Nantel 160.1 145
Eric Nantel 162.3 146 ====== __8. Query Model String (**QMS**)__ ======
Eric Nantel 160.1 147
Brahim Daouas 185.2 148 Ex: #209QMS<cr> might return *209QMSLSS-2IO-D9<cr>
Eric Nantel 160.1 149
Coleman Benson 191.7 150 This reply means that ID 209 is associated to the 2IO's pin D9.
Eric Nantel 160.1 151
Brahim Daouas 185.4 152 Ex: #203QMS<cr> might return *203QMSLSS-2IO-A3<cr>
153
Coleman Benson 191.7 154 This reply means that ID 203 is associated to the 2IO's pin A3.
Brahim Daouas 185.4 155
Brahim Daouas 183.1 156 ====== __9. **RESET**__ ======
Eric Nantel 160.1 157
Brahim Daouas 185.5 158 Ex: #207RESET<cr>
Eric Nantel 160.1 159
Coleman Benson 191.7 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).
Eric Nantel 160.1 161
Brahim Daouas 185.1 162 ====== __10. **DEFAULT**__ ======
Eric Nantel 160.1 163
Brahim Daouas 185.8 164 Ex: #207DEFAULT<cr>
Eric Nantel 160.1 165
Coleman Benson 191.7 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).
Eric Nantel 160.1 167
Brahim Daouas 193.1 168 ====== __11. **A**nalog__ ======
Eric Nantel 162.1 169
Coleman Benson 191.7 170 This command is not used in the standard LSS protocol.
171
Brahim Daouas 185.15 172 Ex: #203QA<cr> might return *203QA364<cr>
Eric Nantel 160.1 173
Coleman Benson 191.7 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.
Brahim Daouas 185.14 175
Coleman Benson 191.7 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
Brahim Daouas 185.16 178 Ex: #203QA1<cr> might return *203QA50<cr>
Eric Nantel 160.1 179
Coleman Benson 191.7 180 This command returns the distance (in mm) of the Sharp GP2Y0A41SK0F analog IR sensor connected to pin A3.
Eric Nantel 160.1 181
Brahim Daouas 185.16 182 Ex: #204QA2<cr> might return *204QA100<cr>
183
Coleman Benson 191.7 184 This command returns the distance (mm) of the Sharp GP2Y0A21YK0F analog IR sensor connected to pin A4.
Brahim Daouas 185.16 185
186 Ex: #205QA3<cr> might return *205QA150<cr>
187
Coleman Benson 191.7 188 This command returns the distance (mm) of the Sharp GP2Y0A02YK0F analog IR sensor connected to pin A5.
Copyright RobotShop 2018