Wiki source code of LSS-2IO Board

Last modified by Eric Nantel on 2023/03/15 07:58

Hide last authors
Eric Nantel 20.1 1 {{lightbox image="LSS-2IO.PNG" width="350"/}}
Eric Nantel 11.1 2
Eric Nantel 219.1 3 [[[[image:[email protected]||alt="buy-online.jpg"]]>>https://www.robotshop.com/products/lynxmotion-lss-2io-arduino-compatible-board||rel="noopener noreferrer" target="_blank"]]
Eric Nantel 143.1 4
Brahim Daouas 142.1 5 **Table of Contents**
Eric Nantel 123.1 6
7 {{toc/}}
8
Brahim Daouas 1.2 9 = Description =
10
RB1 189.1 11 The Lynxmotion LSS-2IO ("Lynxmotion Smart Servo To Input / Output") module was designed as a multi-purpose, Arduino programmable board intended to "bridge the gap" between a Lynxmotion Smart Servo (LSS) serial bus and regular 3-pin RC servos and 5V sensors. Although a default program is included when shipped, it can be re-programmed using the standard Arduino IDE software to communicate with digital, analog or I2C sensors acting as a standard Arduino board. It can also be used as a USB-to-Serial Adapter to directly control a Lynxmotion Smart Servo via USB.
Brahim Daouas 1.2 12
13 = Features =
14
Coleman Benson 155.1 15 * Onboard switch to easily select between three communication modes
Eric Nantel 206.1 16 * USB Type-C connector (Earlier model was using USB Mini)
Brahim Daouas 1.2 17 * 2x LSS connectors allow for daisy chaining
18 * (((
Coleman Benson 155.1 19 6x three row pins to easily connect 3-pin servos & sensors
Brahim Daouas 1.2 20
21 * Digital pins : D9 / D10 / D11 (PWM capable)
22 * Analog & I2C pins : A3 / A4 (SDA) / A5 (SCL)
23 )))
24 * Analog pins 5V rail and Logic 5V are separately powered by two on-board 5V regulators.
RB1 189.1 25 * LED (red): Tx-Rx USB serial activity (Tx & Rx)
26 * LED (green): Power LED (PWR)
Coleman Benson 155.1 27 * LED (RGB): Controlled by the user
28 * Arduino bootloader installed & Arduino IDE compatible
Brahim Daouas 1.2 29 * Lynxmotion Smart Servo (LSS) mounting pattern
Brahim Daouas 115.1 30 * Same form factor as the** **[[LSS - Power Hub>>doc:servo-erector-set-system.ses-electronics.ses-modules.lss-power-hub.WebHome||rel="noopener noreferrer" target="_blank"]]
Brahim Daouas 1.2 31
Brahim Daouas 2.1 32 = Specifications =
Brahim Daouas 1.2 33
Brahim Daouas 179.1 34 * Microcontroller: ATMega328P
RB1 189.1 35 * USB-to-Serial IC: CH340E ([[Driver Download>>https://translate.google.ca/translate?sl=auto&tl=en&u=http%3A%2F%2Fwch.cn%2Fdownloads%2FCH341SER_EXE.html]])
Coleman Benson 153.2 36 * Logic voltage: 5V
37 * Analog voltage rail: 5V
38 * Logic 5V maximum current: 200mA
39 * Analog 5V rail maximum current: 1.2A
40 * Number of analog pins: 3
41 * Number of digital IO pins: 3
42 * Input voltage via LSS connector: 6V-12V
43 * Maximum rated current through LSS connectors: 2A
44 * Default baud rate in 2RC mode (with LSS-2IO Arduino program pre-loaded): 115200
Brahim Daouas 3.3 45
46 = Pinout =
47
Brahim Daouas 4.3 48 |(% colspan="3" style="width:350px" %)(((
49 (% class="wikigeneratedid" id="HExternalPins26Connectors" %)
50 **External Pins & Connectors**
51 )))
Coleman Benson 155.1 52 |(% rowspan="7" style="width:300px" %){{lightbox image="LSS-2IO-External.png"/}}|(% style="vertical-align:middle; width:35px" %)[[image:[email protected]]]|(% style="vertical-align:middle" %)**Vin**: Input voltage supplied by LSS bus (6V to ~~12V).
53 |(% style="vertical-align:middle" %)[[image:[email protected]]]|(% style="vertical-align:middle" %)**Ground (G)**: Common ground.
54 |(% style="vertical-align:middle" %)[[image:[email protected]||alt="SQUARE-Blue.png"]]|(% style="vertical-align:middle" %)**Vout**: Output voltage from onboard 5VDC regulator.
Coleman Benson 154.1 55 |(% style="vertical-align:middle" %)[[image:[email protected]]]|(% style="vertical-align:middle" %)**LSS Rx**
56 |(% style="vertical-align:middle" %)[[image:[email protected]]]|(% style="vertical-align:middle" %)**LSS Tx**
Brahim Daouas 4.3 57 |(% style="vertical-align:middle" %)[[image:[email protected]||alt="SQUARE-Red.png"]]|(% style="vertical-align:middle" %)(((
Coleman Benson 155.1 58 **3x Digital Pins (D9, D10, D11): **PWM Capable.
Brahim Daouas 4.3 59 )))
60 |(% style="vertical-align:middle" %)[[image:[email protected]||alt="SQUARE-Red.png"]]|(% style="vertical-align:middle" %)(((
Brahim Daouas 4.5 61 **3x Analog Pins (A3, A4, A5)**
Brahim Daouas 4.3 62 )))
Brahim Daouas 4.2 63
Brahim Daouas 4.3 64 |(% colspan="3" style="width:350px" %)(((
65 (% class="wikigeneratedid" id="HInternalConnections" %)
66 **Internal Connections**
67 )))
Eric Nantel 40.1 68 |(% colspan="1" rowspan="5" style="width:300px" %){{lightbox image="LSS-2IO-Internal.png"/}}|(% style="vertical-align:middle; width:35px" %)[[image:[email protected]]]|(% style="vertical-align:middle" %)(((
Coleman Benson 155.1 69 **Pin D3: **RGB LED red.
Brahim Daouas 4.3 70 )))
71 |(% style="vertical-align:middle" %)[[image:[email protected]]]|(% style="vertical-align:middle" %)(((
Coleman Benson 155.1 72 **Pin D6: **RGB LED green.
Brahim Daouas 4.3 73 )))
74 |(% style="vertical-align:middle" %)[[image:[email protected]||alt="SQUARE-Red.png"]]|(% style="vertical-align:middle" %)(((
Coleman Benson 155.1 75 **Pin D5: **RGB LED blue.
Brahim Daouas 4.3 76 )))
77 |(% style="vertical-align:middle" %)[[image:[email protected]]]|(% style="vertical-align:middle" %)(((
Brahim Daouas 181.1 78 **Pin D14: **Controls the tri-state buffer (IC3) on the ATMega328P Tx serial line (pulled-down).
Brahim Daouas 4.3 79 )))
Brahim Daouas 181.1 80 |(% style="vertical-align:middle" %)[[image:[email protected]]]|(% style="vertical-align:middle" %)**Pin D7: **Controls the tri-state buffer (IC4) on CH340E Tx / ATMega328P Rx serial line (pulled-up).
Brahim Daouas 4.3 81
Brahim Daouas 3.3 82 = Power =
83
RB1 189.1 84 |(% colspan="1" rowspan="4" style="width:300px" %){{lightbox image="LSS-2IO-Power.png"/}}|(% style="vertical-align:middle; width:35px" %)[[image:[email protected]]]|(% style="vertical-align:middle" %)**LSS Connectors: **The board is meant to be powered from ONE of the two LSS connectors. Vin will supply the two on-board 5V regulators (logic and Vout) and to the Lynxmotion Smart Servos connected on the bus. Refer to LSS Voltage rating in [[LSS - Specifications>>doc:lynxmotion-smart-servo.lss-specifications.WebHome||rel="noopener noreferrer" target="_blank"]]
Brahim Daouas 4.10 85 |(% style="vertical-align:middle; width:35px" %)[[image:[email protected]||alt="SQUARE-Red.png"]]|(% style="vertical-align:middle" %)(((
RB1 189.1 86 **USB: **Connecting only the USB will only provide voltage to the logic. It won't power Vout rail nor LSS connected on the bus.
Brahim Daouas 4.10 87 )))
Coleman Benson 154.1 88 |(% style="vertical-align:middle; width:35px" %)[[image:[email protected]]]|(% style="vertical-align:middle" %)**Vout**: Output voltage rail from onboard 5VDC regulator. Intended to supply sensors requiring low current.
Brahim Daouas 108.1 89 |(% style="vertical-align:middle; width:35px" %)[[image:[email protected]]]|(% style="vertical-align:middle" %)(((
RB1 189.1 90 **Digital Pin Supply:** This rmiddle rail need to be powered from an external power supply depending on what device is connected to the digital pins.
Brahim Daouas 108.1 91
92 [[LSS 5VR Board>>doc:servo-erector-set-system.ses-electronics.ses-modules.lss-5vr.WebHome||rel="noopener noreferrer" target="_blank"]] could be used to supply 5V/2A.
93 )))
Brahim Daouas 4.10 94
Brahim Daouas 138.1 95 {{warningBox warningText="**NOTE:** USB and Vin power source are isolated and there are no issues connecting both a USB and a powered LSS bus at the same time"/}}
96
Eric Nantel 187.1 97
Eric Nantel 206.1 98
Brahim Daouas 9.5 99 = Communication Modes =
Brahim Daouas 4.2 100
RB1 189.1 101 The LSS 2IO Board has three serial communication modes which are selected using the switch SW1. The board is shipped in the 2RC ("to R/C") Mode, pre-loaded with the Lss2IO Arduino program (in the [[AlternativeLSS Arduino Library>>https://github.com/Lynxmotion/AlternativeLSS/]]). The three communication modes are explained below. It is important to note that modes are often a combination of the switch position and the Arduino code running in the ATMega328P chip.
Brahim Daouas 5.5 102
Coleman Benson 155.1 103 == 2RC Mode (as shipped with sample code) ==
Eric Nantel 29.2 104
Brahim Daouas 129.1 105 (% style="margin-right:auto" %)
Eric Nantel 161.1 106 |(% style="text-align:left; width:300px" %)**Switch Position**|(% style="text-align:left" %)**Mode Information**
Eric Nantel 46.1 107 |(% style="width:300px" %){{lightbox image="LSS-2IO-Mode-2RC.png"/}}|(((
RB1 189.1 108 In this mode, with the right code, the 2IO Board behaves as a "peripheral" device and allows for control of multiple RC servos and IO that can be daisy-chained on the LSS bus through the LSS connectors. To use this mode, have the Lss2IO Arduino program (in the [[AlternativeLSS Arduino Library>>https://github.com/Lynxmotion/AlternativeLSS/]]) running on the ATMega328P chip and move the switch to the "2RC" position. The 2IO Board will process LSS protocol commands to query information from sensors or send action commands to RC servos attached to the IO pins of the 2IO Board.
Brahim Daouas 100.5 109
110 (((
Eric Nantel 46.1 111 **Use-cases :**
Eric Nantel 38.2 112
RB1 189.1 113 * Control RC Servos (pins D9, D10 and D11) to the LSS Bus and control them using the [[2RC Communication Protocol>>doc:servo-erector-set-system.ses-electronics.ses-modules.lss-2io-board.2io-2rc-mode-communication-protocol.WebHome||rel="noopener noreferrer" target="_blank"]] which is a reduced version of the [[LSS Protocol>>doc:lynxmotion-smart-servo.lss-communication-protocol.WebHome||rel="noopener noreferrer" target="_blank"]].
114 ** Example: #209D900<cr>. This moves the RC servo connected to pin D9 to an angle of 90 degrees. More information on the 2IO Communication Protocol [[here>>doc:servo-erector-set-system.ses-electronics.ses-modules.lss-2io-board.2io-2rc-mode-communication-protocol.WebHome||rel="noopener noreferrer" target="_blank"]].
115 * Query analog 5V sensors (pin A3, A4 and A5) using the [[2RC Communication Protocol>>doc:servo-erector-set-system.ses-electronics.ses-modules.lss-2io-board.2io-2rc-mode-communication-protocol.WebHome||rel="noopener noreferrer" target="_blank"]] which is a refined version of the [[LSS Protocol>>doc:lynxmotion-smart-servo.lss-communication-protocol.WebHome||rel="noopener noreferrer" target="_blank"]].
116 ** Example: #203QA<cr>. This will return the raw value of the analog sensor connected to pin A3. More information on the 2IO Communication Protocol [[here>>doc:servo-erector-set-system.ses-electronics.ses-modules.lss-2io-board.2io-2rc-mode-communication-protocol.WebHome||rel="noopener noreferrer" target="_blank"]].
Eric Nantel 38.3 117 )))
Brahim Daouas 100.5 118 )))
Eric Nantel 38.3 119
Eric Nantel 171.1 120 |**Sample Wiring / Use**
Eric Nantel 160.1 121 |{{lightbox image="LSS-2IO-Wiring-2RC.PNG" width="900"/}}
Brahim Daouas 9.21 122
RB1 189.1 123 **Internal Serial Connection**
Brahim Daouas 70.11 124
RB1 189.1 125 In this mode, the board is effectively a "peripheral". In order to respond to LSS commands, it needs to be running appropriate code, or the default Lss2IO Arduino sample program. The pinout is as follows:
Brahim Daouas 70.11 126
RB1 189.1 127 * ATMega328P's Tx pin (D1) is connected to the LSS Tx line through a [[tri-state buffer (IC3)>>https://en.wikipedia.org/wiki/Three-state_logic||rel="noopener noreferrer" target="_blank"]] that can be enabled or disabled with pin D14.
128 * ATMega328P's Rx pin (D0) is connected to the LSS Rx line.
Brahim Daouas 79.2 129
RB1 189.1 130 Therefore data that is sent from an external UART device will be received on the LSS Rx line and the ATMega328P Rx pin. The LSS 2IO USB-to-Serial IC Tx is connected to the ATMega328P Rx (pin D0) through another [[tri-state buffer (IC4)>>https://en.wikipedia.org/wiki/Three-state_logic||rel="noopener noreferrer" target="_blank"]] that can be enabled/disabled with pin D7. The Lss2IO Arduino code inherently takes care of managing the pins D14 and D7 as follows :
Coleman Benson 155.1 131
RB1 189.1 132 * **D7 **is LOW**: **to disconnect LSS 2IO USB-to-Serial IC Tx from ATMega328P Rx (pin D0) allowing the ATMega328P to receive data from the UART controller device as LSS 2IO USB-to-Serial IC Tx is HIGH when LSS 2IO is powered.
133 * **D14** is HIGH**:** when the 2IO Board is sending data on the LSS Tx line to an external UART device Rx pin. LSS Tx line is asserted to the 2IO Tx pin :
Brahim Daouas 9.6 134
Eric Nantel 83.1 135 {{lightbox image="LSS-2IO-Schematic-2RC-D14HIGH.png" width="900"/}}
Brahim Daouas 70.13 136
Coleman Benson 156.1 137 * **D14 **is LOW**:** when the 2IO Board is not sending data on the LSS Tx line. The 2IO frees up the LSS Tx line to avoid bus congestion (when 2 devices sends data at the same time) :
Brahim Daouas 70.13 138
Eric Nantel 85.1 139 {{lightbox image="LSS-2IO-Schematic-2RC-D14LOW.png" width="900"/}}
Brahim Daouas 73.2 140
Brahim Daouas 89.4 141 {{warningBox warningText="**NOTE:** Double check that the Lss2IO Arduino program is loaded in the 2IO's ATMega328P to be able to use this mode"/}}
Brahim Daouas 79.1 142
Eric Nantel 187.1 143
Eric Nantel 206.1 144
Coleman Benson 155.1 145 **Pin / ID Default Assignment**
Brahim Daouas 153.1 146
RB1 189.1 147 The following pinout is used in the sample code so as to not interfere with any other guides or manuals. This pinout can be changed in the Arduino program.
Brahim Daouas 153.1 148
Brahim Daouas 152.1 149 (% style="width:459px" %)
150 |(% style="width:111px" %)**PIn/Device**|(% style="width:52px" %)**ID**|(% style="width:139px" %)**Middle Pin Supply**|(% style="width:135px" %)**Notes**
Coleman Benson 155.1 151 |(% style="width:111px" %)2IO Master ID|(% style="width:52px" %)207|(% style="width:139px" %)-|(% style="width:135px" %)RGB LED
152 |(% style="width:111px" %)A3|(% style="width:52px" %)203|(% style="width:139px" %)5V|(% style="width:135px" %)Analog Pin
153 |(% style="width:111px" %)A4|(% style="width:52px" %)204|(% style="width:139px" %)5V|(% style="width:135px" %)Analog Pin
154 |(% style="width:111px" %)A5|(% style="width:52px" %)205|(% style="width:139px" %)5V|(% style="width:135px" %)Analog Pin
155 |(% style="width:111px" %)D9|(% style="width:52px" %)209|(% style="width:139px" %)Not Connected|(% style="width:135px" %)Digital Pin
156 |(% style="width:111px" %)D10|(% style="width:52px" %)210|(% style="width:139px" %)Not Connected|(% style="width:135px" %)Digital Pin
157 |(% style="width:111px" %)D11|(% style="width:52px" %)211|(% style="width:139px" %)Not Connected|(% style="width:135px" %)Digital Pin
Eric Nantel 219.1 158 |(% colspan="4" style="width:111px" %)To change the ID,s you can look at the "CID" command [[HERE>>https://wiki.lynxmotion.com/info/wiki/lynxmotion/view/servo-erector-set-system/ses-electronics/ses-modules/lss-2io-board/2io-2rc-mode-communication-protocol/#H6.IdentificationNumber28ID29]]
Brahim Daouas 150.2 159
Brahim Daouas 153.1 160 {{warningBox warningText="**NOTE:** For a Factory Reset of the 2IO Board in the 2RC Mode, hold the LSS Rx line LOW on power-up by connecting LSS Rx to Ground (Refer to Pinout section). 2IO RGB LED will cycle between RED-GREEN-BLUE. Keep holding LSS Rx LOW until the LED start blinking white. At this point, the Firmware is reset and the jumper can be removed. It will RESET after 3 white blink cycles. If jumper is still connected it will enter Firmware reset again."/}}
161
Eric Nantel 187.1 162
Eric Nantel 206.1 163
Brahim Daouas 4.2 164 == Arduino ==
165
Eric Nantel 161.1 166 |(% style="text-align:left; width:300px" %)**Switch Position**|(% style="text-align:left" %)**Mode Information**
Brahim Daouas 78.1 167 |(% style="width:300px" %){{lightbox image="LSS-2IO-Mode-Arduino.png"/}}|(((
RB1 189.1 168 In this mode, the 2IO Board acts as a "controller", or an Arduino-based robot controller / "Robot Brain" that can control LSS servos. When in Arduino mode, the 2IO board can be loaded with any Arduino program / sketch via the [[Arduino IDE>>https://www.arduino.cc/en/main/software||rel="noopener noreferrer" target="_blank"]]. In IDE, select "Tools -> **Arduino Nano"** and "**ATMega328P** Processor" should be selected. Making sure that the correct COM port is also selected (which is computer dependent). The [[Official Lynxmotion Smart Servo (LSS) Arduino Library & Examples>>https://github.com/Lynxmotion/LSS_Library_Arduino||rel="noopener noreferrer" target="_blank"]] could be a good starting point.
Brahim Daouas 100.5 169
170 (((
Coleman Benson 155.1 171 **Use-cases:**
Brahim Daouas 78.2 172
RB1 189.1 173 * The LSS 2IO Board controls a robotic platform built using Lynxmotion Smart Servos (LSS)
Coleman Benson 155.1 174 * The 2IO Board is used as an Arduino Compatible board to light LEDs, control RC servos, read sensors and much more.
Brahim Daouas 78.1 175 )))
Brahim Daouas 100.5 176 )))
Eric Nantel 46.2 177
Eric Nantel 171.1 178 |**Sample Wiring / Use**
Eric Nantel 163.1 179 |{{lightbox image="LSS-2IO-Wiring-Arduino.PNG" width="900"/}}
Brahim Daouas 78.2 180
RB1 189.1 181 **Internal Serial Connections**
Brahim Daouas 78.2 182
RB1 189.1 183 In this mode, the board is effectively a "peripheral". With the 2IO Board in Arduino mode:
Brahim Daouas 79.3 184
Coleman Benson 155.1 185 * ATMega328P Tx pin (D1) is connected to the LSS Rx line
RB1 189.1 186 * ATMega328P Rx pin (D0) is connected to the LSS Tx line. Therefore, the 2IO can send and receive data to/from LSS servos.
Coleman Benson 155.1 187
RB1 189.1 188 {{warningBox warningText="**NOTE:** It is important to set D7 LOW in your Arduino sketch to disconnect LSS 2IO USB-to-Serial IC Tx from ATMega328P Rx (pin D0) through the tri-state buffer (IC4) allowing the ATMega328P to be able to receive data from the LSS."/}}
Brahim Daouas 92.1 189
Eric Nantel 187.1 190
Eric Nantel 206.1 191
Eric Nantel 83.1 192 {{lightbox image="LSS-2IO-Schematic-Arduino.png" width="900"/}}
Eric Nantel 57.1 193
Eric Nantel 168.1 194 == Direct (USB to Serial) ==
Brahim Daouas 4.2 195
Eric Nantel 161.1 196 |(% style="text-align:left; width:300px" %)**Switch Position**|(% style="text-align:left" %)**Mode Information**
Brahim Daouas 78.3 197 |(% style="width:300px" %){{lightbox image="LSS-2IO-Mode-Direct.png"/}}|(((
RB1 189.1 198 In this mode, the LSS 2IO Board will act as a USB-to-UART converter allowing to control Lynxmotion Smart Servos (LSS) with a USB device (Computer, Raspberry Pi, etc..). To use this mode, the switch should be in the "Direct" position**. **It is also important to make sure that the ATMega328P is not loaded with a sketch making use of the ATMega328P hardware serial pins (D0 and D1).** **The best way to make sure of that, would be to load a **"BareMnimum"** Arduino sketch that can be found in [[Arduino IDE>>https://www.arduino.cc/en/main/software||rel="noopener noreferrer" target="_blank"]] File -> Examples -> 01.Basics. The pin D7 should also not be set LOW (by default, this pin is HIGH by a pull-up resistor R1).
Brahim Daouas 100.5 199
200 (((
201 **Use-cases :**
202
RB1 189.1 203 * Configure or control an LSS using [[LSS Configuration Software>>doc:lynxmotion-smart-servo.lss-configuration-software.WebHome||rel="noopener noreferrer" target="_blank"]] with a computer
Brahim Daouas 78.3 204 )))
Brahim Daouas 100.5 205 )))
Brahim Daouas 78.3 206
Eric Nantel 171.1 207 |**Sample Wiring / Use**
Eric Nantel 168.1 208 |{{lightbox image="LSS-2IO-Wiring-Direct.PNG" width="900"/}}
Brahim Daouas 78.3 209
RB1 189.1 210 **Internal Serial Connections**
Brahim Daouas 78.3 211
RB1 189.1 212 With the 2IO Board in Direct mode (Switch on "Direct" position), the USB-to-Serial IC Rx is connected to the LSS Tx line and the USB-to-Serial IC Tx is connected to the LSS Rx line. Therefore, the USB Device can send and receive data to/from LSS servos.
Brahim Daouas 102.2 213
214 {{warningBox warningText="**NOTE:** It is important to make sure that the ATMega328P is not loaded with a sketch making use of the ATMega328P hardware serial pins (D0 and D1) and that the pin D7 is NOT set LOW"/}}
215
Eric Nantel 187.1 216
Eric Nantel 206.1 217
Eric Nantel 83.1 218 {{lightbox image="LSS-2IO-Schematic-Direct.png" width="900"/}}
Eric Nantel 57.1 219
Eric Nantel 185.1 220 = Advanced Pinout =
221
222 {{lightbox image="LSS-2IO-PINOUT.png" width="700"/}}
223
Eric Nantel 134.1 224 = Dimensions & Mounting =
Eric Nantel 132.1 225
Eric Nantel 134.1 226 |(% style="width:300px" %){{lightbox image="LSS-2IO-Dimensions.png"/}}|(% style="width:300px" %)[[image:LSS-2IO-Mounting.gif]]|
Copyright RobotShop 2018