network of microcontrollers (SPI, I2C, CAN...)

I am working on a robot which will contain several microcontrollers, eg some for motor control, some for sensors and one "master". The communication wires may have to go near motors which is my main concern. I will be using AVRs.

SPI is nice and fast, AVRs support master/slave with hardware addressing, but I am not sure how well it would go with interference. I know that each bit is sampled more than once to detect noise.

I2C is good in that most AVRs have it in hardware and it is easy to connect lots of devices. I don't know how well it can handle noise though.

CAN is good in noisy environments and fast, but it will require a separate chip. I would prefer to keep the size small but if it is so much better then I guess I will use it.

That is what I know, but I don't have any practical experience. Which would you recommend? Does anyone have experience with communication near motors? The furthest distance the wires will go is around 1m.

Thanks for your help!

-Daniel

Reply to
Daniel Watman
Loading thread data ...
[snip]

Use CAN. Microchip do a nice SPI-connected CAN peripheral (the MCP2515), and we have great fun with the robustness properties of CAN...

SPI is okay over short distances (we use it for sensor module to network module communication in fingers, for example) but has *no* robustness properties.

CAN was designed for use in electrically noisy environments.

cheers, Rich.

Reply to
Rich Walker

CAN is more than an electrical specificaton. It includes packet collision detection and message priority at the hardware level. Motorola makes some nice micros with CAN on board, just needing an external driver chip. There are also stand-alone controllers as well.

formatting link
My micro of choice, the IsoPod, is based on the 56805 micro. It comes CAN capable.

Be wary of the limited capability of some of the devices out there. Compare them to the amount of traffic you anticipate generating. Some micros have more or less buffers than others. This is critical if you anticipate having a master generating requests for data. This will need more recieve buffers .

I have built up little mini can networks with 6 microcontrollers at once.

formatting link

Reply to
Blueeyedpop

If you are really into multi-processor communications, you need lots of physical handshaking and avoid anything that is self timed. I used PICs with no interrupt, and it does IR-RX, 16 speed motor control, handshaking, and multi-processor communications without any problem. My robot also does a little dance routine in background program that is running all at the same time! :-) Interference must be suppressed 100% or its no go with things like IR-RX. Data lines not affected by that much from noise so long as you fit some resistors to load the line to prevent it becoming sensitive to noise if your input is very high impedance. Some stuff I made for other people...

formatting link
J

Reply to
e7

I would strongly suggest using RS-485 with a simple serial protocol like ROBIN.

formatting link
RS-485 is cheap and easy.

-- D. Jay Newman

formatting link

Reply to
D. Jay Newman

[...]

I2C is rated for about 1 meter, if I recall, unless you use a bus extender, so I think your bus length is within its capability so that might not be a bad option. It's simple enough to use and works well.

You didn't mention RS485 which has been around for ages, works great, and has excellent noise immunity even over long distances (1000's of feet), think: industrial controls. Just use an inexpensive 8-pin transceiver chip and a UART on your AVR and that's really all you need to create a network.

You also don't have to reinvent the wheel with regard to a simple packet protocol - check out the ROBIN protocol:

formatting link
That link describes the protocol and also provides a sample implementation for my MAVRIC-II ATmega128 board, which includes the RS485 transceiver on-board. Does I2C and SPI, too :-)

At any rate, I used the ROBIN protocol on my rover here:

formatting link
The main controller, one of my MAVRIC-II boards, talks to the two dual h-bridges which control the motors using the ROBIN protocol. Works great. I plan to add more ROBIN nodes as I make enhancements and upgrades to the robot.

-Brian

Reply to
Brian Dean

Thanks for your replies.

I am leaning towards CAN, but considering RS-485 with ROBIN...

CAN is nice since it has hardware CRC and retransmission, so I can basically just send messages and ignore the details of what is happening. Looking at microchip's MCP2515 transciever and MCP2551 driver.

-Daniel

Reply to
Daniel Watman

Reply to
Blueeyedpop

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.