Announcement

Collapse
No announcement yet.

Click programming

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

  • Click programming

    Hi,
    I was wondering if anyone could help with a small programming issue.
    I have a C0-11DD1E-D that I would like to write logic that would show machine cycles per minute and I'm not sure how to write it. I have a machine run signal and a prox that counts revolutions 1:1
    Thanks in advace.

  • #2
    Click image for larger version

Name:	Cycles per minute.png
Views:	177
Size:	206.8 KB
ID:	129216
    Attached Files
    Why worry? If you've done the best you can, worrying won't make it any better

    - Walt Disney

    Comment


    • #3
      Thanks for the input so far

      Comment


      • #4
        Todd, That is interesting, does it actually work? I've never had an occasion to use an off delay timer on a CLICK, so I don't know the internal details of how they work.
        What I would imagine, is that when the timer is activated, its accumulator is cleared and it gets ready to start timing when the enabling rung turns off, alternatively, it may do nothing when activated and both clear the accumulator and start timing on the falling edge os the enable. That is a critical difference, because if the timer works the first way, then TD1 will be zero when you divide 6000/TD1 (I think one would want 60,000, with a millisecond timer) Now if the timer works the second way you'd be fine after the first part, the TD1 would presumably still contain the time from the previous part, though there may a problem with the first part depending on what the timer contains the first time it is activated.

        Note that divide by zero is a run time error, program may compile and load fine, and in fact run fine until X001 turns on.

        Comment


        • #5
          Originally posted by Tinker View Post
          Todd, That is interesting, does it actually work? I've never had an occasion to use an off delay timer on a CLICK, so I don't know the internal details of how they work.
          What I would imagine, is that when the timer is activated, its accumulator is cleared and it gets ready to start timing when the enabling rung turns off, alternatively, it may do nothing when activated and both clear the accumulator and start timing on the falling edge os the enable. That is a critical difference, because if the timer works the first way, then TD1 will be zero when you divide 6000/TD1 (I think one would want 60,000, with a millisecond timer) Now if the timer works the second way you'd be fine after the first part, the TD1 would presumably still contain the time from the previous part, though there may a problem with the first part depending on what the timer contains the first time it is activated.

          Note that divide by zero is a run time error, program may compile and load fine, and in fact run fine until X001 turns on.
          Admittedly, this is how I do it in a PxK, and you're right, the math would preferably be 60,000/TD1, but I don't think a Click timer can have a 59,999 preset, can it?

          And true, I normally have a compare contact in front of the math statement to insure the accumulated value is above zero to prevent divides by zero.

          With no Click on my desk, I could not verify this works as written.
          Why worry? If you've done the best you can, worrying won't make it any better

          - Walt Disney

          Comment


          • #6
            Originally posted by Todd Dice View Post

            Admittedly, this is how I do it in a PxK, and you're right, the math would preferably be 60,000/TD1, but I don't think a Click timer can have a 59,999 preset, can it?

            And true, I normally have a compare contact in front of the math statement to insure the accumulated value is above zero to prevent divides by zero.

            With no Click on my desk, I could not verify this works as written.
            32767 max for timer preset (assuming a DS datatype)

            I looked through the helpfile (timer topic) and saw NO prose detailing the finer differences between TON/TOF-type setup. There is a small discussion about ACC/DN handling at input true/false transition and timer expiry. I guess that Tinker's query is up for experimentation. If anyone does/has determined (knows) this, please post findings.

            Comment


            • #7
              The destination needs to be a float, but this is in principle the same logic I have used in A/B PLCs. In the MATH instruction, you may need to imply floating point by specifying a decimal point in the constant "60000.0" in order to force the CPU to use real numbers in its internal CPU. The constant value should be whatever number represents one minute in the timer timebase. Which timebase works best depends on the real range of expected values.

              I often will have a debounce timer on the input if it is from a device subject to contact chatter or bounce and trigger the calculation from the done bit of the debounce timer. I also will often FIFO the results and perhaps average the last few of them if it is a high speed machine with enough variability. I also may add code so that if the timer gets done (because the machine is idle) I will force the result to a high limit or to zero and/or stop it from entering the FIFO (if one exists).

              In your example, the rung order is a problem. You will be resetting the timer before you use the TD1 accumulator number. In A/B there is a separate RESet instruction, so my cycle timer will be on an unconditional rung and after the math is done, I execute the RES (reset) on the timer. When rung order is critical, I try to put the logic all on one rung with branches. Sometimes it's less pretty, but it keeps people (usually me) from screwing up the order by rearranging rungs later.
              Last edited by OkiePC; 03-12-2020, 05:01 PM.

              Comment


              • #8
                I used a timer off function here. There are sensors mounted on a conveyor to sense product and i wanted to allow for a 10 second delay before reacting since a small hole in the plastic (poke holes) would cause the sensor input to go low. In this case, a timer off function was better to use.

                Mike
                Attached Files

                Comment


                • #9
                  OK, this bugged me because I KNOW I have done it. I had to use an SC4 triggering a counter. I worked on it this morning from a program done in Click software V2.1 and found in V2.6 the math WILL NOT solve to a float; I had to use a double-word. AD, I think you have a problem...

                  Click image for larger version

Name:	Cycles per minute.png
Views:	110
Size:	204.9 KB
ID:	129353
                  Attached Files
                  Why worry? If you've done the best you can, worrying won't make it any better

                  - Walt Disney

                  Comment


                  • #10
                    V2.30 bugfix 12) Math error when using complex order of operations.

                    And your math is not that complex

                    Seriously, Todd, is this a bench CPU?
                    If so, clear memory/reset factory and retry. I wonder if this is an artifact or a firmware issue.
                    Last edited by kewakl; 03-13-2020, 11:15 AM.

                    Comment


                    • #11
                      Did a factory reset and upgrade to V2.6 before writing this logic. CPU is a C0-12DRE-2-D.

                      Edit: I even tried, as you can see in the math box, using 6000.0 as a divisor for result at DF1, and it would not solve.
                      Last edited by Todd Dice; 03-13-2020, 02:25 PM.
                      Why worry? If you've done the best you can, worrying won't make it any better

                      - Walt Disney

                      Comment


                      • #12
                        I noticed the 6000.0.
                        thx for the update

                        Comment


                        • #13
                          As the old commercial once said, "I shoulda had a V-8!"

                          I discovered my issue is the Click model; it has analog I/O, and DF1-DF6 are dedicated to those points. If had chosen DF10 say, I'm certain it would have worked.
                          Why worry? If you've done the best you can, worrying won't make it any better

                          - Walt Disney

                          Comment


                          • #14
                            Just confirmed. Changed result to solve to DF7, and it worked.
                            Why worry? If you've done the best you can, worrying won't make it any better

                            - Walt Disney

                            Comment


                            • #15
                              Are DF1-DF6 'dedicated' as in CANNOT be changed, or is this a project allocation?

                              Comment

                              Working...
                              X