24/9/2017 Build a Simple PLC using Arduino
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:
Hardware is needed to build a simple PLC:
[Link] 1/7
24/9/2017 Build a Simple PLC using Arduino
1. Optocoupler TLP521
2. 5V Active Low Relay Board Module
3. Arduino UNO
[Link] 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
[Link] 2/7
24/9/2017 Build a Simple PLC using Arduino
Build Relay Output Modules:
1. Resistor 560 ohm
2. Optocoupler TLP521
3. 5V Active Low Dual Channel Relay Board Module
Hardware of Simple PLC using Arduino:
[Link] 3/7
24/9/2017 Build a Simple PLC using Arduino
How to Convert from PLC Ladder Diagram to Arduino
Programming?
1. Check link about the duty cycle of PLC [Link]
[Link]/2010/02/[Link]
There are 3 cycles of PLC:
- Input Processing
- Program Execution
- Output Processing
2. PLC ladder diagram for simple PLC using Arduino:
[Link] 4/7
24/9/2017 Build a Simple PLC using Arduino
Example: 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:
[Link] 5/7
24/9/2017 Build a Simple PLC using Arduino
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 [Link]
[Link]/2010/02/[Link]
//[Link] processing
i00 = digitalRead(i00pin);
i01 = digitalRead(i01pin);
i02 = digitalRead(i02pin);
o00 = digitalRead(o00pin);
o01 = digitalRead(o01pin);
[Link] 6/7
24/9/2017 Build a Simple PLC using Arduino
//[Link] 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;
}
//[Link] processing
digitalWrite(o00pin, o00);
digitalWrite(o01pin, o01);
}
[Link] 7/7