Вы находитесь на странице: 1из 4

http://stackoverflow.

com/questions/9273581/what-is-a-flag-in-cx-programmer

What is a Flag in CX-Programmer?

During the reading of PLC documentation (Omron CP1L PLC and CX-
Programmer), there are some missing explanation. For example, it defines "Flag"
as "a bit that serves as an interface between in*struction", does that mean flag

is some sort of conditional Power Flow?

It gets more confusing with the terms "Differential Up/Down", "Carry Flag"?
What are flags and what do they do in the ladder logic? Are they a simple or
instruction to use or just a concept that I don't really need to program in ladder?

[EDITED]

Where to add / modify / delete the flag in an instruction? I open up the edit but flag
isn't there.

up vote 0
down
vote
favorite

plc
asked Feb 14 '12 at 8:11
edited Feb 20 '12 at 3:57
share|improve this question
KMC
3,921959129
add comment

1 Answer
active oldest votes
Ok, this is a better question.

PLCs are like any program - data is stored as different types. Think of flags as
interchangeable with the term "bit", "boolean", etc. They are very important.

If you have CX-Programmer, a much better place to get information is the Instruction
Reference (Help --> Instruction Reference --> yourPLC). These show time diagrams
of most of the instructions and how each of the parameters and flags operate.

For example, a basic timer (TIM) works by assigning it a value. If you use a BCD type
100ms timer and assign its SV (setpoint value) a BCD value of 300 then you have
created a timer with a 30 second limit (300 x 100ms). When the timer turns on it will
begin counting and the PV (process value) will start from 300 and count down. When
the value reaches zero the timer's flag turns ON to indicate that it has expired. If the
timer's number is, say T100 then you can use T100 as a contact in another rung of
logic - it will be true when the timer's execution conditions are TRUE and the timer
has expired.
up
Differentials (UP/DOWN) are special flags which are true for only one PLC scan (ie:
vote 1
they are true for one execution cycle only) when their input conditions change from
down
FALSE to TRUE (ie:OFF to ON) for UP differentials, and TRUE to FALSE (ie:ON to
vote
OFF) for DOWN differentials. You would use differentials in cases where you wanted
accept
to perform an action the moment a given condition changes.
ed
Flags can be used for almost anything. You can use them as general booleans in your
own programs, they can be parts of certain operations (ie: the CY (carry) flag is used
on arithmetic operations which result in a carry - other flags are used to indicate
overflows or div/0 errors, etc).

Edit again : (to answer extended question).

A basic timer's completion flag is a contact with its number. Say I have a 100ms timer,
T100, which turns on when contact 10.00 is on:

10.00 ___
|-----| |---------------------------------------|TIM|
|100|
| |
|#20|
|___|

Now, once 10.00 has been ON for two seconds, the timer will elapse and the flag for
timer 100, T100, will turn ON. If I had another rung where

| T100 W15.00
|-----| |-----------------------------------( )

Then work bit W15.00 would be turned on when the timer elapsed and would remain
on so long as the timer's input condition remained satisfied (ie: so long as 10.00
remains ON). Flags work in different ways for different things, however. Each
operation can use them in different ways.

The example from the Omron Instruction Reference (Help -> Instruction Reference ->
[select PLC]) looks like this :

answered Feb 16 '12 at 15:58

edited Feb 20 '12 at 14:39


share|improve this answer

J...
6,6031932
this is better. I will add more updates today. – J... Feb 17 '12 at 12:11
so basically a flag is a notification after each instruction finished running. It's just
conceptual and I am not responsible to program it? – KMC Feb 20 '12 at 1:27
No, a flag is a boolean whch can have almost infinite purposes. They can give you
information which you may need, can indicate state of things you may care about,
and are things you may pass to other parts of the program to dictate the flow of
logic. – J... Feb 20 '12 at 1:31
I would go so far as to say that the approach of trying to segregate things into
categories of "things I need to understand" and "things I don't need to understand"
is very dangerous for PLC programming. You must understand all of it - it is all
important and there is little room for ambiguity. PLCs are about pure logic - every
element has to be understood or you will run into problems! – J... Feb 20 '12 at
1:33
Again, I feel that examples are probably the way forward. Find somewhere where
you've run into a flag which doesn't quite make sense - we can do them each at a
time, if you like. – J... Feb 20 '12 at 1:39

Вам также может понравиться