Connect CAN Sensor

This article was written for version 2.0.9 of Core. Click here for the most recent version of the help center.

This tutorial will walk you through connecting a CAN RADAR sensor using a Delphi ESR 2.5 short range RADAR sensor.

1. CAN Channel Identifiers

Begin by finding the CAN Hardware And Circuit Identifiers of the physical CAN interface.

PolySync Core supports two types of CAN hardware devices, Kvaser and off-the-shelf. Kvaser uses linuxcan libraries to communicate with hardware, while most other off-the-shelf hardware uses SocketCAN libraries for communication.

1.1 Linuxcan

If you are using Kvaser hardware (compatible with linuxcan libraries and drivers), input the following into your terminal window to parse the hardware and circuit IDs:

$ /usr/src/linuxcan/canlib/examples/listChannels

The following example output should be visible:

Found 1 channel.
channel 0 = Kvaser Leaf Light v2, 73-30130-00685-0, (0)21718, 3.3.0.769

In the above example, the hardware identifier is printed near the end, in this case it’s 21718. The circuit identifier is an index for multi-channel CAN hardware interfaces. The (0) preceding the hardware identifier represents the circuit ID.

1.2 SocketCAN

If you are using SocketCAN hardware (compatible with SocketCAN libraries and drivers), you will only need to find the hardware identifier. Available devices can be queried from the system with ifconfig -a, and are typically represented as can0, can1, etc.

The following devices map to the listed values in PolySync:

| SocketCAN Channel | PolySync HW ID | | ————- | ————- | | can0 | 1 | | can1 | 2 | | can2 | 3 | | canN | N+1 |

Now it’s time to configure the sensor node’s IO Parameters in the SDF Configurator .

To start the SDF Configurator from the terminal, input the following:

$ polysync-core-sdf-configurator

2. Define node in the SDF

Next we need to define the CAN node in the SDF using the SDF Configurator. To add a new sensor node press the Add Sensor Node button in the bottom-left of the SDF Configurator.

Select the sensor from the drop-down list and give the node a name.

Once the node has been created in the SDF, the supported parameters for the node are automatically populated by the SDF Configurator with default values.

3. Parse the sensor ID

Now that you’ve properly configured the circuit ID and hardware ID for the node, you will need to obtain the sensor identifier using the PolySync Core dynamic driver interface.

The PolySync dynamic driver will use the ‘-g’ flag to query the sensor identifier. This can only be done after the hardware and circuit IDs are entered into the SDF Configurator.

$ polysync-core-dynamic-driver -n 1 -g

When invoking the dynamic driver, you will use the node ID that defines the sensor node. The node ID can be found in the upper right corner of the node configuration within the SDF Configurator (above).

The information is logged to the file ~/.local/share/polysync/polysync.log, and to standard output by default.

4. Update the SDF

In this final step, you will need to copy the decimal value of the sensor identifier─provided in the output of the dynamic driver node─to the SDF Configurator “Sensor 0 Identifier.”

SDFConfigurator

Now the PolySync Manager can be started.

$ polysync-core-manager -n

The node can also be manually started by referencing the SDF Configurator node ID within the polysync-core-dynamic-driver command. This is done by starting the PolySync manager in wall-clock mode (no arguments) and then running the polysync-core-dynamic-driver command with the -n flag. The -n flag tells the dynamic driver which node ID (found in the SDF Configurator) to reference.

$ polysync-core-manager
$ polysync-core-dynamic-driver -n 1

5. Data visualization

To visualize the sensor data, start PolySync Studio and launch the 3D view or trace plugins.

$ polysync-core-studio

Sensor data is globally available on the PolySync bus to any node that subscribes to the message type(s) output by the dynamic driver sensor node.

Conclusion

Congratulations! You have now successfully connected a CAN RADAR sensor and visualized its output using Studio.