Logging on an event


ispyisail

Recommended Posts

Hi

I need to log on and event

I have followed the instruction for "Logging on an event"

if (MyChannel[0] > 3)
   beginexport(MyExport)
endif

This works execpt:

In my PLC I have a bit that turns on to log, but the problem is that while the bit is turned on it keeps logging

Is there a one shot option?

Is there a hand shake option?

Do you have some example code!

Thanks

Link to comment
Share on other sites

With your if() statement:

if (MyChannel[0] > 3)

it will log whenever MyChannel is > 3. If however, you want to log once, at the time when MyChannel transitions from <= 3 to > 3, then you want to expand your if() and use the [1] subsetting, which returns the next to most recent reading:

if ((MyChannel[0] &gt; 3) &amp;&amp; (MyChannel[1] &lt;= 3))

So, with this it will log once every time MyChannel changes from <= 3 to > 3. Note that there is no hysterisis for this, which is fine when you are using a bit like you are, but may cause rapid logging if you have an analog sitting at about 3. Usually you'd do hysterisis by spreading the if parts, i.e. doing >3 and <= 2.5 or similar. This is how you would do an alarm fire vs reset condition. However, in this case you can't really get away with it. Instead, you'd do something like this:

if ((MyChannel[0] &gt; 3) &amp;&amp; (Max(MyChannel[1,10] &lt;= 3)))

What this says is if MyChannel goes above 3 and the previous 10 readings are <= 3, then log. You can increase the 10 to extend the hysterisis. This is more hysterisis in time, meaning the value must stay below 3 for 10 readings before the log can retrigger.

I'm not sure what you mean by hand shake option.

Link to comment
Share on other sites

Just brilliant

I wound have never thought of that.

Hand shake:

Allen Bradley use "hand shakes" between Panel view's and PLC's

A bit gets enabled in the "PLC", This bit is read by the "panel view" which inturn enables another bit which is read by the PLC to acknowledge the reading of the first bit.

Thanks

Link to comment
Share on other sites

That is certainly one type of handshake. To implement that, you'd just use the event again, similar to the logging actually. Lets say MyChannel is the input bit (0 or 1), and MyOut is the output handshake bit sent back to the PLC. In the event for MyChannel you'd put:

if (MyChannel[0]  &amp;&amp; !MyChannel[1])
   MyOut = 1
endif

Of course I don't know how you'd want to reset the bit. I suppose it should reset with the next read? If so, then you'd want to make it:

if (MyChannel[0]  &amp;&amp; !MyChannel[1])
   MyOut = 1
else
   if (MyOut[0])
	  MyOut = 0
   endif
endif

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.