Announcement

Collapse
No announcement yet.

Variable programming

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


  • Variable programming

    Hello all,

    I'm new to the Click PLCs and to be completely honest I haven't had much practical experience with any PLC's since college. That being said I recently started a new job that we use Click PLC's exclusively and I'm trying to help clean up some of our 'Common Code'.

    We use the PLC to control air solenoids for clamps. On any given product we will have 2-6 clamps and sometimes even 8 clamps that could be used. We have a program that releases all clamps at the same time but inside the logic we basically have the same code copied several times over depending on how many valves we use on the job.

    I'm wondering if there is a way to write one set of "generic" code that could be automatically configured inside the PLC. That way instead of having 30 lines of code for 6 valves we could use one set of 5 lines that repeats and changes outputs 6 times.

    Like I said its been awhile since I've really programmed PLCs so I'm not even sure this is possible but any ideas/suggestions/comments would be awesome.

    Thank you for reading!

    D


  • #2
    More information is needed to provide an answer.

    1. What action starts each clamp? A pushbutton? Or are they cascaded, one after another?

    2. What action releases the clamps? A pushbutton? After a signal by a sensor? After an amount of time?

    But, to provide "some" answer, I envision you just programming 8-outputs to do the clamping, and say for my example, they cascade in their implementation; one after another. When the output for the 8th clamp is energized, you could also have a jumper wire from the 8th output to power an input that is, for lack of a better description, "the last clamp of the series is made", and then do your logic. If say, you're only using 6-clamps, then instead connect the jumper to the sixth clamp output, to give the PLC the signal, "the last clamp of the series is made."

    This way, you have the same generic code for all your machines, and your only worry is the wiring of the jumper from the last clamp in the series.
    If you've done the very best you can, worrying won't make it any better - Walt Disney

    Comment



    • #3
      I believe that what the OP is wanting would be indirect addressing.
      The CLICK does not support indirect addressing natively, but you can 'roll your own' using the COPY instruction that is set to 'Unpack'.
      You can use a memory location as the source, and C bits as the output.
      Now all you have to do, is load the correct values into the input register, and the whole program is automatically re-configured for different machines.
      I have never actually commissioned a project with a CLICK, but there are some other CLICK gurus on here that could offer more detailed help.
      Circumstances don't determine who we are, they only reveal it.
      Jason Wolthuis

      Comment



      • #4
        Originally posted by plcnut View Post
        I believe that what the OP is wanting would be indirect addressing.
        The CLICK does not support indirect addressing natively, but you can 'roll your own' using the COPY instruction that is set to 'Unpack'.
        You can use a memory location as the source, and C bits as the output.
        Now all you have to do, is load the correct values into the input register, and the whole program is automatically re-configured for different machines.
        I have never actually commissioned a project with a CLICK, but there are some other CLICK gurus on here that could offer more detailed help.
        You can unpack from DHx to Cxx - Cyy.

        I do not have a good grasp of what OP really needs. If he describes his application a bit, like Todd (RM) requested, maybe...

        but there are some other CLICK gurus on here that could offer more detailed help.
        I'm not claiming any GURUship with CLICK.

        Comment



        • #5
          Originally posted by kewakl View Post
          You can unpack from DHx to Cxx - Cyy.

          I do not have a good grasp of what OP really needs. If he describes his application a bit, like Todd (RM) requested, maybe...


          I'm not claiming any GURUship with CLICK.
          Or if he just posts the code they copy and paste over and over, that would be helpful.

          -Todd
          If you've done the very best you can, worrying won't make it any better - Walt Disney

          Comment



          • #6
            OK guys, my original post can just be scraped. What I was going for wasn't going to work.

            I'm going to go a different direction.

            Basically I want to take 2 bytes and use that to control an output block.

            Semi-visual example: 2 Bytes recieved (1000 1110 1010 0110)
            Output block turns sets outputs 2,3,6,8,10,11,12 and 16 on.

            I thought it would be pretty easy to write but I'm already stuck trying to mask individual bits.

            I used an already working program and copied everything over that actually reads the message but like I said, trying to break up the message into individual bits is proving difficult.

            The programmer that would help me is in Brazil right now and I'm sure he will help me but I'm trying to get a bare bones program going just to show proof of concept.

            Comment



            • #7
              Like this?
              Attached Files
              If you've done the very best you can, worrying won't make it any better - Walt Disney

              Comment



              • #8
                Wow, that looks a lot easier than what I had in mind

                I'm going to try to play with that for a bit.

                Thank you!!

                Comment



                • #9
                  Happy it helped.
                  If you've done the very best you can, worrying won't make it any better - Walt Disney

                  Comment



                  • #10
                    It helps to work these things in hex.
                    If you use masks, make them hex. the bit -patterns work nicely -- each byte is 8 in or 8 out.
                    Code:
                    
                                    HEX             BINARY           DECIMAL
                          BYTE    &H55AA  =  0101 0101 1010 1010  =  21,390
                          MASK    &HF01F  =  1111 0000 0001 1111  =  61,471
                    ---------------------------------------------------------------
                    (AND) WORD    &H500A  =  0101 0000 0000 1010  =  20,490
                    ---------------------------------------------------------------
                    (OR)  WORD    &HF5BF  =  1111 0101 1011 1111  =  62,911
                    ---------------------------------------------------------------
                    (XOR) WORD    &HA5B5  =  1010 0101 1011 0101  =  42,421
                    Doing this in decimal would be a bear.


                    What I'm driving at is: If you need to send a byte to an output module that only has 6 outputs, and not SET the UNAVAILABLE last two bits of that output word, MASK (AND) that copy with &H3F.
                    Code:
                    
                    &H3F  =  0011 1111     <-  MASK  a 1 in an output position enables that output
                             |||| ||||               to be modified
                             |||| |||+-- out 1
                             |||| ||+--- out 2
                             |||| |+---- out 3
                             |||| +----- out 4
                             |||+------- out 5 
                             ||+-------- out 6  
                             |+--------- out 7 N/A
                             +---------- out 8 N/A
                    
                    See Tinker's masking snippet here. The program snippet masks out more bits, but the concept is the same.
                    Last edited by kewakl; 03-01-2016, 05:01 PM.

                    Comment



                    • #11
                      OK, back to the original topic of this thread.

                      I'm going to try to be more specific, clear and simple in what our vision is and would like to know if you guys think its possible.

                      So basically we want to know if we can have a program that is configurable without reprogramming the PLC.

                      Right now we use the PLC for up to 6 connectors. 6 connectors is all that we have needed in the past but we are looking at a job that will require up to 12. We might not use all 6 connectors for each job but our code has the ability for up to 6. The way it is programmed now is we have 10 lines of code per connector, each set of code is basically identical except the addressing of certain instructions change per connector. We are trying to stay away from copying the code another 6 times.

                      What we are trying to accomplish is using those 10 lines of code but have the bit addressing change based off a configuration that the PLC receives.

                      Right now we have the PLC receiving an 11 byte message via ASCII. Inside those 11 bytes is a byte of information that tells the PLC what connector we are using. We would like to use that byte ( or more if needed) as the variable/configuration for the code. It will receive the 11 bytes on the first scan and one byte will request connector 1. So it will use that byte to run the code for connector 1. Next cycle it will ask for connector 3, then the same 10 lines of code ( or sub routine) would run for connector 3. So on and so forth.

                      The point of this is to develop generic code that we can put into all of our PLCs and have the ability to use 1-XX amount of connectors.



                      I'm not entirely sure this is possible with CLICK or even any type of PLC out there but I wanted to get your opinion on what you think we could try. I'm not going to ask you guys to write any code for us or anything like that just guiding me in the right direction would be awesome. Like I said, I'm not entirely convinced this is possible.


                      Thank you for your time,

                      Danny

                      Comment



                      • #12
                        Seems possible, and If I am understanding you correctly, you will need a final rung that may look like the attached.

                        C1 is your current "output" used for the connector.
                        DS1 is just the placeholder that accepts the value of "which" connector you wish to power.
                        Attached Files
                        If you've done the very best you can, worrying won't make it any better - Walt Disney

                        Comment



                        • #13
                          Is it a secret or can you post any code.
                          If we had those 10 rungs of code and how they interact with the 'cycle' that you mentioned, we may be able to give suggestions.
                          What is a 'cycle?'
                          Do the actions of one 'connector cycle' overlap with the actions of another 'connector cycle?'
                          If you do add more 'connectors' will the physical configuration of the CLICK I/O require changing?

                          Comment



                          • #14
                            Originally posted by ridgeline mach View Post
                            seems possible, and if i am understanding you correctly, you will need a final rung that may look like the attached.

                            C1 is your current "output" used for the connector.
                            Ds1 is just the placeholder that accepts the value of "which" connector you wish to power.

                            Almost the same as above:
                            C1 is current "output" for desired CONNECTOR
                            DS1 is the DESIRED connector to power
                            Shorter code, however may be harder to understand.

                            Code:
                                     C1                                       Y001  Y008
                            ---------] [--------------+--------------------------(RST)
                                                      |
                                                      |  DS1 1        DS1 8
                                                      +--]>=[---------]<=[-------[Copy Single
                                                                                  1  YD[DS1]
                            It passes SYNTAX CHECK, but I haven't put this code in a CLICK

                            NOT WORKING! let me work a bit

                            Code:
                                     C1                                       Y001  Y008
                            ---------] [--------------+--------------------------(RST)
                                                      |
                                                      |  DS1 1        DS1 8
                                                      +--]>=[---------]<=[-------[Math  DS2
                                                      |                           2 ^ (DS1 -1)
                                                      |  DS1 1        DS1 8
                                                      +--]>=[---------]<=[-------[Copy Single
                                                                                  DS2 YD0
                            BETTER! Forgot the YD starts at 0.

                            Use MATH + Copy DS2 YD0 to output a Single output that is the value of DS1
                            Use Copy DS1 YD0 to output a binary pattern to the output module
                            Last edited by kewakl; 03-03-2016, 04:12 PM. Reason: update the DS1, DS2 output description

                            Comment



                            • #15
                              Click image for larger version

Name:	Connector1_1.jpg
Views:	1
Size:	253.3 KB
ID:	97404

                              Click image for larger version

Name:	Connector1_2.jpg
Views:	1
Size:	250.3 KB
ID:	97405

                              Click image for larger version

Name:	Connector1_3.jpg
Views:	1
Size:	248.3 KB
ID:	97406

                              This is what we have right now X 6

                              Comment

                              Working...
                              X