Click here to Skip to main content
15,867,686 members
Articles / Desktop Programming / MFC
Article

A PLC simulator for WINDOWS

Rate me:
Please Sign up or sign in to vote.
4.56/5 (8 votes)
28 Sep 2008CPOL3 min read 106.1K   9.4K   39   28
A PLC simulator for WINDOWS

Download IO_SIMULATOR.zip - 46.06 KB

Download PLC.zip - 70.53 KB

Download resource.zip - 423 B

Introduction

Here is my first version of PC PLC simulator program. I dreamed about it for almost 15 years and now my dream come true. 


I’ll keep it as real as possible, if I have plenty of time. Any contribute is thankful.
Programmable Logic Controller was designed for most industrial application.
In order to control peripheral electronic devices such as Relay、Magnetic-contactors、solenoid valve…etc. It is intended to be an Interpreter.


The PLC programming language is knowen like ladder diagram symbol, Person who is familiar with electronic automatic control, should be familiar with it. PLC was controlled by input and ladder program after program computation PLC will control output, after all you can control electronic devices as you want.

Overview

PLC.exe is a Programmable Logic Controller simulator program. It is parsing ladder program, reading input and doing computation then doing output.


In the simulator environment, we don’t need I/O control card. I have wroten a program IO_SIMULATOR.exe to simulator input and output via file input.txt and output.txt the example ladder program also included in files for downloading
running screen snapshot


1. the PLC program running, click Sel Ladder file to load ladder program

pic1.jpg

2.Select ladder file

pic2.jpg

3.Click Run to start PLC

pic3.jpg

4.You can stop at any time as you want by click Stop

pic4.jpg

pic5.jpg

5.After PLC is running, you can use IO_SIMULATOR.exe to simulate input and watching output.

pic6.jpg

6.click X000 and X001 to switch on input X000,X001 then ouput Y000 will switch on by PLC.

pic7.jpg

7.click X006 to switch on input X006 after 5 sec output Y002 will switch on by PLC.

pic8.jpg

pic9.jpg

8.click X002 to switch on input X002 in order to switch off output Y000(in our ladder program Y000 with Counter were mutually exclusive) then click X005 on/off for 5 times then output Y002 will be switch on by PLC

pic9.jpg

You can enjoy editing ladder program to test PLC program in ordering to check whether it is enough or any suggest.

Improvements

I know it’s just simulator, but after improvI/O control module it can be real PLC for daily life. 

Technical details

I hope I can provide all of design document including Flow diagram,status diagram but it will take many time.


PLC program just implement a multimedia timer to computation timer object and parsing,computation working thread to computation ladder program to control output to proper status.


IO_SIMULATOR is just only an interface for control input and see output status via file,name input.txt and output.txt each byte indicate X000 to X007 and Y000 to Y007.

pic10.jpg

pic11.jpg
Ladder program was like the following,I don’t spend more time to do more desicriptions

pic12.jpg

Conclusion

Before complaining about that it was so ugly, I need to talk about my dream.
I want it to be a kind of application, and I planed to develop an Editor that it can edit ladder program and also can monitor computation status as soon as possible (I know in computer world what real time is , so I use the word as soon as possible),I also want to develop an GUI editor as for an Interface to control PLC, after all ,it can be applyed in many other environments as your application as possible.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Student NY
Taiwan Taiwan
8 years experience of automatic control with micro computer.
8 years experience of IT,SI,Software development(including 3 years of Project management).
I'm familiar with VB,C,C++,JAVA.
Operating System design and development is my little hobby.

Comments and Discussions

 
QuestionPLC programming using C++ Pin
Member 1097966629-Jul-14 18:11
Member 1097966629-Jul-14 18:11 
Generali need help with plc project i'm trying to do Pin
Matan Fihman5-Jan-13 6:57
Matan Fihman5-Jan-13 6:57 
Question|Do you have the source code for change plc ladder grahp to plc instruction text? Pin
joshua013727-Mar-12 15:00
joshua013727-Mar-12 15:00 
GeneralMy vote of 5 Pin
Gustavo Sanchez28-Oct-11 6:55
Gustavo Sanchez28-Oct-11 6:55 
GeneralMy vote of 5 Pin
KOZAK26-Apr-11 7:59
KOZAK26-Apr-11 7:59 
GeneralMy vote of 5 Pin
admin84200121-Nov-10 5:05
admin84200121-Nov-10 5:05 
GeneralMy vote of 5 Pin
itechnology5-Oct-10 17:44
itechnology5-Oct-10 17:44 
GeneralErrors in the destructor of the object cPLCCore Pin
RodrigueRoland15-Feb-10 23:54
RodrigueRoland15-Feb-10 23:54 
GeneralRe: Errors in the destructor of the object cPLCCore Pin
Jaker.Chen26-Feb-10 4:37
Jaker.Chen26-Feb-10 4:37 
GeneralHI, Jaker Pin
zhan82619-Nov-09 18:13
zhan82619-Nov-09 18:13 
GeneralRe: HI, Jaker Pin
Jaker.Chen21-Nov-09 3:44
Jaker.Chen21-Nov-09 3:44 
Generalhye jaker... Pin
khairuni27-Jul-09 21:26
khairuni27-Jul-09 21:26 
GeneralRe: hye jaker... Pin
Jaker.Chen29-Jul-09 4:45
Jaker.Chen29-Jul-09 4:45 
Questionwhat compiler do you use Pin
yamilesandoval16-Jul-09 14:54
yamilesandoval16-Jul-09 14:54 
AnswerRe: what compiler do you use Pin
Jaker.Chen20-Jul-09 21:28
Jaker.Chen20-Jul-09 21:28 
AnswerRe: what compiler do you use Pin
Jaker.Chen20-Jul-09 21:39
Jaker.Chen20-Jul-09 21:39 
Generalit's me again Pin
yamilesandoval16-Jul-09 14:48
yamilesandoval16-Jul-09 14:48 
GeneralHallo Jaker Pin
yamilesandoval16-Jul-09 14:45
yamilesandoval16-Jul-09 14:45 
GeneralRe: Hallo Jaker Pin
Jaker.Chen20-Jul-09 21:33
Jaker.Chen20-Jul-09 21:33 
GeneralVery good Pin
carl12489-Apr-09 0:47
carl12489-Apr-09 0:47 
GeneralRe: Very good Pin
Jaker.Chen22-Apr-09 19:26
Jaker.Chen22-Apr-09 19:26 
GeneralI can get it to Change Pin
briviere211-Feb-09 6:08
briviere211-Feb-09 6:08 
GeneralRe: I can get it to Change Pin
Jaker.Chen22-Feb-09 4:08
Jaker.Chen22-Feb-09 4:08 
Generalhello Pin
reqinutzu14-Dec-08 21:43
reqinutzu14-Dec-08 21:43 
GeneralRe: hello Pin
Jaker.Chen31-Dec-08 3:54
Jaker.Chen31-Dec-08 3:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.