Non-Blocking Delay on IP2 broken v03.02.17e Bug?

CAI_Support said:
Hi Ross,
 
Thanks for joining the discussion.   With new logic,
IPx is still the same as before with current state either 1 or 0.
IPx[y] will be true if 0V->5V pulse last longer than y milliseconds otherwise false
IPINVx[y] will be true if 5V->0V pulse last longer than y milliseconds otherwise false
 
IPTS  x  y will return in x a number indicate the length of time since last state change, either direction for input y.
 
So you want to make IPEDGE different from AZ1324 proposed to set what edge to record, you want to read back what was last edge change and since how long ago.
For example,
IPEDGE x y z
x is input ID can be 1 to 8
y can be VAR or RAM, stores the current state 0 or 1, with that you know the previous state must be negate of y value
z can be VAR or RAM stores the time since last state change.
 
You have done communication over the IO line, would these added command and data type help?
 
IP and IPINV returning true for a pulse sound useful. However, forgive me for being pedantic (it's a programmer trait!), but 0V->5V or 5V->0V is not a "pulse".
0V->5V->0V is a high pulse.    5V->0V->5V is a low pulse. Which way are you planning ipx/ipinvx to work? As "delayed edge timers" or "pulse detectors"?
 
When I proposed ipedge, I suggested an operand to determine rising/falling/either. I thought AZ1324 had agreed with my suggestion at the time, but like I said, I've not been following closely like I should.
 
Regardless of what you settle on, as long as it is CLEARLY described and functions AS described, I'm sure we'll manage!
 
IPx[] and IPINVx[] depend on that particular input.  It is not really for detecting pulse, rather is input state changed at least that much time.  If user need to  high going, he uses IPx[].  For that same TTL input, if he later needs to detect low going, like Tim asking this topics, he can also use IPINVx[] to detect the low going.  In this way, user don't have to set anything in the PLC code.
 
If detecting pulse, that will need to keep record of at least two state change time.  We plan in the future to use timer to do that.  Here at this topics, we want to see anything related to TTL input, what feature we can add to make it works better and more versatile.
 
So far we have implemented IPINVx[] data type and IPTS command.  We then noticed if we use IPEDGE to set which condition to record timestamp, IPTS may not get anything in certain situation due to IPEDGE instructed not recording timestamp in certain case.  If both of you can help clarify this, we would really appreciate it!
 
CAI_Support said:
IPx[] and IPINVx[] depend on that particular input.  It is not really for detecting pulse,
 
That's why I was clarifying it, because you used the term "pulse" in your previous post, and "pulse" is not the same as a level transition. These are non-trivial distinctions, getting the term right is critical to understanding how it will function and what it's supposed to do. The same argument probably applies to the confusion of the original term "non-blocking delay" which really never was a "delay"! (if you get my point??)
 
We then noticed if we use IPEDGE to set which condition to record timestamp, IPTS may not get anything in certain situation due to IPEDGE instructed not recording timestamp in certain case.  If both of you can help clarify this, we would really appreciate it!
 
Is this another limitation caused by RAM starvation? That you don't have sufficient space. How long is your current store for the timestamp? If it's in ticks, and ticks != milliseconds, let me just make a wild assumption and say it's 20 ticks/sec. If you currently use a 32-bit counter, you could break that into two 16-bit counters. That could store rising and falling edge timestamps seperately  and not overflow for almost an hour, without needing any more memory. Rather than overflowing, once the count gets to (2^16)-1, don't increment the timer any further, so you know it was "at least 54 minutes ago"
Or are there other more significant issues with this? (I would think that for long time delays, using CTS is far more practical anyway)
 
I believe a tick is around 25us unless they are scaling it.  But yes it should not be a problem to either max out the value or say it is only valid within a certain window as long as it is specified.
 
az1324 is correct, to track the input state change, inside WebControl, non-blocking delay using tick, at 41MHz clock speed, each tick is about 24-25us.  Each us is 1/1000 of ms.  Obviously, there are only 32bit number we can use to keep track these time length. That is max for non-blocking delay.  To convert this tick to larger scale number is doable, but a slow process, because the little processor does not have 32bit register to do that calculation, so it will be like take 100 ticks or more to do the conversion.  Like Ross already suggested, if user want to store the longer pulse, it is easier to use CTS.  Because the 32bit number can not store long time in ticks, using this timestamp to calculate pulse length may not always give correct answer.
 
Non-blocking delay might be confusing in certain situation. However, it does not stop PLC execution. not like normal DELAY.  So when TTL input bouncing up and down, WC firmware is tracking how long the input stay at that level without holding off other PLC command execution.  In actual TTL input connect to any real switch, it will have bounces. If setup WC as alarm, any bounce must trigger alarm. For other control, non-blocking delay is for de-bounce the TTL input noise.  For Tim's use, to measure a power on or off condition last long enough.
 
We do plan to implement using timer to measure the pulse width with very accurate result.  However, here is to discuss what to do to improve the 8 TTL inputs functions.  What do we want to know from IPEDGE, do we want to record only rising edge OR falling edge timestamp? If so, how to handle the IPTS may get half the timestamp problem.  Or IPEDGE is for reading status. What do you want to read?  We have IPINVx[] and IPTS implemented and testing in our lab. We want to decide what to do with IPEDGE command, so that we can ship that to Tim for testing.
 
Hi Tim,
 
IPx[y] is working fine. We added IPINVx[y] data type and IPTS command. They all working fine in our test.
However, we have different suggestions for how IPEDGE command would do, so that we could not get that going.
 
For your program, you just needt IPx[y] for detecting up going pulse longer than delay, and IPINVx[y] for high to low going pulse longer than y ms.
If you want to try that firmware, we can send you that one now.  I think that will meet your needs.
 
Thanks.
 
Yes. I PM'ed you but you must not have gotten it. It (IPINVx[y]) works perfectly. It was amazing to watch everything run as expected. Thank you to everyone who helped.
 
Thanks,
Tim
 
Thanks for confirming it, Tim. Anyone with bootloader wants to get this update, please contact us directly.
 
Basically, IPINVx[y] is opposite to IPx[y].
With IPx[y], if input state change longer than y ms, it will return the value, otherwise it will return false.  In this way, shorter than y ms pulses will be filter out.
With IPINVx[y], if input state change from high to low remain longer than y ms, it will return true, otherwise, it will be false.  Its result is similar to set input to inverse.
 
The added IPINVx data ID is for working together with IPx, so that helping detect both direction going pulse longer than y ms.
 
Back
Top