adccommunitymod (AutomationDirect) asked a question.

What register should I use to display values to the right of the decimal

Created Date: May 15,2016

Created By: Mvlawn

**** This post has been imported from our legacy forum. Information in this post may be outdated and links contained in the post may no longer work.****

I am trying to calculate minutes into hours. and while it will display the correct number to the left of the decimal, nothing displays to the right. How do I get past this? I am using a Click PLC.


  • adccommunitymod (AutomationDirect)

    Created Date: May 15,2016

    Created by: Mvlawn

    I am trying to calculate minutes into hours. and while it will display the correct number to the left of the decimal, nothing displays to the right. How do I get past this?

    I am using a Click PLC.

  • adccommunitymod (AutomationDirect)

    Created Date: May 15,2016

    Created by: bcarlton

    In the image you provided an integer value is copied into a Float register. Since it comes from an integer there is nothing past the decimal point to display. In the next rung the value is divided by 60 but the result is sent to an integer register (DS1). If you want to see the appropriate value (7.833333) instead of the rounded value assign the result to a float register (maybe DF2 if it is not already being used) and write the value of 60 as '60.0 ' to give a hint that you want to do decimal point type math. If you want to break out the value as whole hours and minutes then let us know.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: May 16,2016

    Created by: Mvlawn

    Bernie. That worked as you described. Thanks for helping me out again. One more question, see how I am using the Timer on Delay to count Total run time? Is that how you would do it? The max I can go on the timer is 32,767

  • adccommunitymod (AutomationDirect)

    Created Date: May 16,2016

    Created by: bcarlton

    Try this - change you T3 timer to a millisecond time base. Whenever the accumulated time is equal to or greater than 1000 (1 second) then increment a DD register and subtract 1000 from the timer's accumulator. The DD will give you 68 years worth of seconds (if that's enough). You won't need the reset line on the T3 timer. Subtracting the 1000 from the accumulator this way is technically a little more accurate than just waiting for a 1000 millisecond timer to time out then turning on the reset.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: May 18,2016

    Created by: Mvlawn

    Bernie. I was with you up until the subtraction. How would I do that, through a move or copy function?

  • adccommunitymod (AutomationDirect)

    Created Date: May 18,2016

    Created by: kewakl

    MATH, no need for move/copy

  • adccommunitymod (AutomationDirect)

    Created Date: May 18,2016

    Created by: Mvlawn

    What I don't understand is how to subtract the 1000 msec from the timer, without a reset on it.

  • adccommunitymod (AutomationDirect)

    Created Date: May 18,2016

    Created by: kewakl

    What I don't understand is how to subtract the 1000 msec from the timer, without a reset on it.

    Assuming Timer 1 and your rollover count register is DD1

    TD1 1000

    -----------------------]=> MATH TD1 Subtract 1000 from Timer Accumulator

    | | TD1 - 1000 After this scan, the TD1 => 1000 test will be

    | +--------------- false IF (the original value of)TD1 is LESS THAN

    | 2000.

    | If, on the next scan, TD1>=1000 again

    | another second will be counted.

    |

    +-------------+MATH DD1 Add 1 to Timer Rollover Counter

    | DD1 + 1 Would equate to 1 elapsed second

    +---------------

    I have gone so far as to test this code in CLICK 2.00 editor. It passes Syntax Check.

    Expand Post
  • adccommunitymod (AutomationDirect)

    Created Date: May 18,2016

    Created by: Mvlawn

    Works great. Thank you for the tutorial!!!

  • adccommunitymod (AutomationDirect)

    Created Date: July 14,2016

    Created by: g.mccormick

    Try this - change you T3 timer to a millisecond time base. Whenever the accumulated time is equal to or greater than 1000 (1 second) then increment a DD register and subtract 1000 from the timer's accumulator. The DD will give you 68 years worth of seconds (if that's enough). You won't need the reset line on the T3 timer. Subtracting the 1000 from the accumulator this way is technically a little more accurate than just waiting for a 1000 millisecond timer to time out then turning on the reset.

    Bernie, does the inaccuracy of using the reset stem from having to "waste " a scan? If the timer done is used to reset itself, the scan timing would be as :

    Scan 1 timer becomes true after timer rung

    Scan 2 timer is true so reset happens-this scan took a few ms.

    Scan 3 timer starts counting again.

    If you use the brute forcing of a value, the middle San is done away with correct?

    Scan 1 timer reaches 1000

    Scan 1 we do something

    Scan 1 set timer accumulated to 0

    Scan 2 timer increments to 1

    Is that what you meant?

    Expand Post
10 of 11