From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Match True/False String help

Solved!
Go to solution

Hello All,

 

I am fairly new to LabVIEW. I am using LabVIEW 2013 and I am doing some communication with an ABB robot. I am receiving strings from the robot controller in LV via sockets. What I am trying to do, is if the string says "FALSE", LV turns a boolean operator to False, and if the string says "TRUE", LV changes the boolean operator to True. I am using the "Match True/False String" Function to do this. For some reason I am having problems getting that function set up correctly. This is how I have it currently:

True_False String.JPG

 

Is there something I am doing wrong by tying all the nodes into the same string?

 

Thanks for any help!

SM

0 Kudos
Message 1 of 15
(6,280 Views)

My recommendation would be to simplify:

 

 

string check.png

0 Kudos
Message 2 of 15
(6,263 Views)

Will doing it that way turn the boolean to false if the string says "FALSE"?


Thanks,

SM

0 Kudos
Message 3 of 15
(6,260 Views)

Edit

0 Kudos
Message 4 of 15
(6,257 Views)

It's "Equals?", on the Comparison palette. Simply returns TRUE if the inputs are equal, or FALSE otherwise.

0 Kudos
Message 5 of 15
(6,253 Views)

Ok thanks.

 

Another question, once the boolean is true, I want it to stay true for 5 seconds and then go back to false. What's the best way to do that?

 

Thanks,

SM

0 Kudos
Message 6 of 15
(6,243 Views)
Solution
Accepted by topic author Sman29

In like to use "Match Pattern" when comparing strings received from instruments. That way if there is some white space before or after (like a carriage return/line feed), it will still match the TRUE case.

 

STR_Compare.png

0 Kudos
Message 7 of 15
(6,236 Views)
Yes. In a robotics, or any kind of control application, you should have at its core a while loop that basically runs forever. The tiny bit of code you have shown would run inside that loop.

Now once your signal goes true, you could start a timer that turns it off after a known delay. Of course if the condition that caused it to turn on in the first place is still active, it will turn right back on.

Perhaps you could explain a bit more?

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 8 of 15
(6,219 Views)

@SteMob wrote:

Ok thanks.

 

Another question, once the boolean is true, I want it to stay true for 5 seconds and then go back to false. What's the best way to do that?

 

Thanks,

SM


There are many ways but showing us a JPG of one small section of your code isn't enough information to guide you.  We need to see the overall code structure.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 9 of 15
(6,212 Views)

Well I can't really upload my whole code for different reasons. Essentially I have the robot as the client, and LV as the server. Once the TCP connection is successful, the robot sends a string saying connection successful. The robot then has a While loop constantly running waiting for commands from LV. So my robot code is a bunch of IF statements like this:

 

                      IF MoveNext=1 THEN
                            MoveJ Position_1;
                            WaitTime 1;
                            SocketSend client_socket\Str:="TRUE",\NoOfBytes:=4;
                        ENDIF

                    IF MoveNext=2 THEN
                            MoveJ Position_2;
                            WaitTime 1;
                            SocketSend client_socket\Str:="TRUE",\NoOfBytes:=4;
                        ENDIF

.......

Once LV receives the "TRUE" message, it turns on a boolean to True for 5 seconds, then goes to False. Once the boolean goes to False, LV sends a signal to the robot to increment "MoveNext". The problem is right now, I have to keep manually sending the "Step" command to go from point to point, whereas I need it to increment automatically and move to the next position without being told. Basically the robot sits there waiting on signals from LV telling it to increment and move to the next position.

 

So here is the code for the connection and communication:

True_False String2.JPG

This is the code to start the moves, but I keep having to hit "Step" for each move, whereas I need it to be based off the timer:

 

True_False String3.JPG

 

And this is the code that is supposed to turn the timer on for 5 seconds, then send a message back to the robot setting command=45 which the robot takes and increments automatically like this:

 

True_False String4.JPG

 

IF bytes_available>=1 THEN
                    UnpackRawBytes parse_data,1,command\Hex1;
                    IF command=45 THEN
                        command:=0;
                        Incr MoveNext;
                       

                       IF MoveNext=1 THEN
                            MoveJ Position_1;
                            WaitTime 1;
                            SocketSend client_socket\Str:="TRUE",\NoOfBytes:=4;
                        ENDIF............

Does this kind of help explain what I am trying to do?

 

Thanks for all the help,

SM

0 Kudos
Message 10 of 15
(6,197 Views)