Communication between multiple Controllino Mega's

Hello everyone,
I am using multiple Controllino's to controle an industry model with various machines.
An easy example for the problem would be the following:
In my case Controllino 1 controles different conveyor belt's and wants to tell Controllino 2, which can controle a crane, when a workpiece is ready to be picked up.
As there will be a lot of different occasions like that, I thought the easiest way to handle the problem would be to connect all Mega's via an ethernet switch.
But the ethernet library, I found in the reference, is for connecting to the internnet.
Does anyone have experience with this form of communication or advice?
Regards
BeefJerky

I don't know what a "Controllino Mega" is - presumably it is a version of an Arduino Mega? Can you post a link to its datasheet?

  • How many Megas do you want to connect together?
  • How far apart are they?
  • How much data needs to pass between them (bytes per second)?

For a small number and short distances perhaps a simple Serial connection would work?

For longer distances with a wired connection RS485 might be a good idea.

If a wireless solution is possible and if the distances are not great then maybe nRF24L01+ wireless modules would be suitable.

...R
Simple nRF24L01+ Tutorial

Thanks for your quick response.
The datasheet from the controllino is here.
I have to connect 4 of them, they are right next to eacht other and they need to send about 10 boolean variables and maybe a few characters between them, optimally every loop. I'm not quite sure how much data per second that would require.

The datasheet says it has an RS485 connection and AFAIK that can work as a BUS with them all connected to it. It is robust and reliable.

...R

Okay, thank you for your advices. I will post an update once I got a kind of solution.

Crosspost
http://forum.arduino.cc/index.php?topic=589707.0

Update:
Okay, so I got 2 controllinos connected using the Udp library.
So far, this has been the easiest solution for me and I wanted to share my simple example, since I haven't found one like this.
Controllino 1:

#include <SPI.h>         // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h>         // UDP library from: bjoern@cs.stanford.edu 12/30/2008


// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {  
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEF };
IPAddress ip(192, 168, 1, 178);

unsigned int localPort = 8888;      // local port to listen on

// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;

void setup() {
  // start the Ethernet and UDP:
  Ethernet.begin(mac,ip);
  Udp.begin(localPort);

  Serial.begin(9600);
}

void loop() {
  // if there's data available, read a packet
  int packetSize = Udp.parsePacket();
  if(packetSize)
  {
    Serial.print("Received packet of size ");
    Serial.println(packetSize);
    Serial.print("From ");
    Serial.println(Udp.remoteIP());
    Serial.print("Data:  ");
    Serial.println(Udp.read());
    Serial.println("#############################################");
  }
  delay(10);
  
  Udp.beginPacket("192.168.1.177", 8888);
  Serial.print(Udp.beginPacket("192.168.1.177", 8888));
  char x = 5;
  Udp.write(x);
  Udp.endPacket();
  
}

And Controllino 2:

#include <SPI.h>         // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h>         // UDP library from: bjoern@cs.stanford.edu 12/30/2008


// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {  
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 177);

unsigned int localPort = 8888;      // local port to listen on

// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;

void setup() {
  // start the Ethernet and UDP:
  Ethernet.begin(mac,ip);
  Udp.begin(localPort);

  Serial.begin(9600);
}

void loop() {
  // if there's data available, read a packet
  int packetSize = Udp.parsePacket();
  if(packetSize)
  {
    Serial.print("Received packet of size ");
    Serial.println(packetSize);
    Serial.print("From ");
    Serial.println(Udp.remoteIP());
    Serial.print("Data:  ");
    char z = Udp.read();
    if (z == 5) {
      Serial.println(z, DEC);
    }    
    Serial.println(z);
    Serial.println("#############################################");
    
    Udp.beginPacket("192.168.1.178", 8888);
    Udp.write(1); // response after receiving data
    Udp.endPacket();
    
  }
  delay(10);
  
}

Thanks again!
Joe