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

pstiles

  • Newbie
  • Posts: 12
    • View Profile
Starting and stoping a timer in a CusFN
« on: November 13, 2006, 01:51:24 AM »
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: 3102
    • View Profile
    • Internet Programmable PLCs
Re:Starting and stoping a timer in a CusFN
« Reply #1 on: November 13, 2006, 02:53:02 AM »
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 13, 2006, 03:18:27 AM »
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: 3102
    • View Profile
    • Internet Programmable PLCs
Re:Starting and stoping a timer in a CusFN
« Reply #3 on: November 14, 2006, 05:51:15 AM »
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