has someone experience with long CAN bus?

General discussion on mikroC.
Author
Message
picdog
Posts: 390
Joined: 28 Feb 2006 09:32

has someone experience with long CAN bus?

#1 Post by picdog » 20 Aug 2006 14:59

Hello all guys on the forum,

I would to know if someone has experience with mikroC CAN library and very long real busses.

I am going to build two devices for work on a CAN bus using mikroC CAN library; devices are based on 18F4680 and the MCP 2551 CAN adapter, on a bus long about 700 meters - 1 km, using a shielded twisted pair (in fact it is a FTP Cat 5 cable, which contains 4 tw. pairs, two of them used as CAN bus and as power supply, and the other as spare).

The bus is very long and is not "circle", it is a straight line along a field - I need to activate some actuator for water and read the state of them via this bus.

I would know if someone has before tried something similar on a so long bus, I think to use a 2x1mmq twisted pair unshielded if FTP pairs are too thin for this distance.

I know that there are more than one mode of operation, I am interested in the low-speed, "fault tolerant" mode and ask if there are special settings to do this (I read that the example provided with mC works in "high speed mode" at 500 Kbps but I read it is not so direct to switch the baud rate?).

In this case, the termination resistors are always between the two wires? (and one at each end of the bus). For me the speed is not a concern because I need only few bytes sometimes. I read that the maximum length is calculated considering that there should be at max 1 bit delay (for the collision detection system to work properly) on the length of the bus and that is necessary considering that speed of light along a line is slight lesser than in vacuum. However there is a lower limit to the baud rate and so a upper limit in the length of the bus (1000 m has been reached by someone without problem, just using enough low-resistance cable).

Thank you in advance for considering my request; I am happy to share this experience even because then I will switch this project to mikroC for dsPIC where CAN is less used (but available I think on a lot of 30F).

Have a nice day! :)

Picdog
... a proud user of MikroElektronica EasyPic3, EasyPic4, BigPic4, MikroC for PIC, EasydsPIC2, dsPIC-Pro2, LV24-33 and MikroC for dsPIC :)

piort
Posts: 1379
Joined: 28 Dec 2005 16:42
Location: Laval,Québec,Canada,Earth... :-)
Contact:

#2 Post by piort » 20 Aug 2006 19:26

hi Picdog,

i dont know about CAN bus with pic, but in the PLC industrie we use something VERY similar (DeviceNet is base on CAN bus protocole)... For long run, we put a amplification relay at every 300 M . In the same time, this station filter the line for parasite so we can run communication at 115K with out prob. So i suggest to you to reboost your signal at every 300M and put few small value condensator to filter the line... At 1Km long, wire have the tendensius to catch every electromagnetic chit in the air :)

hope that will hlp you

happy coding :-)

LGR
Posts: 3204
Joined: 23 Sep 2004 20:07

#3 Post by LGR » 20 Aug 2006 20:00

The Bosch CAN definition allows for some fairly high (IIRC ~ 40V) voltages, but the MCP2551 transciever only operates between 0 and 5 volts. I could never get a good answer as to what the distance limits were with those, but it was a baud/distance curve; i.e. you can go further if you're willing to go slower.

I don't know about suppliers of high-performance transcievers, but I'd be curious to learn.
If you know what you're doing, you're not learning anything.

picdog
Posts: 390
Joined: 28 Feb 2006 09:32

#4 Post by picdog » 20 Aug 2006 22:42

Hello Piort and LGR,
thank you for your advices, I will try and we will see. 8) I read that there are some settings when init the library and there are a couple (two I remember) of registers to set in accordance to which kind of operation is wanted. I will start with a short (some dozens meters) bus and will go further; I don't absolutely need a big speed as I have only to send a few bytes sometimes, only I need that this is reliably of course! (in addition of low level anticollision and ACK system of the CAN bus, I will send at application level some packet to acknowledge a command, just to be sure :o
I will update you about the tests.
Best regards, picdog
... a proud user of MikroElektronica EasyPic3, EasyPic4, BigPic4, MikroC for PIC, EasydsPIC2, dsPIC-Pro2, LV24-33 and MikroC for dsPIC :)

alex.forencich
Posts: 56
Joined: 11 Jun 2006 03:49
Location: Lake Oswego, Oregon
Contact:

#5 Post by alex.forencich » 20 Aug 2006 23:52

Another thing to consider is the voltage drop across the length of the cable. If you put 5v in one end of the line, you will NOT get 5v out the other end. Why do long-distance transmission lines carry power in excess of a million volts? A drop of 500 - 1000 volts over hundreds of miles is negligible if the initial voltage is 1,000,000 volts. You should put at least twice as much voltage as you will need in the power wire, then regulate it down at the destination.

picdog
Posts: 390
Joined: 28 Feb 2006 09:32

#6 Post by picdog » 21 Aug 2006 00:10

Hello Alex,
thank you for the advice, I know that they use very high voltages to minimize currents and so the resistive dropout. I mean you are referring to the power line I have to pose along with the CAN bus. It is true that I will have some hundreds ohms of resistance if I use a twisted pair I find in the FTP cables. So feeding directly 5 Vcc becomes impratical because I have to drain some dozens of mA and the dropout is too much. I will use a +25 or +30 Vcc power supply on the power line, and at each node a good filter done with VK200 and bypass capacitors and a LM2575-5.0 to step down with good efficiency to 5 Vcc to power the PIC and the MCP. This seem rather simple to obtain an the currents involved are very small.
For the interferences I will put some ferrite beads every dozen meters only on the power line. What do you think? Best regards, picdog
... a proud user of MikroElektronica EasyPic3, EasyPic4, BigPic4, MikroC for PIC, EasydsPIC2, dsPIC-Pro2, LV24-33 and MikroC for dsPIC :)

LGR
Posts: 3204
Joined: 23 Sep 2004 20:07

#7 Post by LGR » 21 Aug 2006 04:42

If you don't need high data rates, you might find RS-485 easier to work with, and inexpensive RS-485 drivers can go > 1 km. CAN has it's advantages, but it's a lot of work and learning curve to set up, and my understanding is that even at low baud rates, it can't go as far as RS-485.
If you know what you're doing, you're not learning anything.

picdog
Posts: 390
Joined: 28 Feb 2006 09:32

#8 Post by picdog » 21 Aug 2006 07:26

great! thank LGR, I believed an LTC485 able to cover only 300m, it is possible to push it more? or there are other transceivers that use higher voltage. I will do a quick search. I will try both, the simpler 485 and the more exotic CAN. On dsPIC side it will be nice because of the 2 Uart and the Can module just embedded.
... a proud user of MikroElektronica EasyPic3, EasyPic4, BigPic4, MikroC for PIC, EasydsPIC2, dsPIC-Pro2, LV24-33 and MikroC for dsPIC :)

LGR
Posts: 3204
Joined: 23 Sep 2004 20:07

#9 Post by LGR » 21 Aug 2006 14:57

I may be confusing things. I know that certain RS-422/485 devices that I've worked with before were capable of > 1 km, but I don't know what drivers they used. The cheap chips may be more limited. But from memory, the CAN drivers can't even do 300m. Again, this is all from memory, and I might be wrong.
If you know what you're doing, you're not learning anything.

picdog
Posts: 390
Joined: 28 Feb 2006 09:32

#10 Post by picdog » 21 Aug 2006 18:53

Hello LGR,
I have just received this afternoon some 18F4680 TQFP and some MCP2551 (also 2 x MCP2510 just to try also CAN over SPI with non-18Fxx8 chips), so I will give a try in the next days. As far as I read googling the Net about CAN, it is possible to reach longer distances but at obviously lesser speed of communications, also as long as you need that the maximum delay between the two end of the bus is long as a 1/baud rate (a bit) - considering also that on that wire the speed of the signal is lesser (I think about 0.6-0.7 times) than the speed of the light in vacuum.
:wink: let see what we can do with a 1,50 euro transceiver 8)
I will keep you informed!
picdog
... a proud user of MikroElektronica EasyPic3, EasyPic4, BigPic4, MikroC for PIC, EasydsPIC2, dsPIC-Pro2, LV24-33 and MikroC for dsPIC :)

Sparky1039
Posts: 1179
Joined: 24 Nov 2005 20:07
Location: Colorado, USA

#11 Post by Sparky1039 » 21 Aug 2006 22:43

CAN bus is capable of 500m and perhaps more, and as you guessed it very dependant upon data speed. Voltage drop is not a worry because the CAN bus driver is differential signaling. Low impedance driver output, high impedance receiver input. The deciding factor on long cable runs using any differential signaling is capacitance. The higher quality cable that exhibits the lowest capacitance per unit length will perform better over long lengths. Going RS-485 is also a good choice too, and I've seen 3Km cable runs work reliably at 60kbps. The down side of RS-485 is you need 2 pairs for bi-directional communication, vs CAN only needs one.
Another thing to think about with CAN is there is a lower limit on how slow you can go. Many of the driver chips have built in limits on the maximum "on" time a bit can be (Microchip's driver chip for one).

For the type of distances you're working with I usually take a long hard look at going wireless first, then use cable. Wireless is lower cost compared to 1km of high quality cable (plus the expence of laying it down). Have a look at Chipcon's RF products (i.e. CC1100 or CC2500 chips) for straight forward radio approaches for this kind of thing. It doesn't take too much to get a wireless link up and running with their parts.

LGR
Posts: 3204
Joined: 23 Sep 2004 20:07

#12 Post by LGR » 21 Aug 2006 22:52

Sparky1039 wrote: The down side of RS-485 is you need 2 pairs for bi-directional communication, vs CAN only needs one.
I've seen half-duplex RS-485.
If you know what you're doing, you're not learning anything.

picdog
Posts: 390
Joined: 28 Feb 2006 09:32

#13 Post by picdog » 21 Aug 2006 23:10

great job Sparky1039, thank you for your notes! :D
I cannot use wireless because ... I just used it on the same run :oops: I am very interested in the RF field and did some antennas (a 4 element coupled patch home-etched) with a honest 15 dbi gain, about 30° E-H @ -3db. I used a pair of simple D-Link access point devices configured as bridges with encryption and I cover 1,2 km with the minimum speed (about 1 mbps). Ping times between the two ends is about 3 ms. The cost of the system has been very low. The system is quite power-hungry even @ +10 dbm. I want to experiment with lesser power system and with this busses because in some scenarios I have the wires just posed (sometimes...20 pairs! Don't know if they are useful after some years...).
The nature of the experiment is not to use only two devices - they are actually for the first test - rather to use more devices along the bus (e.g. to check some illuminations of the field) e.g. two dozens devices along the bus. In this way using wireless is more expensive both for topology and for the cost of the single adapter.
I will try also RS485 because if the wiring are present, in the scenarios above, I have plenty of pairs and can use two of them; just to justify these posts on this forum (mikroC), even I am also interested in writing in mikroC some simple routines to achieve a sort of redundancy using both the two busses (some simple thing to begin, like receiving a command on a bus and expecting the same on the other ecc...). What do you think? I am very interested and pleased reading your posts.
Good evening, Picdog
... a proud user of MikroElektronica EasyPic3, EasyPic4, BigPic4, MikroC for PIC, EasydsPIC2, dsPIC-Pro2, LV24-33 and MikroC for dsPIC :)

Isaac
Posts: 121
Joined: 13 Jul 2006 23:03
Location: Sinaloa, Mexico

#14 Post by Isaac » 29 Nov 2007 18:50

:) Hello, question: Can the mikroe rs485 board used to drive rs422 conections??? I belive there is a chip from national that can do the RS232 convertion to rs422 LMS485, but i dont know if this can be done with the mikroe RS485 module. Thanks

LGR
Posts: 3204
Joined: 23 Sep 2004 20:07

#15 Post by LGR » 29 Nov 2007 19:56

Yes. RS-422 is simply 2-ended RS-485.
If you know what you're doing, you're not learning anything.

Post Reply

Return to “mikroC General”