Author Topic: Starting and stoping a timer in a CusFN  (Read 18710 times)

pstiles

  • Newbie
  • Posts: 12
    • View Profile
Starting and stoping a timer in a CusFN
« on: November 12, 2006, 05:51:24 PM »
I need to use a timer as a total run-time timer. I need to start it when my furnace is first turned on and stop it when the furnace is turned off. I am starting ans stoping the furnace from with in a CusFN by setting and clearing a bit. Can someone tell me how I can accomplish rhis?

Thanks

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Starting and stoping a timer in a CusFN
« Reply #1 on: November 12, 2006, 06:53:02 PM »
You could set a relay bit whose contact is used to turn ON/Off a timer in a separate ladder circuit.

Alternatively, you could start a timer by assignment its PV to a value you wish for it to start counting down:

E.g. TIMERPV[1] = 100  ' 10.0 second timer.

To clear a timer within a custom function without using a ladder circuit, you can assign the PV to -1 and use CLRIO to clear the timer.

E.g If timer #2 is called "T2", then:

  TIMERPV[2] = -1
  CLRIO  T2

The above two statements resets a timer.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

pstiles

  • Newbie
  • Posts: 12
    • View Profile
Re:Starting and stoping a timer in a CusFN
« Reply #2 on: November 12, 2006, 07:18:27 PM »
This would trun the furnace off after 10 sec. What I need is to know how long the furnace is running, I.E a total run-time timer. A run-time timer is cumulative.

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Starting and stoping a timer in a CusFN
« Reply #3 on: November 13, 2006, 09:51:15 PM »
In that case, use a counter driven by a clock pulse to measure your run time.
      R1     Clk:1.0s                    C1
|----||------||----------------[UpCtr]

When R1 is turned ON (you can use SETIO in custom function to set R1) C1 will count up every 1 second until it reaches the maximum set value and it will then roll over. You can cascade the overflow to another count to count larger than 9999.

When R1 is turned OFF, C1 stops counting.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS