Connecting CAN Transceiver to Arduino Due - UMSATS/subsystems-tsat4 GitHub Wiki
The CAN transceiver used is: SN65HVD231QDRG4Q1
Pinouts:
Transceiver:
Note that there is a line instead of a dot at the top of our purchased transceivers.
Digikey Link: https://www.digikey.ca/product-detail/en/texas-instruments/SN65HVD231QDRG4Q1/296-24421-1-ND/2057479
Due:
Connections:
Tranceiver | Due |
---|---|
D | CAN_TX |
R | CAN_RX |
VCC | 3.3V |
GND | GND |
RS | GND |
Vref | No connection |
At least 1 pair of CANH and CANL must have 120 Ohms across it. Ideally 2 pairs (but not more). This is done to prevent signal reflection.
For each CANH (i.e. for multiple tranceivers), connect them to each other (e.g. on a bus).
For each CANL, connect them to each other.
Arduino Library
The Arduino library used is: https://github.com/collin80/due_can
To initialize the CAN node:
Can0.begin(CAN_BPS_250K);
To send test messages on that node, the following can be used:
void sendData()
{
CAN_FRAME outgoing;
outgoing.id = 0x401;
outgoing.extended = false;
outgoing.priority = 4; //0-15 lower is higher priority
outgoing.length = 8;
outgoing.data.value = 0x0102030405060708;
Can0.sendFrame(outgoing);
}
To receive test messages on that node, the "CAN_TrafficSnooper" example can be used.
Refer to the given examples for more details.
Additional CAN Bus
In addition, the Due has a second CAN bus that can be used, with the Rx pin being the DAC0 pin, and the Tx pin being the D53 pin.
In order to use it with the Arduino library, use the "Can1" object instead of "Can0" object.
References:
http://www.ti.com/lit/ds/symlink/sn65hvd231q.pdf https://www.boxelectronica.com/img/cms/due_1.png