PDA

View Full Version : CAN bus



Desterline
- 5th July 2004, 20:56
Hey guys and gals,

I'm looking at needing a multidrop network in a noisy enviroment and from what I read I think CAN (controller area network) would probably be a good fit.

I've found a ton of information about it -to much realy- but I haven't found many example projects. And searching the archives here is complicated by the 4 character min search requirement.

I was hoping for a "here's a schematic, heres some code" example that I could start working with.

Thanks,
-Denny

Desterline
- 8th July 2004, 17:25
Hmmm... Several days, no responses... Let's broaden the question.

Has anyone done any work with PBP and CAN?

Any feedback would be helpful.

Thanks,
-Denny

shawn665
- 13th July 2004, 15:15
I have used the MCP2515 can controller with the 16F877. I have a master LCD display head in a prototype aircraft that is fed signals from about four different PIC based sensor units throughout the aircraft. I used assembly interrupts to handle message reception for the most imortant messages, and poll for the rest. The assembly routine puts the data from the most important messages into a memory bank directly, and the polled data is placed into a buffer.

Being assembly, it's not the easiest to follow, but it certainly works well enough. Still interested?

Desterline
- 13th July 2004, 21:08
Hmm.... Starting to get pretty far from my hardware (18f248 w/internal can controller) so I'm not sure the code would be directly useful to me (besides, my assembly isn't exactly the best :-) But maybe a couple questions?

If I understand the CAN concept correctly, I put the data to be sent in the transmit buffers, set a couple flags (priority, message length) and the transfer is actualy a background proccess - no more cpu cycles. The recieving end is similar, reception actualy takes no cpu time, the data is placed into the recieve buffers (depending on the reception filters) then a buffer full interrupt is set.

Is that about right?

I'm sure I'll have more questions as I get into this, but it's a low priority at the moment.

Thanks,
-Denny

shawn665
- 13th July 2004, 21:18
You've got it! Just set the right bits, and the message goes out.

I think the MCP 2515 is pretty much the same as what's in your PIC, only there is no SPI interface to deal with. I haven't written any code for the 18 series yet, though.


Shawn