Author Topic: Reading counter present value  (Read 11182 times)

lloyd.maclean

  • Newbie
  • Posts: 7
    • View Profile
    • lloyd's page
Reading counter present value
« on: February 13, 2004, 01:09:55 PM »
I can't figure out why this statement in a custom function does not work...


IF CtrPV[9]=1 THEN
 SETBIT OUTPUT[1],0
ENDIF

Thanks,
Lloyd

BLF_Electronics

  • Newbie
  • Posts: 9
  • Controls are Cool!
    • View Profile
    • BLF Technology Group
Re:Reading counter present value
« Reply #1 on: February 13, 2004, 02:51:09 PM »
The logic you have listed will work in a [CusFn] as it is scanned continuously. If you use it in a [dCusF] it will only work if the rung goes true when the counter = 1. Try it with the [CusFn] and see if it works for you.

Brian Ferry
BLF Electronics

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Reading counter present value
« Reply #2 on: February 13, 2004, 05:57:30 PM »
How is the counter CtrPV[9] being changed? It must have a chance of being changed in some part of the ladder program or in interrupt service routine so that when you check the value of CtrPV[9] there will be a chance that the counter #9 present value can reach 1. It should work.

When you execute SETBIT OUTPUT[1],0 you are trying to turn on Output #1. But is this output also controlled by any ladder logic rung? If so, then the SETBIT OUTPUT[1],0 will only change the output bit for 1 scan time until another part of the ladder program changes it back and that may be the reason you did not see that the output has changed.

Email: support@triplc.com
Tel: 1-877-TRI-PLCS

lloyd.maclean

  • Newbie
  • Posts: 7
    • View Profile
    • lloyd's page
Re:Reading counter present value
« Reply #3 on: February 17, 2004, 06:21:41 AM »
Thanks support, you hit the nail on the head!