Author Topic: TimerPV countdown  (Read 15273 times)

dave333

  • Newbie
  • *
  • Posts: 5
  • I'm a llama!
    • View Profile
TimerPV countdown
« on: January 08, 2019, 12:06:07 PM »
I'm running a system with a SmartTile and a Weintek MT8050iE with EasyBuilder Pro.  On the operating panel I have a display showing the TimerPV of
the system on time.  It's set up as 99.9S max.   When I first set up the system I got a very smooth countdown on the display.  The tenths of a
second value was visibly counting down .1s at a time.  Somewhere along the line I made some other changes to the program and now the display
counts down in varying increments, e.g. 55.2, 54.6, 53.9 etc.  I've tried running trial programs  with just the timer with no other functions
but haven't been able to duplicate my initial results.  Is there something I can look at to get the tenths of a second countdown as before or do
I have to accept the incremental change in display.  Thanks for any help you can provide.

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:TimerPV countdown
« Reply #1 on: January 08, 2019, 02:25:15 PM »
Dave,

Inorder for the HMI to display a TIMER PV that is changing at a 10 Hz rate (0.1 second period) the following things must happen:
    [*] The HMI has to be able to request the TIMER PV at a 20 Hz rate (0.05 second period) to not miss a single count.  This is a the Nyquist sampling rate minimum.  The total time to send the request from the HMI to the PLC for the TIMER PV, the time for the PLC's low level firmware to respond to this request, the transit time to return the data to be to the HMI and finally the time required by the HMI to process the data and update HMI window, must be less than 0.05 seconds.
    [*] The PLC ladder logic scan rate has to equal or exceed 20 Hz for the TIMER's PV to update without missing a count.  The TIMERs are implemented in firmware on the PLC and the TIMER PV is only updated at the start of a scan of ladder logic.
    [/list]

    If your requirement is to display time to 0.1 seconds without losing counts on the HMI display, then you need to reduce the time that your PLC program takes to execute.

    The PLC scan rate is directly affected by the complexity of the PLC program.  You can test this by writing a 2 line PLC program.

    The custom function, ScanDelay, is a time waster that can be used to emulate a complex PLC program:

    ' ScanDelay - CF that wastes time to simulate a complex PLC program
    '
    ' The variable A, determines the number of ms to waste
    '
    Delay A
    [/tt]

    You can change the value of "A" using online-monitoring.  You will probably have to exit the on-line monitor to see the affect of slowing down the ladder logic scan rate.  The communication between your PC and the PLC to support on-line monitoring will probably slow the PLC to the point that the TIMER PV will appear to miss cycles.


    Gary D*ckinson
    « Last Edit: January 08, 2019, 02:28:34 PM by garysdickinson »

    dave333

    • Newbie
    • *
    • Posts: 5
    • I'm a llama!
      • View Profile
    Re:TimerPV countdown
    « Reply #2 on: January 09, 2019, 01:09:48 PM »
    Gary:

    Thanks for the response.  It's good to know what the limitations are.  I will try some sample programs using the
    ScanDelay to get a feel for the effect of the PLC program size.

    Dave

    garysdickinson

    • Hero Member
    • Posts: 502
    • Old PLC Coder
      • View Profile
    Re:TimerPV countdown
    « Reply #3 on: January 09, 2019, 02:03:38 PM »
    Dave,

    Good luck with your experiments.

    The processor used on the SmartTile is fastest of all the PLCs that I have used from TRI.  I have measured scan rates for trivial ladder logic programs at about 200 Hz (0.005 second period)!

    As a guide to execution speeds, ladder logic exection is extremely fast.  The execution of TBASIC (Custom Functions) takes more CPU time. So I tend to do as much work in ladder logic as possible and use CFs only as needed.

    I do not know how you have connected the HMI to the PLC.  On most of my systems I have chosen to use a serial link.  I use Modbus RTU between HMI/PLC. I have found that the PLC overhead is less with this combination then when using Ethernet and the TRI hostlink protocol.

    There are things that might work for you that could create a down counter with a 0.1 second resolution without the use of the PLC.  The HMI has a free running system clock with a resolution of 0.1 seconds.  This clock is accessible to the HMI's version of custom functions called macros.  It is possible to have a macro called at a rapid rate when a window is being displayed.  This would allow you to build a numeric display object would display the value of a variable local to the HMI.  This approach does not require as much bandwidth between the HMI/PLC.  This approach would present less issues with PLC scan rate as you are not using a PLC TIMER.

    Best regards,

    Gary D*ickinson


    « Last Edit: January 09, 2019, 02:05:10 PM by garysdickinson »