Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

OMRON PLC 1

Status
Not open for further replies.

giwee

Electrical
Mar 19, 2014
2
0
0
US
I'm developing some ladder logic code to read a square wave duty cycle, and am having a problem with OMRON's counter implementation. My background is embedded C and HDL, and this is the first time I've developed in ladder logic. Basically the 8-bit counter isn't counting; apparently there is some kind of counter enable that I haven't found in the manual or any googling.

The counter part of the code is pretty simple:
M1 F0
-||---------(R)- <<< this line resets the counter when M1 is asserted.

F0
------------(C)- <<< this line is the counter which should be counting whenever the program is running (plus-one increment per "scan" of the ladder logic).

I'm not using the "Preset" value for the counter; instead I'm using four comparators to observe the counter and actuate independent events based on various values of the counter. M1 will be asserted at various times to reset the counter. The Preset value of the counter (which asserts F0 when the count exceeds it) is just left at the default 1, which I know isn't a problem because I've also set it at very large values just to check.

Both on the PLC, and the simulator software, show the counter incrementing once when the program starts, then nothing else. If I press start and stop repeatedly in the simulator, the counter slowly increments.

So far I've only come up against a blank wall; any help would be much appreciated.
 
Replies continue below

Recommended for you

You cannot use:
F0
------------(C)-

Counter's usually increment on the rising edge. From a PLC's point-of-view there is only ONE rising edge in the above case. Hence your one count per restart.

I suggest you look for a better input toggle. Most PLCs have a list of system functions you can tap. For instance the CLICK PLC, I'm writing a filter program on right now, has a _scan value you would run as:
_scan
--||--------(C)-

Which WOULD work in your case.
Other things offered would be _100ms, _1sec, _1min, _WDreset, etc. etc.

Or you could set up a timer of any time interval you want and have it toggle your counter and be reset by your logic or itself.

Keith Cress
kcress -
 
Status
Not open for further replies.
Back
Top