Main Site Documentation

Connecting devices (micro-controllers) on different distance


#1

Original problem was discussed here (http://www.tinyclr.com/forum/topic?id=11116&page=1), but I started a new thread to separate 2 different problems.

My question is which protocol (approach) should I use if connecting 2 micro-controllers (chips) (in my case Spider - Cerb40, Cobra II - Cerb40) on “long” distance.
My distance is around:
[ul]
a few inches
1m (3.28 feet)
2m (6.56 feet)
10m (32.81 feet)
30m ( 98.42 feet)
50m and more (164.04 feet) [/ul]

Let’s say we want 100% correction. I think that means some CRC. The discussion is meant to help me (and possible someone else) which protocol should I use (I2C, SPI, UART, RS232, RS485, CAN, … when connecting 2 devices.


#2

@ Makla - Better go for RS485


#3

Good question!!! the protocol should be adapted according to the distance. We can consider that i2c, spi and rs232 for short distances (<2m) while rs485 and can will be better for higher distance due to physical layer and control code (CRC checksum…) There’s other ones that you forget that are the ethernet or wifi/ blutoth connection.

The best protocol would be a protocol that adapt itself to environmental conditions (distance, SNR, QoS… ) as done on Software Define Radio. but due to phisical layer there’s some limitation to flexibility.

Why not choosing the one that is the more robust on long distance? (RS485, CAN and ethernet seem to be perfect candidate).


#4

Most interfaces like RS232/485 are just a HW layer, so you have to handle error correction on your own.
You could define a simple Protocoll like:
Length+RunningNumber+Data+CRC.
The Running Number would let you know if you missed a complete Telegram.
The receiver could then ask the sender to resend a specific telegram.
Over serial connection a EndOfTelegram info would make it easier to resync after some lost bytes.
If you choose ASCII format then this could be a Zero or line feed. You also could say that a short delay indicates that a new telegram will follow.

Using Ethernet it depends on the Layer you use: TCP includes error correction, UDP dosen’t.

b.t.w RS485 is specified for up to 500m, but you have to make sure to set termination resistors correctly.


#5

So, if I want to connect Spider and Cobra II with Cerb40 on a distance 2m and 20m I can use:
CAN - no costs, error correction
TCP - need to buy ENC28 for Cerb40 and switch, error correction
RS232 - need to buy 2 RS232 modules, without error correction.

I think the choice is easy. CAN over UTP cable is the way to go. Disagree?
I just have one question left. Should I use only 2 wires in UTP or should I connect 4 wires for TX line and second four for RX line?


#6

Or not: http://www.tinyclr.com/forum/topic?id=8402&page=1
:frowning: :frowning:
If I want to receive data. If I want to just send data to Spider/Cobra II, than the drivers are good.


#7

For longish distances, I believe you’d need external CAN transceivers on both ends?


#8

That’s not completely true, cost is limited but you need a can transceiver for each device like :
http://www.nxp.com/products/interface_and_connectivity/transceivers/can_transceivers/TJA1040T.html

Combine this with a 1 pair shielded cable and some capacitors and your up and running.


#9

You need to use 1 pair and ground the others (or at least 1)
We use 1 pair shielded cable for this, its thinner and cheaper.


#10

Depends… what needs to be communicated, a CAN message is “only” 8 bytes of data, the order sending / receiving messages can be different :

send 1 2 3 4 5 and receive 2 1 3 4 5, so sending a larger chunk of data is not that straightforward.


#11

Do I need this in every case? I can not just connect pins on microcontroller?

I didn’t have an idea, which connector should I use. I have microcontroller in an enclosure and can’t solder wire to something. I didn’t know if audio (RCA) connector could be used for this kind of purpose.


#12

A DB9 is a standard, see picture for wiring. (V+ is optional, you only need CAN Hi - CAN Low - GND)


#13

Understand. I will do as you suggest. I will look on the web how to connect things (chip, capacitors …) If you have some image showing that, I would appreciate if you share it.

I knew that. But this connector is so big, to transfer only 2 wires. I have GND on Cerb40 and Spider, so I don’t think I also need this signal. I will first try with RCA.

Thanks for everything.


#14

You need a SHARED GND to reliably know when a signal goes above the GND threshold.


#15

Can someone please help me:

http://si.farnell.com/jsp/search/browse.jsp?N=2028+203959&Ntk=gensearch&Ntt=CAN+transceiver&Ntx=mode+matchallpartial
http://si.farnell.com/jsp/search/browse.jsp?N=2028+203959+110165250&Ntk=gensearch&Ntt=CAN+transceiver&Ntx=mode+matchallpartial&No=0&getResults=true&appliedparametrics=true&locale=sl_SI&divisionLocale=sl_SI&catalogId=&skipManufacturer=false&skipParametricAttributeId=&prevNValues=2028+203959&mm=1001810||,&filtersHidden=false&appliedHidden=false&autoApply=false&originalQueryURL=%2Fjsp%2Fsearch%2Fbrowse.jsp%3FN%3D2028%2B203959%26Ntk%3Dgensearch%26Ntt%3DCAN%2Btransceiver%26Ntx%3Dmode%2Bmatchallpartial%26No%3D0%26getResults%3Dtrue%26appliedparametrics%3Dtrue%26locale%3Dsl_SI%26divisionLocale%3Dsl_SI%26catalogId%3D%26skipManufacturer%3Dfalse%26skipParametricAttributeId%3D%26prevNValues%3D2028%2B203959
http://si.farnell.com/jsp/search/browse.jsp?N=2028+203660&Ntk=gensearch&Ntt=CAN+transceiver&Ntx=mode+matchallpartial

There are to many of them and my knowledge about that is at this moment zero. The page is in Slovenian language (sorry about that, I tried USA page, but the products are not the same) but I think you will not have any problems.


#16

Thanks!


#17

I use the MCP2551

http://si.farnell.com/jsp/search/browse.jsp?N=2028+203654&Ntk=gensearch&Ntt=MCP2551&Ntx=mode+matchallpartial