PLC Simulator

luis

Member
Join Date
Oct 2003
Posts
3
Hi:

I'm a Computer Science student, and I'm trying to develop a PLC Simulator based on the explications in the www.plcs.net tutor's page, but I feel the need for a little more of orientation about PLC, since I don't know much about it.

Anyone can help me?

T.I.A.

Luis
 
Soooo...

What exactly do you want to know?

What is that you read in the Tutor (you did read it, didn't you?) that you don't understand?

If you have read it and there's something you don't understand, explain what you do understand and point out where you are losing it.
 
Thanks

Thanks for your reply

There are various things I don't get so clear:

1.- The PLC have timers internally (software timers), I believe that they have a limited number off them (same for the counters).
2.- In the tutorial they use Cxxx to name a counter or Txxx to a timer, this names refer to the IO/register the activated/deactived?
If this is true, then I can use the rrbb to refer to them also? (rrbb is rr=register bb=bit).

T.I.A.

Luis
 
Re: Thanks

luis said:
Thanks for your reply

There are various things I don't get so clear:

1.- The PLC have timers internally (software timers), I believe that they have a limited number off them (same for the counters).
Some have a limited nuimber, some don't. Often a timer isn't really a timer, but a type of counter. The PLC will have only one clock whose value changes constantly and independant of scan. When a timer isntruction is encountered, the value (or a peice of it) is compared to the last stored value, the accumulated value updated, the new clock time stored (plus the "extra" that didn't go into the accum), and the bits updated. In other PLCS, there may actually be seperate clocks running, which would be why you run out.

2.- In the tutorial they use Cxxx to name a counter or Txxx to a timer, this names refer to the IO/register the activated/deactived?

Keep in mind that the tutorial is based on no particular PLC. Some PLCs (such as AB) do use the 'T' or 'C' prefix to indicate a timer or counter, while others (such as GE and Modicon) do not. I find it a little easier to know that this register is being used for a timer because it has a 'T' in front, but that kind of data structure adds complications at times.

But to answer your question, these refer to INTERNAL MEMORY registers, not I/O registers. The PLC does not have a bunch of timers wired into its brain, any more than it has a bunch of relays with contacts. It was designed to replace all that junk. It's just computer memory now.


If this is true, then I can use the rrbb to refer to them also? (rrbb is rr=register bb=bit).

You are going to need more than just rrbb for a timer. At the very least, you'll need a register (word) to store the PRESET, another register (word) to store the ACCUMLATED, and at least one bit (for Done). But as I said, you might need at least a byte (half word) to keep track of the "how much time has passed since the timer block was last updated".



So you're trying to make "a PLC simulator", huh? That sounds like an overly ambitious project. How will this "simulator" differ from a Real PLC? How will you differentiate between the program that is the Simulator, and the program that the Simulator is running?
 
Here's an object model for a timer that is used by both Allen Bradley and GE. Each timer requires three 16-bit words. One of these words (ACC) contains the accumulated time while the timer is keeping track of time. Another word (PRE) contains the timer's preset value. The third word has the control/status bits for the timer and is also where accumulated time less than one timer 'tick' (REM) is stored. Control/status bits include 'Enabled', also called 'Timing', 'Done', and 'Reset'.

Let's consider a simple timer where there is no seperate 'Reset' bit (if 'Timing' is false, then 'Reset' is true). Each PLC scan, the timer algorithm works as follows:

If 'Timing' is false
-Set ACC to zero
-Set REM to zero
-Set 'Done' to false

If 'Timing' is true
-Take the elapsed time since last scan from the PLC's system clock and add it to REM
-Integer divide REM by the timer increment and add the result to ACC
-Put the remainder from the previous step in REM
-If ACC is greater than or equal to PRE, set 'Done' to true

Since you're writing the simulation, you can include whatever rules seem appropriate to you.
 
More Sim

To Steve:
you gave me a good sugestion (also because is more easy to program), I'll use the rules a seem appropriate to me.

Then I suggested my self that all those words (ACC & REM) will be keep inside the timer (do not use any register at all), so the timers my sim use will be PURE software timer. In programming lenguage these 'words' will be variables inside the timer structure.

Bellow I'll explain my sim.

To Allen:
I named my project "MicroPLC Sim" so I'm trying to simulate a microPLC (dah!).

The characteristics of the microPLC are as follow:
-16 inputs (related with register 0 bit 0-15)

-16 outputs(related with register 1 bit 0-15)
(so the next instruction will refer to input 5)

0005| |SW1
-------| |-------- SW1=a name the user assign to the instruction
| | 0005= register 00, bit 05

-32 Registers, 16 bit each (again registers 0 and 1 refer to I/O). So it will have 30 registers to use with other instructions (maths, move, etc).

-As you alredy know, it will use ladder diagram to program the PLC logic (a grid were you put the instructions, this will be the program the sim is runing).

-I'll try to use all the instructions that are on the tutorial.

-For timers I'll use rrbb notation (not Txxx) refering to the 'Done' bit, yyyy represents the number of ticks it will have to wait to set the 'Done'bit to true.
-Same as the timers, the counters will use rrbb to refer to the 'Done' bit and yyyy to the number of pulses we want to count before triggering the 'Done' bit; it will have internally the actual count of pulses (and compare it with yyyy to set the 'Done' bit).

Hope that this will clear up what I'm trying to do. So any recomendation/comment is welcome (I really need them!!).
 

Similar Topics

Showing a new guy basic programming and remembered the simulator here. But nothing happens when selecting the link. "Try our online PLC Simulator-...
Replies
25
Views
1,274
hi everyone please give me a solution to timeout error in delta plc simulator,i have a doubt about firewall and antivirus we r using.
Replies
2
Views
624
I just started to learn how to program PLCs. I was searching for the best simulator programs for learning how to code PLCs. The best one I could...
Replies
7
Views
2,895
I am trying to find PLC simulation software that will connect with KepServerEx, in order to learn and test an OPC UA solution. My Siemens trial...
Replies
1
Views
1,381
Replies
12
Views
3,746
Back
Top Bottom