Lynxmotion SSC-32 Protocol Tutorial

Last modified by Eric Nantel on 2022/11/01 07:26

Serial Protocols

Many hardware devices communication with the computer using a serial protocol. Some are simple ASCII-based protocols, but others can be more complex binary ones that require checksums. No matter, both can easily be made in FlowBotics.

Let's use the Lynxmotion SSC-32 servo controller board as an example of an ASCII protocol. If you open any of the Lynxmotion projects, you will find the "LM SC-32 + Comport" module inside a few levels of schematics that handles all the protocol communications and COM port management.

This module does a few things. The left portion pre-processes the virtual robot's data to get them ready to be encoded into the protocol for transfer to the SSC-32 board. The right portion takes the protocol data received from the SSC-32 board, and extracts various state and input pin signals.

The two main workhorses of the schematic is the "LM SC-32 Engine" and "Comport" modules:

lynxmotion-ssc-32-protocol-engine.png
The engine module has all the protocol encoding logic, so let's take a look at that.

Using Ruby

In this case, we implemented the protocol using a Ruby module, but it could also be implemented using the FlowBotics graphical language.
lynxmotion-ssc-32-protocol-ruby.png

The code is pretty simple:

  1. Wait until new "data" signals arrive.
    • Note: The "i" variable has the number of the input that changed. In this case "data" is input "0".
  2. Loop through all the positions in the data array, and make the servo position string.
  3. Output the servo string, and the "outputs" string.
  4. Every other time, also output the input poll string.
  5. Finally, output the "Q" query string.

The four output strings are output as four different signals because there's some additional logic (offscreen) that treats them a bit differently. If you have any questions about how this works, ask us in our forum and we'll be glad to explain it to you!

For documentation of the Ruby language, we recommend the Ruby Doc site.

<< Back to Developer Zone

 

Tags:
Created by Eric Nantel on 2022/03/16 14:33
Copyright RobotShop 2018