Best way to learn CAN Communication protocol

Thread Starter

Gajyamadake

Joined Oct 9, 2019
298
I want to learn about CAN communication protocol I found the main use of CAN is for automotive - within a car where multiple devices need to exchange information But neither i have a car nor any other device to do practical But still i want to learn about it.

I have learned about protocols like uart, i2c and spi by making a flow chart. Should i make a flow chart? I have another option that I should learn by looking at the sample code

It is better to walk on one way than walking on many paths to reach destination. Hopefully someone will help me to walk on the right track

Thank you very much for any advice. @JohnInTX
 

BobaMosfet

Joined Jul 1, 2009
1,012
Here's your best solution:

Understanding & Using the Controller Area Network Communication Protocol
Author(s): Marco Di Natale; Halbo Zeng; Paolo Giusto; Arkadeb Ghosal
ISBN-13: 978-1461403135
ISBN-10: 1461403138

Learn the way the rest of us did. Good luck.
 

JohnInTX

Joined Jun 26, 2012
3,987
Yeah.. I have to agree with @BobaMosfet on this one. CAN is a relatively complex subject that you can't learn from a forum. You need to read up on the whole thing before asking specific questions. A good way to start would be a book as noted and also just reading application notes and datasheets from vendors that make the stuff. Here are some resources from Microchip that I found helpful way back when. Your interaction with a CAN bus will not be centered on the low level bit transmission - that is handled by a CAN controller. Rather you need to understand the concepts of the CAN messaging, what a message is, how to configure a CAN controller (bit rates etc), how to set up message filters, how to send and receive messages with the CAN controller and how to manage errors.. You also have to understand the physical layer that is implemented with a separate driver IC.

You won't be bit-banging this one.

The PDFs with numbers refer to Microchip Application Nodes - all concise and well written. can2spec.pdf is the 2.0 Spec from Bosch. There are newer versions of most of this available around but it's a starting place. After all of that, read a datasheet for a uC with CAN built in like PIC18F4685 or a datasheet for a Stand Alone CAN controller like the MCP2515 and see how to interface your code to the CAN controller registers. You won't get this in a day or a week.

There also is some discussion of CAN right here on AAC:
https://forum.allaboutcircuits.com/threads/can-bus-specification.166232/


It's a big subject: start by reading, reading, reading. I learned it by reading these and similar stuff. Maybe you can too.
Good luck!
 

Attachments

Last edited:

John P

Joined Oct 14, 2008
1,796
CAN is great, and it appears reasonably simple at first. Data transmitted on two lines, a one is sent when the two lines are at the same voltage, a zero when one line is higher--not difficult to follow. But then you get into the protocol that's used, how data frames are constructed, and you start to be thankful that there are specialized chips out there that do all the interfacing for you. Using CAN is not the same as communicating via a UART! I looked at the data sheet for a PIC processor with a built-in CAN controller, and the number of registers involved with handling communication was really daunting. I wouldn't want to deal with it unless the software is a pre-written module, or the whole thing is dealt with by an external chip. I'd try to avoid any need to understand the entire operation.

And Gajyamadake, I don't want to sound negative here, but you're the guy who was having trouble understanding how to operate a 4x4 keypad, despite several people trying to explain it to you. You'll do best if you don't try to learn the most complicated things before you're ready for them.
 

Thread Starter

Gajyamadake

Joined Oct 9, 2019
298
And Gajyamadake, I don't want to sound negative here, but you're the guy who was having trouble understanding how to operate a 4x4 keypad, despite several people trying to explain it to you. You'll do best if you don't try to learn the most complicated things before you're ready for them.
Thank you so much for your explanations.

The title of my thread shows that I just wanted to know how we can learn CAN in a easy and simpler way. I understand that it will take a long time to understand CAN. I just started to learn basic first.

I do not want to leave any of my threads incomplete I am a bit late but still i keep working. I am also working on the Matrix keypad but I did not get much time, so I did not give 100% on it. But i have learned how to interface LCD to 4 bit.

Right now I will only focus on only two threads Keypad and CAN until I finish them
 

Thread Starter

Gajyamadake

Joined Oct 9, 2019
298
It's a big subject: start by reading, reading, reading. I learned it by reading these and similar stuff. Maybe you can too.
Good luck!
I have a question, pic18f4685 has inbuilt CAN. If I have two pic18f4685 and if I want to send data from one pic18f4685 to the other pic18f4685 via CAN, can I do this directly or do I need transceiver IC?

This is just a question that came to my mind that if this can happen, if not why not
 

JohnInTX

Joined Jun 26, 2012
3,987
You still need the transceiver. The PIC outputs are single ended TX out and RX in. The transceiver combines these into the differential CANH and CANL signals for the CAN bus as well as providing necessary feedback of the bus state (on the RX line) when transmitting. Monitoring the bus state is required for message arbitration. The CAN controller won't work properly without it.
 
Last edited:
Top