Author Topic: Counter  (Read 10957 times)

tobor0216

  • Newbie
  • Posts: 24
  • I'm a llama!
    • View Profile
Counter
« on: May 31, 2010, 10:44:37 AM »
I am trying to sense to many time per day my air conditioner runs. I installed a switch in the duct work that has a paddle in it. When the fan turen on the switch is made. The switch is made until the fan turns off.

I want to increment the counter by 1 when the switch is made. The reset the trigger (Input 1) and wait for the next time the switch is mad to increment the counter.

Any Ideas?

I tried the code below


If testbit(Input[1],1)then
C = C+1
Endif

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Counter
« Reply #1 on: May 31, 2010, 11:15:02 AM »
Is the switch connected to Input1? Or is there a separate "reset trigger" input?

Assuming your fan sensor switch is connected to an input named: fanSwitch:


Within the custom function FanSWCnt you can put your statement:

C = C+1

which will increment the counter.

If you have a separate reset switch to reset the counter then you can connect the reset switch to another custom function and then within that CF you run the statement:

  C = 0

to reset it.


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

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Counter
« Reply #2 on: May 31, 2010, 11:17:38 AM »
The program of course can also be constructed purely out of ladder logic using the [UpCtr] counter. The maximum range in this case is 1 to 9999. You can cascade multiple counters to expand the range. i.e. when first counter reaches 9999 and roll over to 0 it increments another counter. The range therefore increased to 1-99999999 counts.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS