Announcement

Collapse
No announcement yet.

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

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts


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

    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.
    Attached Files
    Last edited by Mvlawn; 05-15-2016, 06:47 AM.


  • #2
    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.
    thePLCguy

    Bernie

    Comment



    • #3
      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

      Comment



      • #4
        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.
        thePLCguy

        Bernie

        Comment



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

          Comment



          • #6
            MATH, no need for move/copy

            Comment



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

              Comment



              • #8
                Originally posted by Mvlawn View Post
                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
                Code:
                                   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.
                Last edited by kewakl; 05-18-2016, 06:03 AM.

                Comment



                • #9
                  Works great. Thank you for the tutorial!!!

                  Comment



                  • #10
                    Originally posted by bcarlton View Post
                    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?

                    Comment



                    • #11
                      Waiting for the 'done bit' to be true takes the preset time since the timer was started plus up to one scan time (if the timer accumulated value reached the preset just after the timer instruction was scanned. And, as you pointed out. an extra scan is introduced to actually perform the reset. Thus this, on the average, would take preset plus 1 and 1/2 scan time for multiple reseets. This difference may not be important in your application.

                      But for an application which needs a little more accuracy the 'subtract the desired time from the accumulated value' method will, on the average, take precisely the preset time. it's a little more work than just
                      thePLCguy

                      Bernie

                      Comment

                      Working...
                      X