Setting OPx on based on IPx

Clearly I still don't understand this function fully

You're not the only one. I'm actually more inclined to think there's still a bug there that needs squashed! I've done some further testing and get INCONSISTENT results, which software simply shouldn't be capable of :)
 
The original code Tim posted:
   tsteq ip1[2000] 1
   set op1 1
   tsteq ip1[10000] 0
   set op1 0
There is a problem.  That is caused by the delay function is depending on the time register associated with IPx.  That timer only register the time IPx changed, does not matter is to zero or to one.  Before this timer up, TSTxy will always got false, if a non-blocking delay is associated.  It is possible that during testing for 1, the IP changed state to 0, so that both testing will be false.
 
To avoid this problem, it may be better to add another checking without delay to make sure the checking is the proper portion of the logic.
start
tsteq ip1 1
callsub dlayon1
tsteq ip1 0
callsub dlayoff1
nop
end
 
dlayon1:
tsteq ip1[2000] 1
set op1 1
ret
 
dlayoff1:
tsteq ip1[10000] 0
set op1 0
ret
 
 
Hope this helps.
 
 
Hello and thank you for the reply and example. Unfortunantly the example does not work..at all. OP1 never turns on.
Question, is nop supposed to be in the beginning sequence? I tried it with and without but didn't seem to make a difference.
I am running a new board with firmware version 3.2.16b
 
Thanks,
Tim
 
edit: I am using a magnetic contact switch connected to IP1, is the above problem related to point bounce or should it matter?
 
Hi Tim,
 
NOP just provide an alternate path for the last TSTEQ, when test result is false, TSTEQ will skip next line of PLC code.
If the TSTEQ is your last test, please make sure to have NOP, so that it will skip NOP, rather than skip first line after START
 
If the above logic did not work, your IP1 change is probably very frequent, so that it does not keep more than 2 second on?
 
Understood about the coding. Thanks.
 
The set up is simple. IP1 is pulled high by a magnetic contact on a cabinet door. When door is open IP1 goes high. When door is closed IP1 goes low.
OP1 connected to a relay.
When IP1 goes High I want a delay of 2 seconds then turn on OP1. When IP1 goes low I want delay of 10 seconds.
 
With the above code I opened the door and left it open for 15 or so seconds and OP1 never turns on. Nothing happened either when I closed the door for 15 or so seconds either. Repeated numerous times. OP1 never turned on. 
 
Tim,
 
Are you sure you saw the OP1 never turn on?
I pasted the above code to my test WebControl board, hold IP1, after two seconds, OP1 is on, then after I released the IP1, OP1 still on for 10 seconds.
You can actually see the IP1 and OP1 change state on the web GUI, if you enable the polling in the general tab.  During normal running, you may want to uncheck polling to save resources.
 
You were right. I took a spare board, coded it and tested. both calls worked perfectly. I went back to the board in the application and it still didn't work.
 
Well, in order to keep my posted examples simple I used IP1 and OP1 for the examples. I knew that in reallity that it was OP5 not OP1 on my board but had forgotten that the cabinet contact was IP8 (not IP1). So the program was looking for a change in IP1 when it should have been IP8.
 
So basically yesterday and today it was operator error. I am sorry for waisting your time with my last post. 
 
Thank you so much for your help!
Tim
 
Back
Top