HMI Pad Forums Old forum Support (old) Using variable in tag name in column C

This topic contains 8 replies, has 2 voices, and was last updated by  chrsyv 7 years, 7 months ago. This post has been viewed 847 times

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #19919

    chrsyv
    Member

      Hello, I want to use the QR scanner to read a QR code, then use that information in column C for which tag I want start/stop etc.

      Problem I have so far is that I can only hardcode in which tag I want to start/stop in column C, not use the scantext variable I use to store the scanned QR code with.

      Any suggestions on how this can be solved?

      #19920

      John
      Keymaster

        Not sure if I understand well your question. I will propose a way to achieve what I think you want with a tag based on the modbus protocol. Consider the following rows

        scannedData STRING internal style=barcode;
        myPlcTag BOOL C1 value=scannedData==”ON” ? true : false ; write_access=0;

        The above code will write true (1) to Coil 1 when the scanned text is “ON”, and false (0) otherwise.

        Please let me know in case this is not what you want to achieve.

        Thanks.

        #19921

        chrsyv
        Member

          i’m using the softlogix plc, so the eth/ip protocol.

          I’ll try and add some more info to my problem:

          Let’s say I have 3 engines standing next to eachother, each with it’s seperate QR code. When the QR-code is scanned the names are Engine1, Engine2, Engine3.

          What I would like is go up to an engine, scan the QR code, then get the right information on the iPad. The problem with your example is that I would need 3 lines for each engine (start/stop/status) instead of 3 lines for all engines.

          what is in my head is: (ignore if the info in column D is wrong, it’s the column C that matters
          //EXAMPLE
          scannedData STRING internal style=barcode;
          startengine BOOL scannedData.1 style=”slider” ; write_access=0; (and the rest of the info needed)
          stopengine BOOL scannedData.2 style=”slider” ; write_access=0; (and the rest of the info needed)
          Status engine BOOL scannedData.3 READ OUT INFO ON ENGINE
          //EXAMPLE STOP

          but the problem is using the variable scannedData in the connection to the PLC doesn’t work this way.

          #19922

          John
          Keymaster

            Variable names in SM do not necessarily match tag names in PLCs. In fact I recommend using different names to avoid confusion, specially when using the EIP/NATIVE protocol. The scannedData variable in SM is a STRING value, so you can not treat it as a BOOL the way you do, however you can *compare* string values and get a boolean condition whether the comparison is true or false, as in my earlier example. You can also write the string value as is in your PLC.

            I still do not understand what you mean by “get the right information on the iPad”. I assume you want to scan the code and do something with it. You only need a single row for the scanned code, so your first row is correct. Then you can do whatever you want with it, including starting or stoping any engine or even transferring the scanned string into your PLC if you need to. I am not sure why my earlier example does not work for what you need. Please clarify. Thanks.

            #19923

            chrsyv
            Member

              Say I have 100 PLC blocks, all configured the same.

              Pin CMD.1 on the block starts the engine
              Pin CMD.2 on the block stops the engine
              Pin CMD.3 reads out if the engine is running or if it’s stopped.

              Normally, to start engine one, I would use this line in SM

              Startengine BOOL engine1.CMD.1 style=”slider” and the rest that needs to be set up.

              however this requires me to create 1 line in the excel sheet for each plc block I would want to control.
              Instead, i would like to use the string from the scancode for the FIRST part of the PLC tag I want to connect to.

              So instead of using
              Startengine BOOL engine1.CMD.1 style=”slider” and the rest that needs to be set up.

              I want to use
              Startengine BOOL scancode.CMD.1 style=”slider” and the rest that needs to be set up.

              where scancode can be Engine1-100 depending on what I scanned.

              I might have misunderstood your example, but from what I’m reading, you set the value true or false to one tag, and if the information on the scancode is any different from what you posted, nothing will happen.
              I can’t really explain it any better, and I don’t know how I can do it on the PLC.

              #19924

              chrsyv
              Member

                So I would like to use the contents of scancode to decide with PLC block I would want to control.

                #19925

                John
                Keymaster

                  Ok, lets see. It is not possible in column C to have a tag name that changes dynamically, you can only enter direct PLC tag names. This means that if you have 100 engines you will need 100 groups of tags. You can selectively hide them from the interface by using the ‘hidden’ attribute.

                  However, you can still trigger the run/stop state of your engines individually based on the scanned text. Lets suppose your scanned texts are in the form “Engine001″, “Engine002″, and so on. Consider the following:

                  scannedData STRING internal style=barcode;
                  startengine1 BOOL engine1.CMD.1 hidden=!(scannedData[0,6]==”Engine” && scannedData[-3,3].to_i==1) ;
                  startengine2 BOOL engine2.CMD.1 hidden=!(scannedData[0,6]==”Engine” && scannedData[-3,3].to_i==2) ;

                  This will check for the scanned text to contain a particular pattern followed by a number at the end to hide or show a particular row. Depending on the number only the relevant rows will show. I hope this helps.

                  #19926

                  chrsyv
                  Member

                    Ok, it won’t be optimal, but it will fill our needs! thanks for the help!

                    Oh, when using this solution, is there a limit of sorts for how many lines of code in the excel sheet SM can handle before it becomes notably slow, or any other limitations?

                    #19927

                    John
                    Keymaster

                      The ScadaMobile app was designed from the ground up for high performance. You should never find any performance issues or other limitations even with really large projects.

                      From the communications point of view, only the visible rows and the ones used in expressions will be polled from the PLC. So if you end having let’s say only 5 visible rows, then only these will be read from the PLC at every polling cycle. This is automatically handled. Other tags will not be polled because they are not visible and their value is not used elsewhere.

                      Source files (csvs) can be really large before you will notice anything. In fact I have yet to have an application with some perceptible delay at loading the csv file. I have an user with a project with above 8000 rows. I tested this project, and I can tell that it loads as fast as a 10 row project. This is because SM parses csvs only once (just after you load them to the app, or after you select them on the files tab) then stores the resulting project in a binary format that loads really fast. Still, the parsing time for said 8000 rows csv is below 1 second, but this only happens when you reload it to the app.

                      Another possible issue in your particular application is the simultaneous evaluation of hundreds of expressions at the time you scan a new bar code. I do not believe this would be an issue either, but if you are concerned about it you may try to alleviate a bit the expressions engine by using a couple of intermediate expressions, like this:

                      scannedData STRING internal style=barcode;
                      patternOK BOOL internal value=scannedData[0,6]==”Engine”; hidden=true;
                      engineNumber INT internal value=scannedData[-3,3].to_i ; hidden=true;
                      startengine1 BOOL engine1.CMD.1 hidden=!(patternOK && engineNumber==1) ;
                      startengine2 BOOL engine2.CMD.1 hidden=!(patternOK && engineNumber==2) ;

                      Thanks.

                    Viewing 9 posts - 1 through 9 (of 9 total)

                    You must be logged in to reply to this topic.

                    Copyright © SweetWilliam, S.L 2009-2013. All rights reserved.
                    Science and Technology Park of the University of Girona, Emili Grahit, 91 (NarcĂ­s Monturiol building, Office P3-B03) 17003-Girona. Phone +34972183244