Sunday, January 11, 2015

Build a Simple PLC using Arduino





This article about build a simple PLC for simple ladder diagram programming.
Ladder diagram for this simple PLC only: LD,LDI,AND,ANI,OR,ORI,OUT.

For CPU PLC using Arduino, and Input/Output Module use optocoupler and relay.

In PLC input module use Voltage 24VDC and PLC output module use relay.

This image about defference PLC and Simple PLC using Arduino:

build a simple PLC using Arduino

Hardware is needed to build a simple PLC:
1. Optocoupler TLP521
2. 5V Active Low Relay Board Module
3. Arduino UNO
4.Power Supply 24VDC
5. AC Adaptor with Output 9VDC for power to Arduino UNO
6. Switch / Push Button

Build 24VDC Input Modules:
1. Resistor 3.3K ohm
2. Resistor 10K ohm
3. Optocoupler TLP521

Build Input Module 24VDC for Simple PLC

Build Multi Input Modules 24VDC for Simple PLC

Build Relay Output Modules:
1. Resistor 560 ohm
2. Optocoupler TLP521
3. 5V Active Low Dual Channel Relay Board Module

Build Output Modules for Simple PLC

Build Relay Output Modules for Simple PLC

Hardware of Simple PLC using Arduino:

Diagram of Simple PLC using Arduino UNO

Hardware of Simple PLC using Arduino


How to Convert from PLC Ladder Diagram to Arduino Programming?
1. Check link about the duty cycle of PLC http://program-plc.blogspot.com/2010/02/scan-time-of-plc.html

There are 3 cycles of PLC:
- Input Processing
- Program Execution
- Output Processing

2. PLC ladder diagram for simple PLC using Arduino: 

PLC ladder diagram for simple PLC using Arduino

Example: PLC Ladder Diagram of Allen Bradley MicroLogix 1000

PLC Ladder Diagram of Allen Bradley MicroLogix 1000



3. PLC Ladder Diagram to Arduino Programming:
3.1. Input Processing:
use code: digitalRead(pin)
example: i00 = digitalRead(i00pin)

3.1. Program Execution:
PLC Ladder Diagram to Arduino Programming

3.3. Output Processing:
use code: digitalWrite(pin, value)
example: digitalWrite(o00pin, o00)

See the Results:

Download Project File:
1. PLC Ladder Diagram for MicroLogix 1000, click here
2. Arduino project file, click here

Arduino Code:
//Input/Output Pin
const int i00pin = 2; //Connect to Push Button
const int i01pin = 3; //Connect to Push Button
const int i02pin = 4; //Connect to Push Button
const int o00pin = 8; //Connect to Relay
const int o01pin = 9;//Connect to Relay

//Variable Name for Input/Output
boolean i00;
boolean i01;
boolean i02;
boolean o00;
boolean o01;

void setup() {
//Input Pin Setup
pinMode(i00pin, INPUT);
pinMode(i01pin, INPUT);
pinMode(i02pin, INPUT);

//Output Pin Setup
pinMode(o00pin, OUTPUT);
pinMode(o01pin, OUTPUT);
}

void loop()
{
//The duty cycle of PLC http://program-plc.blogspot.com/2010/02/scan-time-of-plc.html

//1.Input processing
i00 = digitalRead(i00pin);
i01 = digitalRead(i01pin);
i02 = digitalRead(i02pin);
o00 = digitalRead(o00pin);
o01 = digitalRead(o01pin);


//2.Program execution
//(I:0/0 OR O:0/0 ) AND NOT I:0/2
if ((i00 || o00) && !i02) {
o00 = true;
}else {
o00 = false;
}

//((O:0/0 AND I:0/1 ) OR O:0/1) AND NOT I:0/2
if (((o00 && i01) || o01) && !i02) {
o01 = true;
}else {
o01 = false;
}


//3.Output processing
digitalWrite(o00pin, o00);
digitalWrite(o01pin, o01);
}



Labels:





Newer Post Older Post Home

You may also like these ebook:

Get Free PLC eBook directly sent to your email,
and email subscription to program-plc.blogspot.com




We hate SPAM. Your information is never sold or shared with anyone.

Your Email Will Be 100% Secured !