We've been using Microchip's 18F2580 and 18F4580 processors for most of our CAN projects. They are readily available and have the CAN protocol module already on board. Connect the processor to an Automotive CAN transceiver like the NXP PCA82C251 and you have a quick solution. I was forced into using CAN when we built a replacement PCM for REVOLT's Mazda 3 project and have become a convert. CAN is pretty easy to use, and seems to work quite well even in very noisy environments.
The biggest challenge of using CAN is getting all of the timings right for the bus speed you are using. There are a couple registers that have to be set just right. In Microchip this is the BRP (Baud Rate Prescaler), SYNC, PHSEG1 and PHSEG2, and PROPSEG. The latter values are summed to find out how many (scaled) clock cycles makes one bit. For some reason Microchip likes giving all of its equations backwards. The equations explain how to calculate the bus speed based on the register values. Most designers want the other way, they know the bus speed they want, and need to solve for the register values. Its a pain.
The good news is other people have suffered the same pain, and some of them wrote tools to help with the calculations. The best I've found for CAN so far is from Intrepid Control Systems. Their Microchip Controller Area Network (CAN) Bit Timing Calculator makes it easy. Give it the clock speed and CANbus speed and it will show you all of the possible BRP values. Then it will show you what values to fill in for the remaining registers for each possible BRP value.
The biggest challenge of using CAN is getting all of the timings right for the bus speed you are using. There are a couple registers that have to be set just right. In Microchip this is the BRP (Baud Rate Prescaler), SYNC, PHSEG1 and PHSEG2, and PROPSEG. The latter values are summed to find out how many (scaled) clock cycles makes one bit. For some reason Microchip likes giving all of its equations backwards. The equations explain how to calculate the bus speed based on the register values. Most designers want the other way, they know the bus speed they want, and need to solve for the register values. Its a pain.
The good news is other people have suffered the same pain, and some of them wrote tools to help with the calculations. The best I've found for CAN so far is from Intrepid Control Systems. Their Microchip Controller Area Network (CAN) Bit Timing Calculator makes it easy. Give it the clock speed and CANbus speed and it will show you all of the possible BRP values. Then it will show you what values to fill in for the remaining registers for each possible BRP value.
