aspose file tools*
The moose likes Arduino and the fly likes Arduino In Action Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Arduino
Bookmark "Arduino In Action Question" Watch "Arduino In Action Question" New topic
Author

Arduino In Action Question

Gavin Ross
Greenhorn

Joined: Jun 06, 2007
Posts: 5
I have been developing projects with the Arduino for six months now and have progressed fairly far. My son and I built a autonomous robot that uses sonic distances sensors, infra red sensors, temperature sensors and microphones to navigate a maze. It is quite a good project for us to have learnt the basics. I am now wanting to progress onto having more than two Arduino communicating with each other and with a computer. What is the best way of doing this? Should I use the SPI bus or the I2C bus for the communication between the micro controllers?
Martin Evans
author
Greenhorn

Joined: Jun 18, 2013
Posts: 15
    
    7
Hi Gavin

it will depend on the specifics of your project. For example how far the Arduinos are apart there are a variety of communication protocols you could use including good old serial.
Gavin Ross
Greenhorn

Joined: Jun 06, 2007
Posts: 5
Thanks for the reply.

Would serial comms handle using a single channel/port to address multiple linked devices. I want to send a bitstream which inludes, as the first two bytes, the address of the micro controller that it refers to. Only if the address matches its internal address, will the micro controller respond else it will ignore the comms. Or would I need to have each micro controller action the serial event and either respond or send it to the next device in the chain on a different port?
Richard Tookey
Ranch Hand

Joined: Aug 27, 2012
Posts: 1067
    
  10

Gavin Ross wrote:
Would serial comms handle using a single channel/port to address multiple linked devices. I want to send a bitstream which inludes, as the first two bytes, the address of the micro controller that it refers to. Only if the address matches its internal address, will the micro controller respond else it will ignore the comms. Or would I need to have each micro controller action the serial event and either respond or send it to the next device in the chain on a different port?


I am implementing a ring system using serial ports. Each device in the ring has an ID (in my case a letter in the range 'a' to 'z') and commands are sent along the ring and either swallowed by the device when the ID matches or passed to the next device in the ring. Devices send results along the ring to the computer which itself is a device (ID == 'z'). I have a Java program on the PC which generates commands and displays the results. Currently I only have 5 devices in the ring (a PC as controller, a Raspberry Pi, a Mega 2560 and two devices based on PIC16F628A) but I hope to be able to expand this. I would like to have used I2C but the PIC16F628A chips do not have built-in I2C and I'm not keen on 'bit banging'. My protocol looks a bit like I2C with each record having the device ID as the first character and then the rest of the record depends on the device but terminated by a '\n'. I'm running this at 115200 Baud. Currently I don't have a checksum of any sort but I'm probably going to have to add one. I typically have about 10 commands of around 10 bytes per second which means I have plenty of spare capacity but I don't know how well this will scale; probably not well.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Arduino In Action Question