Go Down

Topic: More than 127 Arduino working together (Read 1 time) previous topic - next topic

@Graynomad - letters are required to identify the instruction as multiple devices will be connected to an arduino - This will allow me to send data only for the devices that need to be activated without the need to send data for the rest

What if I use a daisy chain of arduinos - found this post and looks interesting
http://geodesicsphere.blogspot.com/2012/12/daisy-chaining-serial-connections.html


Any idea how many devices can be in the chain?

Graynomad

Quote
6750|M-200|S100|R255255255

As far as I can see you only have the letters M, S, R and | (vert bar) how do they help addressing multiple Arduinos?

Quote
Any idea how many devices can be in the chain?

As many as you like, there is no physical limit but you have to think about propagation delay because at best you will have a one-character delay for every Arduino. So if there are 100 nodes #100 will get the message 99 x byte-times later than #1. At 115200 that's approx 8.6mS later. That may or may not matter in your application.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

@Graynomad

the first numbers identify the arduino - the letters identify the device on the arduino so as per my example I can do the following
6750|M-200|S100|R255255255 or 6750|R255255255 or 6750|M-200|R255255255 or use any other pattern I wish

Currently not excluding to have a start of message indicator in worst case scenario

zoomkat

Quote
As far as I can see you only have the letters M, S, R and | (vert bar) how do they help addressing multiple Arduinos?


Simple setup using letters to determine the servo to receive the servo command.

Code: [Select]

//zoomkat 11-22-12 simple delimited ',' string parse
//from serial port input (via serial monitor)
//and print result out serial port
//multi servos added

String readString;
#include <Servo.h>
Servo myservoa, myservob, myservoc, myservod;  // create servo object to control a servo

void setup() {
  Serial.begin(9600);

  //myservoa.writeMicroseconds(1500); //set initial servo position if desired

  myservoa.attach(6);  //the pin for the servoa control
  myservob.attach(7);  //the pin for the servob control
  myservoc.attach(8);  //the pin for the servoc control
  myservod.attach(9);  //the pin for the servod control
  Serial.println("multi-servo-delimit-test-dual-input-11-22-12"); // so I can keep track of what is loaded
}

void loop() {

  //expect single strings like 700a, or 1500c, or 2000d,
  //or like 30c, or 90a, or 180d,
  //or combined like 30c,180b,70a,120d,

  if (Serial.available())  {
    char c = Serial.read();  //gets one byte from serial buffer
    if (c == ',') {
      if (readString.length() >1) {
        Serial.println(readString); //prints string to serial port out

        int n = readString.toInt();  //convert readString into a number

        // auto select appropriate value, copied from someone elses code.
        if(n >= 500)
        {
          Serial.print("writing Microseconds: ");
          Serial.println(n);
          if(readString.indexOf('a') >0) myservoa.writeMicroseconds(n);
          if(readString.indexOf('b') >0) myservob.writeMicroseconds(n);
          if(readString.indexOf('c') >0) myservoc.writeMicroseconds(n);
          if(readString.indexOf('d') >0) myservod.writeMicroseconds(n);
        }
        else
        {   
          Serial.print("writing Angle: ");
          Serial.println(n);
          if(readString.indexOf('a') >0) myservoa.write(n);
          if(readString.indexOf('b') >0) myservob.write(n);
          if(readString.indexOf('c') >0) myservoc.write(n);
          if(readString.indexOf('d') >0) myservod.write(n);
        }
         readString=""; //clears variable for new input
      }
    } 
    else {     
      readString += c; //makes the string readString
    }
  }
}


Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

Graynomad

Quote
the first numbers identify the arduino - the letters identify the device on the arduino
Ah, I get it.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

You can have a switching arduino between each two networks, it has a I2C interface on one side and a software or external hardware I2C on the other side. Each arduino would have a special address within it's network and each network would have an ID/address. Each normal arduino would send data with these two addresses, all arduino's on the same network would interpret it to see if the device address is its or not, if the network address is different, all arduinos on the network would ignore that data except the switch arduino which sends it to the other network or to another switch for another third network.

Go Up