2RC Communication Protocol

Last modified by Eric Nantel on 2024/07/03 09:39

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. 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.

A special thanks goes to C. Mackenzie for his contributions to this project.

Command List

 #Description Action Query Config Units NotesDefault Value
1Limp L  noneUsed for RC servos connected on the 2IO 
2Position in Pulse P QP microseconds

Inherited from SSC-32 serial protocol

 
3Position in Degrees D QD tenths of degrees   
4LED Color LED QLED CLEDnone (integer from 0 to 7)0=Off (black); 1=Red 2=Green; 3=Blue; 4=Yellow; 5=Cyan; 6=Magenta; 7=White.0 (OFF)
5Gyre direction (G) G QG CGnone Gyre / rotation direction: 1= CW (clockwise) -1 = CCW (counter-clockwise)1
6ID #   CIDnone (integer from 0 to 250)Note: ID 254 is a "broadcast" which all servos / modules respond to.  
7Baud rate  QB CBnone (integer) 115200
8Model String QMS none (string)  
9RESETRESET  noneSoft reset. See command for details. 
10DEFAULT   noneRevert to firmware default values. See command for details. 
11Analog QA Analog QA : returns raw value / QA1: calculated distance (mm) for Sharp GP2Y0A41SK0F / QA2: distance (mm) for Sharp GP2Y0A21YK0F / QA3: distance (mm) for Sharp GP2Y0A02YK0F 

Details

1. Limp (L)

Example: #209L<cr>

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>.

2. Position in Pulse (P)

Example: #209P2334<cr>

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.

Query Position in Pulse (QP)

Example: #209QP<cr> might return *209QP2334

This command queries the angular position of the RC servo connected to pin D9 in PWM "units".

3. Position in Degrees (D)

Example: #209D1456<cr>

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.

Query Position in Degrees (QD)

Example: #209QD<cr> might return *209QD132<cr>

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.

4. LED Color (LED)

Ex: #207LED3<cr>

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). 

0=Off (black); 1=Red 2=Green; 3=Blue; 4=Yellow; 5=Cyan; 6=Magenta; 7=White; 

Query LED Color (QLED)

Ex: #207QLED<cr> might return *207QLED5<cr>

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). 

Configure LED Color (CLED)

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). 

5. Gyre Rotation Direction (G)

"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). 

Ex: #209G-1<cr>

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. 

Query Gyre Direction (QG)

Ex: #209QG<cr> might return *209QG-1<cr>

The value returned above means the servo/analog sensor is in a counter-clockwise gyration.

Configure Gyre (CG)

Ex: #209CG-1<cr>

This changes the gyre direction as described above and also writes to EEPROM.

6. Identification Number (ID)

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.

Configure ID (CID)

Ex: #209CID1<cr>

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.

Ex: #203CID2<cr>

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.

Pin / ID Default Assignment

The code uploaded to the board for use in 2RC mode uses the following ID for each function / pin:

PIn/DeviceID
2IO Master ID207
Pin A3203
Pin A4204
Pin A5205
Pin D9209
Pin D10210
Pin D11211

NOTE: This is user modifiable with the 2RC Mode communication protocol using the CID command

7. Baud Rate

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).

Query Baud Rate (QB)

Ex: #207QB<cr> might return *207QB115200<cr>

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.

Configure Baud Rate (CB)

Ex: #207CB9600<cr>

Sending this command will change the baud rate associated of the 2IO associated with ID 207 to 9600 bits per second.

Important Note: the 2IO's new baud rate takes effect immediately after sending the CB command.

8. Query Model String (QMS)

Ex: #209QMS<cr> might return *209QMSLSS-2IO-D9<cr>

This reply means that ID 209 is associated to the 2IO's pin D9.

Ex: #203QMS<cr> might return *203QMSLSS-2IO-A3<cr>

This reply means that ID 203 is associated to the 2IO's pin A3.

9. RESET

Ex: #207RESET<cr>

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). 

10. DEFAULT

Ex: #207DEFAULT<cr>

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).

11. Analog

This command is not used in the standard LSS protocol. 

Ex: #203QA<cr> might return *203QA364<cr>

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.

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.

Ex: #203QA1<cr> might return *203QA50<cr>

This command returns the distance (in mm) of the Sharp GP2Y0A41SK0F analog IR sensor connected to pin A3.

Ex: #204QA2<cr> might return *204QA100<cr>

This command returns the distance (mm) of the Sharp GP2Y0A21YK0F analog IR sensor connected to pin A4.

Ex: #205QA3<cr> might return *205QA150<cr>

This command returns the distance (mm) of the Sharp GP2Y0A02YK0F analog IR sensor connected to pin A5.

Recently Visited

Copyright RobotShop 2018