Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 7 months ago.
CAN communication between two controllers
Can anyone please tell me how CAN communication works between two different controllers and that needs to displayed in LCD?
1 Answer
6 years, 7 months ago.
Hi Meena,
There are several examples for CAN on the mbed site, you've probably done some searching already. Here's something I put together, which only focuses on the very basics.
https://os.mbed.com/users/WiredHome/notebook/can---getting-started/
The simple examples, like the one I referenced, show data being sent from one CAN port and received by another, but CAN is bidirectional, so indeed it is fully possible to exchange information, confirm it has been sent, and so on.
An important factor to consider is that CAN has support to deliver only 8 bytes of data at a time. So, if you wanted to send temperature across the network for a remote display, for example, you have many ways to do that:
- Send a single byte, which is a signed char, representing the temperature in degrees.
- Send a floating point value.
- Send a text string (generally not the best as it may quickly exceed 8-bytes of data)
If you need to send more than 8 bytes, consider the following:
- Break a big message down into 8-byte chunks, and send each message in turn.
- Break each message down into 7-byte chunks, and prepend the 7-bytes with a sequence number, to aid the receiver into correctly receiving the data.
Hopefully my page, and that of many others, provide you enough to continue your work.
You can also use the can ID to index message chunks to save space in the message body.
Example Long message ID=0xABXX Part 1: 0xAB00 and 8 bytes data. Part 2: 0xAB01 and 8 bytes data. ... Part 256: 0xABFF and 8 bytes data. You can set a CAN filter on ID ranges, or mask ID bytes.