CAN Devices on Other Platforms
This is a guide on how to use our CAN devices on other platforms like PLCs and Raspberry Pi based control platforms.
Overview
Baud rate: 1 Mbps
Device data transmission interval: 10 ms (100 Hz)
This guide and the use of our sensors on other platforms is currently a beta project. Use at your own risk and feedback any issues or bugs to [email protected].
Wiring & Connections
We use a 5-pin connector on all our CAN devices. For most devices, the 4th pin is not in use.
The devices require a stable 24V DC power supply.
Wiring of each CAN line should be done with a single long line and short stubs to each sensor. Use a 120 resistor shortly after the last device.
PIN 1 (red): +24V
PIN 2 (yellow): CAN H
PIN 3 (white): CAN L
PIN 4 (green): Not Connected
PIN 5 (black): GroundSetup Process
Our design support 8 of the same device type per CAN bus (node ID 0-7). All devices are shipped with node ID 0, so in order to have multiple devices on a single CAN bus you need to assign each one a unique node ID (described in detail in Common Features). The easiest way to do this, is to connect the first device, give it node ID 1, then connect the next one - give it node ID 2 and so on until you have reached 7, and then the last one can keep node ID 0. If you have 8 density sensors, the result should look like this:
Density sensor @ node id 0
Density sensor @ node id 1
Density sensor @ node id 2
Density sensor @ node id 3
Density sensor @ node id 4
Density sensor @ node id 5
Density sensor @ node id 6
Density sensor @ node id 7
The same procedure goes for other devices.
CAN ID and Message Design
The CAN messages use the extended CAN ID format of 29 bits. It contains information about the message priority, sender node type, receiver node type, secondary node id and message type:
priority(Priority: 2 bits - 4 values) = 2/29 bitssenderNodeType(Sender Node Type: 8 bits - 256 values) = 10/29 bitsreceiverNodeType(Receiver Node Type: 8 bits - 256 values) = 18/29 bitssecondaryNodeId(Secondary Node Identifier: 3 bits - 8 values) = 21/29 bitsmsgType(Message Type: 8 bits - 256 values) = 29/29 bits
To extract these fields from your received CAN message, use the following bit shifting scheme:
To create a new CAN ID, the following function can be used:
The first byte in the the CAN message is a sub-index, which is used to distinguish between values of the same type, e.g. temperature reading 1, 2 and 3, all using the same message type. The way to extract the data correctly is shown below.
So let's say we want to process an incoming CAN message containing a density value from a density sensor, we could do something like:
Common Features
These features are common for all CAN devices, and can be implemented as general functions in your application.
Update Sensor Node ID
The firmware on our devices support up to 8 of the same node type on the same bus.
Pseudo-code for implementing a function that sends a new node ID to a density sensor is shown below:
Out of the box, your density sensor will have node ID 0. So to update it to 1, you would do updateDensitySensorId(0, 1); . To set it back to factory default (and make it compatible with FCS again) you would do updateDensitySensorId(1, 0); . Similarly, you can do this for other devices by changing the NODE_TYPE_DENSITY_SENSOR to your desired node type. The sender node type in this case is NODE_TYPE_PLC = 8.
Sending Data to a Device
A general function for sending bytes of data to your devices are shown below.
Using this function, you can create a specific function for sending specific data types, as shown below:
Device Specific Configuration and Data
Density / Temperature Sensor
The density/temperature sensor sends density on request (not at 10 ms interval) and constantly transmits temperature data. To start a new measurement, send a CAN message with the message type MSG_TYPE_START_MEASUREMENT , the data in the message can be left empty.
Calibration
To calibrate your density sensor, send the correct value from your EasyDense (or similar) as a float with the message type MSG_TYPE_CALIBRATION_CMD using the SG unit (important!). You can then listen for the MSG_TYPE_CALIBRATION_ACK message with acknowledgement types described below.
Node type: NODE_TYPE_DENSITY_SENSOR = 4
Message types
To device
MSG_TYPE_NODE_ID = 36MSG_TYPE_START_MEASUREMENT_CMD = 33MSG_TYPE_CALIBRATION_CMD = 28
From device
MSG_TYPE_DENSITY = 14MSG_TYPE_TEMPERATURE = 12MSG_TYPE_CALIBRATION_ACK = 29
Acknowledgement types
ACK_TYPE_NONE = 0ACK_TYPE_CALIBRATING = 1ACK_TYPE_OK = 2ACK_TYPE_ERROR = 3
Examples
Receive density value (SG)
Receive density sensor temperature value
Send new calibration to sensor @ node ID 3
Receive calibration ack (pseudo-code, extend as you like)
Pressure Sensor
The pressure sensor sends the measured pressure constantly.
Calibration
To calibrate your pressure sensor, send an empty CAN message with the message type MSG_TYPE_CALIBRATION_CMD , and listen for the MSG_TYPE_CALIBRATION_ACK message with acknowledgement types described below. It is important that the sensor is in atmospheric pressure at the time of calibration, since the calibration will read this as the zero pressure.
Node type: NODE_TYPE_PRESSURE_SENSOR = 3
Message types
To device
MSG_TYPE_NODE_ID = 36MSG_TYPE_CALIBRATION_CMD = 28
From device
MSG_TYPE_PRESSURE = 13MSG_TYPE_CALIBRATION_ACK = 29
Acknowledgement types
ACK_TYPE_NONE = 0ACK_TYPE_OK = 2ACK_TYPE_ERROR = 3
Examples
Receive pressure value (bar)
Send calibration command to sensor @ node ID 7 (will read atmospheric pressure and subtract it)
Receive calibration ack (pseudo-code, extend as you like)
Radar Level Sensor
The level sensor sends the measured distance in meters constantly. You can use this value to calculate the volume in your tank.
Node type: NODE_TYPE_LEVEL_SENSOR = 5
Message types
To device
MSG_TYPE_NODE_ID = 36MSG_TYPE_MIN = 41(Used to set the minimum measure distance of the sensor, usually not necessary to change from default (0.25 m))MSG_TYPE_MAX = 42(Used to set the maximum measure distance of the sensor; the sensor can give higher quality measurements if this value is specified. Default is 3.0 m)
From device
MSG_TYPE_LEVEL = 16
Examples
Send min/max distance value
Receive distance from level sensor (m)
Agitator
The agitator sends its measured rounds per minute (RPM) of the motor shaft constantly. It can be controlled by specifying the duty cycle/PWM from 0-100%.
Node type: NODE_TYPE_AGITATOR_ACTUATOR = 6
Message types
To device
MSG_TYPE_NODE_ID = 36MSG_TYPE_PWM = 27
From device
MSG_TYPE_RPM = 17
Examples
Send agitator PWM/duty cycle value (0-100%)
Receive rounds per minute value from agitator (RPM)
FCS I/O Module
The I/O Module offers the following interfaces:
2x PT1000 RTD measurements
4x 24V Relay ports
4x 24V CAN bus ports
DC Current measurements for all 8 ports
External AC relay
AC measurement for external AC relay
State feedback for ports and external relay
Node type: NODE_TYPE_FCS_IOM = 2
Message types
To device
MSG_TYPE_PORT_STATE = 21(Relay and CAN port states)MSG_TYPE_POLARITY_STATE = 22(Relay 4 voltage polarity state)MSG_TYPE_EXTERNAL_RELAY_STATE = 23(External relay state)MSG_TYPE_CAN_TERMINATION = 25(CAN bus 120 termination state)
From device
MSG_TYPE_TEMPERATURE = 12(PT1000 RTD measurements )MSG_TYPE_DCC = 18(DC Current measurements )MSG_TYPE_ACC = 19(AC Current measurements )MSG_TYPE_PORT_STATE = 21(Relay and CAN port states feedback)MSG_TYPE_POLARITY_STATE = 22(Relay 4 voltage polarity state feedback)MSG_TYPE_EXTERNAL_RELAY_STATE = 23(External relay state feedback)MSG_TYPE_CAN_TERMINATION = 25(CAN bus 120 termination state feedback)
Examples
Read temperature measurements
0
Temperature 1
1
Temperature 2
2
PCB Temperature
Read DC current measurements
0
FCS I/O Module total DC current
1
6 pin display output DC current
2
Relay 1 DC current
3
Relay 2 DC current
4
Relay 3 DC current
5
Relay 4 DC current
6
CAN 1 DC current
7
CAN 2 DC current
8
CAN 3 DC current
9
CAN 4 DC current
Read AC current measurements
Send port state command
Last updated
Was this helpful?

