Announcement

Collapse
No announcement yet.

Click PLC internal c bit set/reset not working as expected.

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


  • Click PLC internal c bit set/reset not working as expected.

    Can anyone explain why the following is not working as I'm expecting it to? I'm trying to toggle a c-bit (set/reset) with an input.The c-bit is not used anywhere else in the program. I have tried both of the following examples.

    Example 1: (RE=Rising Edge)

    Code:
    |                                                 |
    |      X001      C1                    C1  |
    |-----|RE|----------| |------------------(RST)| 
    |             |                                    |
    |             |      C1                    C1  |
    |             -------|/|-------------------(SET)|
    Example 2: (RE=Rising Edge)

    Code:
    |                                                  |
    |      X001      C1                    C1  |
    |-----|RE|----------| |------------------(RST)|
    |                                                  |
    |                   C1                    C1   |
    |--------------------|/|-------------------(SET)|
    Essentially, I've tried using the set and reset instruction in the same rung, and in two separate rungs. I'm expecting to toggle the c1 bit to toggle every
    time x1 is made, but the c1 gets set, and will never reset.



  • #2
    Ladder logic executes left to right top to bottom, scan after scan after scan. Lets take it step by step. For example #1, when you press X1, it cannot Reset C1 as it is not True, but the next rung says if its not true, SET C1 - so it SET's it. The next time you press X1 the PLC goes to the first rung and resets C1 as it is True. The very next rung says if it is NOT True - SET it. So it SET's it. The next time you press X1 it does it again.

    Example two will always SET C1 when C1 is not True, it does not matter. C1 will always be Set.



    Try this:




    Click image for larger version  Name:	toggle.png Views:	1 Size:	56.7 KB ID:	104805


    BTW, I used CLICK software to demo it. The contact with the arrow going up is a RE(rising edge) in your example.

    Last edited by icauto1; 02-25-2017, 08:53 AM.

    Comment



    • #3
      Mine is similar to icauto1's example

      Code:
      Toggle C2 on every RISING_EDGE of C1  
              -|^|- is RISING EDGE
      
            C1           C2                   C2
      -+-----|^|----------|/|-----+------------(OUT)
       |                          |
       |      C1           C2     |
       +-----|/|----------| |-----+
      
      NOTE: This rung is NOT required if using
      a physical input PushButton.
      HOWEVER, a physical button may bounce causing C2 CHATTER.
      This rung will be required if using HMI button in SET MODE.
      I refrain from using HMI buttons in MOMENTARY MODE.
                                                C1
      -----------------------------------------(RES)

      Comment



      • #4
        Sorry, I had an error in the way I wrote example 2 (notice the rising edge x1 in rung 2), it should have looked like this:

        example 2: (revised)
        Code:
        |        
        |      X001          C1                    C1
        |-----|RE|----------| |------------------(RST)
        |
        |      X001           C1                    C1
        |-----|RE|-----------|/|-------------------(SET)
        So, I understand the way ladder logic executes, and why example 2 may reset and set the bit during a single scan, but example 1 should theoretically work, because the rising edge contact should be examined true for 1 scan only. My understanding of the logic flow for example 1: x1 is active c1 -||- is made c1 -|/|- is not made -->reset C1 --> end scan of rung.

        I did end up using a toggle bit to fix this, I just couldn't wrap my head around why it executed like this. I'm pretty sure I've seen other plc's handle example 1 as I expected it to function.
        Last edited by First_Scan; 02-25-2017, 11:39 AM. Reason: fix formating on code block

        Comment



        • #5
          Your Example 1 might work in some smart relays because they evaluate top to bottom, left to right, which is not how most of us older timers think a PLC should behave.

          Your example is going to evaluate the rung left to right on the top branch (row) and the result it gets for C1 output will be applied to the C1 test in the second branch (row) of rung 1.

          Comment



          • #6
            Continued conditionals is something I ran into in an old A-B PLC2 (limit on columns?)
            My Do-more Sim examples show how Y0 gets evaluated and in which order.
            The Status is too short to display being that Y0 (first example) is only on after rung 1
            is evaluated up until rung 2 evaluation is complete.

            Click image for larger version

Name:	Continued Logic.png
Views:	120
Size:	17.4 KB
ID:	104813

            Click image for larger version

Name:	Continued Logic 2.png
Views:	123
Size:	7.8 KB
ID:	104815






            Attached Files

            Comment



            • #7
              Originally posted by Mike Nash View Post
              Your example is going to evaluate the rung left to right on the top branch (row) and the result it gets for C1 output will be applied to the C1 test in the second branch (row) of rung 1.
              [EXAMPLE 1]
              AND all this happens DURING the SAME scan, so:
              C1 (if TRUE will be RESET by the RST in the top output branch)
              (if FALSE, nothing else happens in the top output branch)
              Since C1 must be false, the second branch MUST SET C1.


              but the c1 gets set, and will never reset
              Oh, C1 DOES get Set, but only until the second output branch is evaluated/updated.
              By the end of the scan, it will be set. You will NEVER see it be false.
              The last one wins is a popular phrase concerning this type of situation.
              Last edited by kewakl; 02-25-2017, 04:31 PM.

              Comment



              • #8
                Important
                Remember the PLC program runs from top to bottom and as each rung is executed it's only the rung under it that is a affected not the one above until the next scan cycle.
                Example
                When X1 goes high the one shot gives a single scan cycle pulse that sets S1 true.
                The next scan cycle the one shot is low and S1 is now set true enabling S2 to be set on the next input from X1 and disabling the S1 SET bit.
                When the next input from X1 goes high again the one shot will set S2 high now resetting the S1 bit low.

                Comment



                • #9
                  This is easy for me to read. c1 is the toggle output.

                  c1 sw c2
                  ---| |----|^|---------------(OUT)

                  c1 sw c3
                  ---|\|----|^|---------------(OUT)

                  c2 c1
                  ---| |----------------------(Reset)

                  c3 c1
                  ---| |----------------------(SET)

                  Comment



                  • #10
                    Originally posted by bsinkovich View Post
                    This is easy for me to read. c1 is the toggle output.

                    c1 sw c2
                    ---| |----|^|---------------(OUT)

                    c1 sw c3
                    ---|\|----|^|---------------(OUT)

                    c2 c1
                    ---| |----------------------(Reset)

                    c3 c1
                    ---| |----------------------(SET)
                    Too bad that the forum FORMAT DESTROYER struck again!

                    Code:
                    .
                    .     c1    sw                 c2
                    . ---| |----|^|---------------(OUT)
                    .
                    .     c1    sw                 c3
                    . ---|\|----|^|---------------(OUT)
                    .
                    .     c2                       c1
                    . ---| |----------------------(Reset)
                    .
                    .     c3                       c1
                    . ---| |----------------------(SET)
                    and without the leading dots, the forum will munge properly formatted CODE-tagged text, too!

                    Comment



                    • #11
                      Kewakl, I want to be good.

                      Caddyshack
                      Judge Smails: "Do you want to be good Danny"

                      How do you do the formatting above?
                      Thanks, Brad

                      Comment



                      • #12
                        Never mind, got it. Thanks.

                        Code:
                        .          OK          OK
                        .-----------^----------^

                        Comment

                        Working...
                        X