adccommunitymod (AutomationDirect) asked a question.

Interrupt Trigger question

Created Date: July 15,2019

Created By: xtal_01

**** This post has been imported from our legacy forum. Information in this post may be outdated and links contained in the post may no longer work.****

I am using the PLC as a totalizer for a flow meter. The meter has a 4-20 mA output and measures 0-250 gal/min I set up the PLC with a timer on a rung ... every second, it resets ... the done bit takes the reading (RX0) ... divides it by 60 and adds it to a register ... R10 = R10 + (RX0 / 60) ... and that works But I realized there is an error creeping in. If the timer is "done " just after the program has left the rung, then rather then 1 sec sampling it will be 1 sec plus the time it takes to got through the program to this point again .. not much of an error but still an error. I was reading the manual and there is something called "interrupt trigger " ... I have never used this. So, where do I even find it (don't see a place to access it) and how is the best way to use it? Do I just have it go to the math rung ever second or do I have it got to a sub routine and have that do the math (not sure does it go back tot he same place in the program after done ... not a specific place, could be anywhere when the interrupt goes off) or ??? Thanks ..... Mike


  • adccommunitymod (AutomationDirect)

    Created Date: July 15,2019

    Created by: xtal_01

    I am using the PLC as a totalizer for a flow meter. The meter has a 4-20 mA output and measures 0-250 gal/min

    I set up the PLC with a timer on a rung ... every second, it resets ... the done bit takes the reading (RX0) ... divides it by 60 and adds it to a register ... R10 = R10 + (RX0 / 60) ... and that works

    But I realized there is an error creeping in. If the timer is "done " just after the program has left the rung, then rather then 1 sec sampling it will be 1 sec plus the time it takes to got through the program to this point again .. not much of an error but still an error.

    I was reading the manual and there is something called "interrupt trigger " ... I have never used this.

    So, where do I even find it (don't see a place to access it) and how is the best way to use it? Do I just have it go to the math rung ever second or do I have it got to a sub routine and have that do the math (not sure does it go back tot he same place in the program after done ... not a specific place, could be anywhere when the interrupt goes off) or ???

    Thanks ..... Mike

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: July 15,2019

    Created by: BobO

    Don't reset the timer, subtract 1000 from .Acc.

  • adccommunitymod (AutomationDirect)

    Created Date: July 15,2019

    Created by: xtal_01

    I am assuming subtracting 1000 from the accumulated value of the timer is the same as resetting it to zero (1000 must be in milliseconds)?

    What will this do for me?

    Will I still not get the error of having to run through the program before it sees the time. I am thinking that if the timer trips (is done) just after the program reads that rung, and the program takes say .1 second run, then my "real " sample time will be 1.1 seconds rather then the 1 second I need ... a 10% error possible in every reading?

    Am I right or ??????

    Thanks ...... Mike

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: July 15,2019

    Created by: BobO

    I am assuming subtracting 1000 from the accumulated value of the timer is the same as resetting it to zero (1000 must be in milliseconds)?

    What will this do for me?

    Will I still not get the error of having to run through the program before it sees the time. I am thinking that if the timer trips (is done) just after the program reads that rung, and the program takes say .1 second run, then my "real " sample time will be 1.1 seconds rather then the 1 second I need ... a 10% error possible in every reading?

    Am I right or ??????

    Thanks ...... Mike

    That's (part of) the problem...depending on scan time it isn't always resetting from 1000 to 0, it could be 1001 or 1002, which introduces cumulative error. Subtracting 1000 forces the interval to average 1000, instead of something higher.

    There are other sources of error too, but that is a good starting place.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: July 15,2019

    Created by: xtal_01

    Got it! That makes sense!

    The only question I have is that if you subtract 1000 and there is say 1001 in the Acc .... and you have 1 left, won't after a time the register fill up? By the end of one day taking one sample a second that would be 86,400 in the Acc. That would be a huge number after a few weeks / months / years of running.

    I am looking the wrong way at using an interrupt triggered timer or ?????

    All this is new to me but I know the last PLC (built by someone else) did have an error in the flow totals .. client was not happy about this (and other problems with the panel, thus I am building a new one) so I am trying to get it right.

    Thanks again!

    Mike

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: July 15,2019

    Created by: BobO

    Got it! That makes sense!

    The only question I have is that if you subtract 1000 and there is say 1001 in the Acc .... and you have 1 left, won't after a time the register fill up? By the end of one day taking one sample a second that would be 86,400 in the Acc. That would be a huge number after a few weeks / months / years of running.

    I am looking the wrong way at using an interrupt triggered timer or ?????

    All this is new to me but I know the last PLC (built by someone else) did have an error in the flow totals .. client was not happy about this (and other problems with the panel, thus I am building a new one) so I am trying to get it right.

    Thanks again!

    Mike

    No. The .Done condition is .Acc>= 1000. If the new value in .Acc is 1 after subtracting 1000, the next interval will be 999.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: July 15,2019

    Created by: xtal_01

    Garry ... I see the same problem as the I had with the timer. I want something that is independent of the program. This way the time it takes to run through the program will have no affect on the actual time. If I am reading this correctly (and maybe I am not) does the entask still not depend on running through the program and executing when it comes around each time?

    Thanks ... Mike

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: July 15,2019

    Created by: xtal_01

    Bob0 ... so say I "trigger " my math operation with the done bit (1000). Are you saying by leaving say 1 or 2 in the Acc, that will shorten my next timing cycle by that much in the thought that the actual run time through the program will be about the same?

    It would be nice to the timer trigger (1000) but then use the actual valve in the Acc (it would have to continue accumulating and I don't think it does) to do the calculation.

    Mike

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: July 15,2019

    Created by: Garry

    Hi Mike,

    The ENTASK can be set up with an always on condition. It will execute every 1000mseconds. Make the task never yield.

    In the Project Browser you can modify the running order. Move the task to the top of the list above the $Main. I cannot find any information that will help determine the amount of error you can expect but this would probably be the best accuracy. You would have to do some experiments with both methods to determine the best solution.

    Regards,

    Garry

    Expand Post
10 of 40