giwee
Electrical
- Mar 19, 2014
- 2
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.
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.