Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

CAN networks, a step too far???

Status
Not open for further replies.

large_ghostman

Well-Known Member
Most Helpful Member
I have a bit of a thing about wanting to try out a CAN network, one of my projects would be good for CAN, but is it too much to try out for now complexity wise?
Anyone know how difficult it is to set up and use? I am currently reading all the Mchip app notes and looking at the lib they do. Anyone used there lib? does it work ok?
 
PIC's CAN module is very good. If you use isolating drivers, such as TI's ISO1050, it'll make very reliable connection in a small noisy place. Once you wrap your head over how CAN works, you'll find the module very easy to setup.

You can even connect to your car, although I've never tried this, so it's purely theoretical.
 
So you recommend that I use a driver and dont just use pics? The app notes are pretty good
 
So you recommend that I use a driver and dont just use pics?

You need PIC for the protocol etc, but you still need a transceiver for the electrical stuff (physical layer of CAN).
 
Kind of like a RS232 driver? I have downloaded the application maestro, as recommended in the app note. Would be a good system for the incubators, I am looking forward to documenting it.
Shame I am finding C hard to grasp :(.
 
The more I read about it the more I like it, looking at some of the code, its not too bad. seems easier and less confusing than USB. What speeds do you recommend to run it at? At the moment I am thinking 1meg bus speed, otherwise I am going to have to run the pics pretty fast, I might try a slower speed to start with and use the internal OSC. Hmm lots to think about. I like the idea of plugging mums new car into the network lol
 
Yes Ian I know and thank you! I do ask to be fair :D, anyway looks like the application maestro implements J1939, which seems to be for cars and that, now I discover there is also a high speed and low speed protocol. So first choice is which to use? then I can focus myself on that particular one. So far though I think J1939 would still be a good choice.
I am going to use a cut down version of the incubator with it for a try out. So each part will be a separate chip/node like the temp sensing and fan controllers and turners, and humidity etc. These will I assume talk to a master as well. But I will outline the plan in more detail later.
Looks like I am in School all next week tho.
 
Using Assembler with three 18F4585 and Xceivers SN65HVD251, I implemented a 3-node CAN network.

Word of caution: the way that some CAN-specific registers are described and how to access them is wrong / not complete and unclear in the datasheet. Rising a ticket to Microchip took time because the "guy who knows" was on vacation and his answer was not helping much.

Just by going as per the datasheet and against the common advice (use a working network to test your design) got it up and running from the first try. An LCD allowed to read messages sent / received.

In Spanish it rhymes well: más paciencia que ciencia.
 
Last edited:
I dont have a working network to try it out, so thats not an option :D, the LCD is a good idea
 
I dont have a working network to try it out, so thats not an option :D

Not sure now but I think that was the reason to implement three and not only two nodes.

First go for the simplest, loopback. Then no filters or maks, until you see it running. Chances and time to make it complex, you will have later.
 
Sounds interesting, how easy do you find it to add nodes? Would you use it again? I am going to try the C code version so no idea if that has errors in it, hopefully tho it shouldnt be to hard to find out
 
Sounds interesting, how easy do you find it to add nodes? Would you use it again?

Adding to what? With a working network I guess it would be easier (?). Kind of, "more of the same".

Using it again? I could if needed but in my case, most of what I do in electronics is just solving what I find challenging. Like text in the screen of a scope or implementing a digital filter with a 18F micro against all advice to buy it or the "Life" game on a 12864 GLCD.

Good luck.
 
Last edited:
If I had to link bunch of controllers together with extensibility option, I would, no doubts, go with CAN.

Lower speed gives you more reliability. High speed gives you more bandwidth to avoid collisions.
 
The way I am doing the incubator, I think makes it a good choice for can, at the moment its based on spi, also I am doing a complete redesign, in the spirit of trying out energy saving, I am going to use sleep modes etc, mainly so I can squeeze more time when its on the backup battery, but also because it interest's me.
 
Shame I am finding C hard to grasp :(.
I could write more "tutorials" in the Code Repository. Is there something that would interest you.. maybe how to divide C projects in multiple files, or something else (for beginners)?
 
I have done something in PIC micro controller - PIC 18F25K80, a CAN n/w @125 Kbps with MCP-2551 as CAN controller. The problem I had with the PIC was the CAN peripheral fried after some time, and I cant isolate why, else its very good. I also recommend to buy a microchip CAN bus analyzer tool for sniffing CAN packets.
 
The problem I had with the PIC was the CAN peripheral fried after some time, and I cant isolate why
I had the same problem. tom_usenet from the Microchip forum found the answer...

https://www.microchip.com/forums/tm.aspx?m=640252&high=

A common (possibly ground) connection between all transceivers is vital. Connect 0 Volts between all CAN transceivers as well as the two CAN bus lines. i.e. you need a minimum of three wires.

You might get away with only two CAN wires if you can guarantee that all transceivers share a common ground at all times (and are never unplugged from ground), but it is simpler and more reliable to use a third wire.

Don't be fooled (like I was) by mikroElectronica CAN products, which only provide two CAN line connections. Common ground really is needed to prevent transceiver burn-out.

Have had no further transceiver burn-out since learning this valuable lesson.
 
Last edited:
Maybe you forgot to put some resistance in the lines driving optoisolators..
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top