Arduino based PLC

Hello everyone,

I need to come up with a method to control a lift station and 3 conveyors.

Controls newbie here.

As my budget is tight I want to use an M-duino(arduino based plc) which is easy to wire and use.

Please take a look at all the things is have put together so far. Any advise would be very helpful.
Also If someone can help me program it I would be forever greatful.
:slight_smile:

Image from Original Post so we don't have to download it. See this Image Guide

...R

I just had a very quick look at this M-duino page

Is it programmed like an Arduino?

...R

Hi Robin2,

From what I read it seems like its the same way.
Below is the example code they have.

/*
Industrial Shields
www.industrialshields.com
march/2015

  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
 
  This example code is in the public domain.
 */
 
// NOTE: IMPORTANT ACTIVATE/DESACTIVATE APROPIATE INPUT/OUTPUT
// M-Duino 21 IOs have I0X, Q0X
// M-Duino 42 IOs have I0x + I1X, Q0X + Q1X
// M-Duino 58 IOs have I0x + I1X + I2X , Q0X + Q1X + Q2X

//Configuration Digital IN (24Vdc) INTERRUPT IN
int I06 = 3; //INTERRUPT #1
int I05 = 2; //INTERRUPT #0
int I16 = 19; //INTERRUPT #4
int I15 = 18; //INTERRUPT #5
int I26 = 21; //INTERRUPT #2
int I25 = 20; //INTERRUPT #3

//Configuration Digital IN (24Vdc)

int I04 = 26;    // select the Analog/PWM Digital IN
int I03 = 25;    // Digital IN
int I02 = 24;    // Digital IN
int I01 = 23;    // Digital IN
int I00 = 22;    // Digital IN
int I14 = 31;    // Digital IN
int I13 = 30;    // Digital IN
int I12 = 29;    // Digital IN
int I11 = 28;    // Digital IN
int I10 = 27;    // Digital IN
int I23 = 35;    // Digital IN
int I22 = 34;    // Digital IN
int I21 = 33;    // Digital IN
int I20 = 32;    // Digital IN

//Configuration Analog/PWM/Digital IN (0-10Vdc or 24Vdc)
int Q05 = 4;    // select the Analog/PWM Digital OUT
int Q06 = 5;    // select the Analog/PWM Digital OUT
int Q07 = 6;    // select the Analog/PWM Digital OUT
int Q15 = 8;    // select the Analog/PWM Digital OUT
int Q16 = 7;    // select the Analog/PWM Digital OUT
int Q17 = 9;    // select the Analog/PWM Digital OUT
int Q25 = 12;    // select the Analog/PWM Digital OUT
int Q26 = 13;    // select the Analog/PWM Digital OUT

//Configuration Digital OUT (24Vdc)
int Q00 = 36;    // Digital OUT
int Q01 = 37;    // Digital OUT
int Q02 = 38;    // Digital OUT
int Q03 = 39;    // Digital OUT
int Q04 = 40;    // Digital OUT
int Q10 = 41;    // Digital OUT
int Q11 = 42;    // Digital OUT
int Q12 = 43;    // Digital OUT
int Q13 = 44;    // Digital OUT
int Q14 = 45;    // Digital OUT
int Q20 = 46;    // Digital OUT
int Q21 = 47;    // Digital OUT
int Q22 = 48;    // Digital OUT
int Q23 = 49;    // Digital OUT

volatile int state = LOW;

////////////
// Ethernet
////////////
#include<EtherCard.h>

static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
uint8_t ntpServer[] = {128,138,141,172}; // time.nist.gov NTP server
byte ntpMyPort = 8888;
byte Ethernet::buffer[1000];   // tcp/ip send and receive buffer
////////////

// the setup routine runs once when you press reset:
void setup() {       

  //Configuration Analog/PWM/Digital OUT (0-10Vdc or 24Vdc)  
  pinMode(Q05, OUTPUT);  
  pinMode(Q06, OUTPUT);  
  pinMode(Q07, OUTPUT);  
  pinMode(Q15, OUTPUT);  
  pinMode(Q16, OUTPUT);  
  pinMode(Q17, OUTPUT);  
  pinMode(Q26, OUTPUT);  
  pinMode(Q25, OUTPUT);  
    
  //Configuration Digital IN (24Vdc)  
  pinMode(I00, INPUT);     
  pinMode(I01, INPUT);     
  pinMode(I02, INPUT);     
  pinMode(I03, INPUT);
  pinMode(I04, INPUT);  
  pinMode(I10, INPUT);     
  pinMode(I11, INPUT);     
  pinMode(I12, INPUT);     
  pinMode(I13, INPUT);     
  pinMode(I14, INPUT);     
  pinMode(I20, INPUT);
  pinMode(I21, INPUT);  
  pinMode(I22, INPUT);     
  pinMode(I23, INPUT); 

  pinMode(I05, INPUT);     
  pinMode(I06, INPUT);     
  pinMode(I15, INPUT);
  pinMode(I16, INPUT);  
  pinMode(I25, INPUT);     
  pinMode(I26, INPUT); 

    
  //Configuration Digital OUT (24Vdc)
  pinMode(Q00, OUTPUT);     
  pinMode(Q01, OUTPUT);     
  pinMode(Q02, OUTPUT);     
  pinMode(Q03, OUTPUT);
  pinMode(Q04, OUTPUT);
  pinMode(Q10, OUTPUT);     
  pinMode(Q11, OUTPUT);     
  pinMode(Q12, OUTPUT);     
  pinMode(Q13, OUTPUT);
  pinMode(Q14, OUTPUT);
  pinMode(Q20, OUTPUT);     
  pinMode(Q21, OUTPUT);     
  pinMode(Q22, OUTPUT);     
  pinMode(Q23, OUTPUT);

////////////
// Ethernet
////////////
  Serial.begin(57600);
  
  if (ether.begin(sizeof Ethernet::buffer, mymac, 53) == 0) 
    Serial.println( "Failed to access Ethernet controller");
    
  if (!ether.dhcpSetup()) {
    Serial.println("DHCP failed");
  }
  
  ether.printIp("My IP: ", ether.myip);
  ether.printIp("GW IP: ", ether.gwip);
  ether.printIp("DNS IP: ", ether.dnsip);  
  
  if (!ether.dnsLookup("www.industrialshields.com")) {
    Serial.println("DNS failed");
  }  
  
  ether.printIp("Lookup IP   : ", ether.hisip);
////////////   
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(Q00, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q01, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q02, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q03, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q04, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q05, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q06, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q07, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q10, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q11, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q12, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q13, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q14, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q15, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q16, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q17, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q20, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q21, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q22, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q23, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q25, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q26, HIGH);   // turn the LED on (HIGH is the voltage level)

  delay(1000);               // wait for a second
  digitalWrite(Q00, LOW);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q01, LOW);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q02, LOW);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q03, LOW);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q04, LOW);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q05, LOW);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q06, LOW);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q07, LOW);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q10, LOW);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q11, LOW);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q12, LOW);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q13, LOW);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q14, LOW);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q15, LOW);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q16, LOW);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q17, LOW);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q20, LOW);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q21, LOW);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q22, LOW);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q23, LOW);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q25, LOW);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(Q26, LOW);   // turn the LED on (HIGH is the voltage level)
  delay(1000);     // wait for a second

////////////
// Ethernet
////////////
  unsigned long rtime = getNtpTime();
  
  char tmp[30];
  sprintf(tmp,"Time: %ld\n",rtime);
  
  Serial.println(tmp);
////////////
}

unsigned long getNtpTime() {
  unsigned long timeFromNTP;
  const unsigned long seventy_years = 2208988800UL;
  uint8_t localPort = 12345;
  
  ether.ntpRequest(ntpServer, localPort);
  Serial.println("NTP request sent");
  while(true) {
    word length = ether.packetReceive();
    ether.packetLoop(length);
    if(length > 0 && ether.ntpProcessAnswer(&timeFromNTP,localPort)) {
      Serial.println("NTP reply received");
      return timeFromNTP - seventy_years;      
    }
  }
  return 0;
}

I would not use a device in a serious application that comes from a supplier who recommends code like that.

...R

Hi Robin,

I think you might be right. The only issue is I already placed an order for it :confused:

I am hoping someone software savy like you might be able to help.

If you want someone to write a program for you then you should ask in the Gigs and Collaborations section and be prepared to pay.

However I suspect that anyone writing a program would need to have one of the devices for testing. It looks like it is significantly different from an regular Arduino board.

To my mind the purpose of using a PLC is so that you can sue someone like Siemens if it does not work properly. And you can easily hire technicians who are familiar with branded PLC products.

The M-duino may be an excellent product, but how do you know? And do you want to be the guinea-pig?

...R

mac7988:
I need to come up with a method to control a lift station and 3 conveyors.

Controls newbie here.

Based on "Controls newbie here" I submit that your learning curve will be faster with a standard PLC and ladder logic than with the C++ on the Arduino. It's not just the hardware cost, you have to factor in the value of your time too.

A big plus of the PLC is having realtime status of the program in a graphical language and changes on-the-fly. You can get a Click PLC for $70 which might be all you need based on the image you provided.

YMMV