I evaluated ARM mbed with CAN (LPC1768/MCP2561), but ARM Cortex-M is not suitable for the goal: expensive and over spec.
The following is the waveform of CAN over the network between two LPC1768:
And the physical network:
SocketCAN and SLCAN are interesting, so I evaluated them by re-building Raspbian to add SLCAN kernel module. But I noticed that SLCAN does not support mask/filtering on CAN controller, so I do not adopt them in this project.
CANopen is over-spec for this project. I will add a thin layer on top of CAN-bus instead of CANopen, because I want to use cheap and low-power 8bit MCUs such as PIC16F1 for CAN nodes.
I use this PIC board to evaluate CAN:
(The problem below has already been fixed in ver 0.1 release)
It seemed like I forgot to set CNF1, CNF2 and CNF3 to appropriate values to generate 125kbps baudrate.
Assuming that the oscillator runs at 8MHz and BRP(Buad Rate Prescaller) = 2,
TQ = 2*2/8MHz = 500ns ... Equation 5-2 in P38
16TQ corresponds to 125kHz
According to 5.3 in P 41,
SyncSeg = 1 TQ,
PropSeg = 2 TQ,
PS1 = 7TQ,
PS2 = 6TQ.
Total 16TQ.
CNF1 in P42
SJW: 01
BRP: 000001
CNF2
BTLMODE: 1
SAM: 1
PHSEG1: 110
PRSEG: 001
CNF3
SOF: 0
WAKFIL: 0
PHSEG2: 101
So the values of CNF1, CNF2 and CNF3 would be like this:
Register | Value |
---|---|
CNF1(2Ah) | 01000001 |
CNF2(29h) | 11110001 |
CNF3(28h) | 00000101 |
Voltage: CANH - CANL
1bit: 16 Time Quantum (TQ)
I have also got this cheap oscilloscope "PCB scope" in my original 3D-printed case:
The following is a screen shot from the oscilloscope in logic analyzer mode: