Supported Sensors

SainSmart 16 Channel Controller

sainsmart-usb
V2.0.0-pr.2
USB
340

Supported hardware versions

The driver interface communicates with the SainSmart 16-Channel Controller through the USB interface.

Manufacturer SainSmart
Hardware ID SainSmart 16 Channel Controller

Requirements and background

Sainsmart’s 16 channel control relay is a USB HID Programmable Control Relay which is ideal for robotics and power supply control.

Sensor Notes

Only one sensor is supported per ECU/machine.

There are no input or output PolySync message types, the interface communicates directly with the device to toggle relays on and off.

To replay logged sessions, the sainsmart node must first be disabled in the SDF Configurator.

Hardware requirements

  • 12V power
  • An ECU with a USB port
  • ECU with PolySync Core installed

Connecting the sensor

  • Connect the sensor through the usb interface to the ECU

Configuring the PolySync driver

The default PolySync Configurator configuration has shown to work out of the box on most systems.

Adding the sensor to the SDF

Using the Configurator tool, add a sensor node to the SDF.

The SainSmart 16-Channel Controller ‘Node Interface’ name is sainsmart-usb.

Configuration parameters

Node Configuration Parameters

Parameter ID Description Value Type Values Notes
4434 Override Enabled State. False: 0, True all on: 1, True all off: 2 1 0
4435 All channels off when driver exits 1 1
4417 Name of Channel 1 4 Channel 1
4401 Channel 1 Enabled (true: 1, false: 0) 1 0
4418 Name of Channel 2 4 Channel 2
4402 Channel 2 Enabled (true: 1, false: 0) 1 0
4419 Name of Channel 3 4 Channel 4
4403 Channel 3 Enabled (true: 1, false: 0) 1 0
4420 Name of Channel 4 4 Channel 4
4404 Channel 4 Enabled (true: 1, false: 0) 1 0
4421 Name of Channel 5 4 Channel 5
4405 Channel 5 Enabled (true: 1, false: 0) 1 0
4422 Name of Channel 6 4 Channel 6
4406 Channel 6 Enabled (true: 1, false: 0) 1 0
4423 Name of Channel 7 4 Channel 7
4407 Channel 7 Enabled (true: 1, false: 0) 1 0
4424 Name of Channel 8 4 Channel 8
4408 Channel 8 Enabled (true: 1, false: 0) 1 0
4425 Name of Channel 9 1 0
4409 Channel 9 Enabled (true: 1, false: 0) 4 Channel 9
4426 Name of Channel 10 4 Channel 10
4410 Channel 10 Enabled (true: 1, false: 0) 1 0
4427 Name of Channel 11 4 Channel 11
4411 Channel 11 Enabled (true: 1, false: 0) 1 0
4428 Name of Channel 12 4 Channel 12
4412 Channel 12 Enabled (true: 1, false: 0) 1 0
4429 Name of Channel 13 4 Channel 13
4413 Channel 13 Enabled (true: 1, false: 0) 1 0
4430 Name of Channel 14 4 Channel 14
4414 Channel 14 Enabled (true: 1, false: 0) 1 0
4431 Name of Channel 15 4 Channel 15
4415 Channel 15 Enabled (true: 1, false: 0) 1 0
4432 Name of Channel 16 4 Channel 16
4416 Channel 16 Enabled (true: 1, false: 0) 1 0
4400 USB vendor ID 1 1046
4433 USB product ID 1 20512
42 PolySync-Abstraction-Layer Interface File Name 4 /usr/local/polysync/lib/libps_sainsmart_usb_interface.so
40 Executable File Path 4 /usb/local/polysync/bin/polysync-core-dynamic-driver
Default configuration

The values in the default configuration are set by the sensors firmware.

Validating the sensor is properly configured

If you’re approaching a new PolySync system or need to validate an existing configuration you can use the following checklist to ensure the sensor is properly configured.

Set up checklist

If the sensor passes this checklist then the PolySync dynamic driver will likely be able to communicate with the sensor.

  1. Ensure you can connect to the sensor’s usb port with console as described in the Configuring the sensor section
  2. Use the -t command line argument to perform a validation test on the SainSmart 16 Channel Controller
    • WARNING validation test activates and deactivates all switches, power will be cycled on all devices connected during test
  3. Use the test interface to enable each channel and it’s LED in sequence then disable each channel in sequence. You can also hear two sets of audible clicks. bash $ polysync-core-dynamic-driver -n 1 -o -t

Starting the PolySync driver

The configuration set in the Configurator is loaded from the SDF when the dynamic driver starts. It connects to the sensor through the serial port, requests the data, and waits for confirmation that the sensor configuration is valid.

When the dynamic driver receives the first packet of data, it begins processing and abstracting the data from the OEM data structure in a high-level hardware agnostic message type.

  1. Power the sensor and ECU on
  2. Optionally follow the set up checklist
  3. Start the PolySync Core manager
    • $ sudo service polysync-core-manager start
  4. Start the dynamic driver process

Starting the node manually on the command line

To start a dynamic driver node on the command line, the node must first be defined in the SDF using the Configurator application. The supported sensor articles have instructions on how to define a dynamic driver node that is associated with each supported sensor.

Each node defined in the Configurator has a unique node ID which points to the nodes configuration. This article explains how to find the node ID.

Command line flags and usage

Once the node ID is known (substitute for X), the dynamic driver node for the supported sensor can be started with the base command:

$ polysync-core-dynamic-driver -n X

Each sensor supports an array of command line arguments. To see a full list of command line arguments, pass the -h help flag:

$ polysync-core-dynamic-driver -n X -h  |  less

There’s a lot of output so we recommend you pipe the output to less, but it’s not required.

Flag Required Description Arguments
-h No Show the help message N/A
-o No Reserved N/A
-w No Disable the hardware interface(s), allowing the node to run without hardware connected - also known as replay mode N/A
-r <N> No SDF runtime configuration key that specifies the domain to operated under, the default domain is used otherwise Runtime configuration key, [0-65536]
-n <N> Yes SDF node configuration identifier for the node SDF node ID from the Configurator, [0-65536]
-i <pal.so> No Use provided PAL interface file instead of what is stored in the SDF Path to the dyanmic driver interface PAL shared object library
-e No export a JSON support string describing the interface, used by the SDF configuration tool N/A
-u No Allow updates to the SDF configuration during the normal runtime if needed (does not exit) N/A
-p <file.plog> No Use provided logfile in Record and Replay operations instead of the default File path to a PolySync plog logfile
-s <psync.sdf> No Use provided SDF instead of the default File path to an SDF file
-U No Update the node SDF configuration and exit N/A
-O No check the node SDF configuration for required updates and exit option (returns exit status zero if no change required) N/A
-d No enable additional debugging output in the interface N/A
DTC codes and common fixes
DTC value DTC name Fault description Notes
304 DTC_NOINTERFACE Interface not available Activated when the sensor is not reachable at the serial port set in the Configurator; activated when the sensor becomes unreachable during runtime

Troubleshooting

SainSmart gets an active fault - dtc_code: 304 error on startup.

Create the file /etc/udev/rules.d/51-sainsmart-usb.rules

Add the copy the following lines to the file.

# udev rules to allow write access to all users
# for Sainsmart USB devices
SUBSYSTEM=="usb", ATTR{idVendor}=="0416", MODE="0666"

Useful SainSmart Resources

Sainsmart 16 Channel Controller