2MC Communication Protocol
Using the LSS-2MC Code
Using the LSS-2MC with it's example code will allows the user to control two brushed DC or a single bipolar stepper motor. Being an ongoing project check the available functions bellow.
Global | |||||||
---|---|---|---|---|---|---|---|
Description | Action | Query | Config | Default | Units | Notes | |
ID # | QID | CID | 215 / 216 | none (integer from 0 to 250) | Note: ID 254 is a "broadcast" which all servos / modules respond to. | ||
Motor Mode | QMM | CMM | 0 / 1 | 0 = Stepper Mode / 1 = Brushed DC Mode | |||
Gyre direction (G) | G | QG | CG | 1 | 1 / -1 | Gyre / rotation direction: To invert the polarity or direction | |
Baud rate | QB | CB | 115200 | none (integer) | |||
Model String | QMS | LSS-2MC-XX | DBR = HBridge | ||||
RESET | RESET | None | Soft reset. See command for details. | ||||
Limp | L | None | MM0 = Stop / MM1 = Coast to a stop | ||||
Halt & Hold | H | None | MM0 = Stop & Hold / MM1 Stop with brake | ||||
Motion Mode | Q | 0 = Holding / 1 = Stepping / 2 = Speed / 3 = Angle | |||||
DC Motor / H-Bridge | |||||||
Raw Duty-cycle Move | RDM | QRDM | 0 | -255 / 255 | Set duty-cycle and truncated to 255 if exceeded | ||
Stepper Motor | |||||||
Wheel mode in Degrees | WD | QWD | 0 | °/s | -9000 / 9000 in tenths of degs/sec |
Identification Number (ID)
Identification number connected to the 2MC Board can be configured via the CID command described below. The factory default ID (as per the sketch loaded at the factory) for all 2MC pins is indicated in the Pin / ID table above. Since LSS & 2MC 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. Note: Most people will keep the default ID unless using multiple LSS-2MC on the same communication bus. | |
Configure ID (CID) Ex: #215CID200<cr> Query ID (QID) Ex: #215QID<cr> might return *215QID215 |
Motor Mode (MM)
Our example code allows for two types of motors to be used, either Brushed DC or Stepper. One need to set the mode in which they want to use the LSS-2MC. | |
Configure Motor Mode (MM) Ex: #215CMM0<cr> should return *215QMM0<cr> Ex: #215CMM1<cr> should return *215QMM1<cr> Query Motor Mode (QMM) Ex: #215QMM<cr> might return *215QMM0<cr> |
Gyre Rotation Direction (G)
Ex: #215G-1<cr> Reverse the polarity / rotation for the given output. |
Baud Rate (B)
Since it's intended to be daisy chained with LSS, in order to respond to the same serial bus, all LSS / 2MCs 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. 2MC Board is shipped with a baud rate set to 115200. | |
Configure Baud Rate (CB) Ex: #215CB9600<cr> Important Note: the 2MC new baud rate takes effect immediately after sending the CB command. Query Baud Rate (QB) Ex: #215QB<cr> might return *207QB115200<cr> |
Query Model String (QMS)
Ex: #215QMS<cr> might return *215QMSLSS-2MC-DBR<cr> Ex: #215QMS<cr> might return *216QMSLSS-2MC-ST<cr> |
Reset (RESET)
Ex: #215RESET<cr> |
Limp (L)
Ex: #215L<cr> Ex: #254L<cr> |
Halt & Hold (H)
Stepper Mode (MM0) Ex: #215H<cr> | |
Brushed DC Mode (MM1) Ex: #215H<cr> |
Motion Mode
Ex: #215Q<cr> might return *215Q0<cr> 0 = Holding |
Raw Duty-cycle Move (RDM)
Ex: #215RDM255<cr> Ex: #215RDM-255<cr> |
Wheel Mode in Degrees (WD)
Ex: #215WD900<cr> |