LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can anyone please explain these functions?

Solved!
Go to solution

- Picture 1

1) What does the "width" (Blue color) do in Number To Decimal String function?

2) How does calculation work in String Length function?

3) Why do I need 2 TCP Read functions?

 

- Picture 2

1) What does the "offset" (Blue color) do in Search/Split String function do? 

2) Again, why do I need 2 TCP Read functions?

 

My apologize if I ask too obvious questions because I'm trying hard to understand these functions but those jargons really bring me down. In case you're wondering, this is part of my assignment.

 

 

Download All
0 Kudos
Message 1 of 9
(3,484 Views)

For most of your questions, what is it you don't understand in the Context Help explanations for your functions?

0 Kudos
Message 2 of 9
(3,450 Views)

1. The width is the minimum number of characters to have in the resulting string.

2. I don't understand your confusion here.  It is purely the number of bytes in the string.

3. A simple communication method is to first send the number of bytes in the message and then the message itself.  So the first write is sending the number of bytes and the second write is the actual data.  On the read side, you first read the number of bytes (I32, so 4 bytes) and use that to read the full message.

 

As already stated, most of your questions here can be answered by reading the context help and the full help.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 9
(3,432 Views)

- Picture 1

1) For the "width", let's say the input number is 5 and the width is 3. Does it mean that the function will show like _ _ 5 and the number can only reach until 999?

 

2) I concatenate 1 boolean (1 byte?) and 1 number (1 bit?). Does the final number of length is 1.125 bytes?

 

3) For this question, I understand how TCP Write works but I just don't understand why do I need 2 of it.

 

- Picture 2

1) Even I read from the Context Help explanations, I still don't understand what does "offset" mean.

 

2) Same with Picture 1 - 3

0 Kudos
Message 4 of 9
(3,429 Views)
Solution
Accepted by Crazy6a3er

A computer works with bytes.  So you cannot have partial bytes in a data structure.  Most integers are I32, meaning they are a number represented by 32 bits (4 bytes).  The Boolean is actually represented by a single byte (0 is false, anything else is a true).

 

But in your case, we are converting a number into a human readable string with a minimum length of 3 characters (3 bytes minimum).  So when you concatenate, your string will be at least 4 bytes in length.

 

And if you don't understand a function even after reading the help, make a small VI and experiment with the function until it makes sense.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 9
(3,420 Views)

@crossrulz wrote:

...

 

And if you don't understand a function even after reading the help, make a small VI and experiment with the function until it makes sense.


There you go!

 

One my early G-daddies told me "If you do not understand a fucntion, try "ctrl-n" ."

 

Ctrl-n is the short cut for "create new VI". One of the strong points of LabVIEW is that it is very easy to run a sub-VI with little effort.

 

Turn on the "ligth bulb" (execution highlighting) is also another goodw ayo to learn LV. When you get to the point where you can predict what you will see in execution highting mode... You will be "getting it".

 

Ben 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 6 of 9
(3,415 Views)

To put my two cents in - another strong point of LabVIEW is the easy creation of a SubVI from a selected part of the block diagram. My favorite way goes like this:

  1. select the interesting part of the code
  2. press Alt+E, S (Edit / Create SubVI)
  3. doubleclick on the newly created SubVI
  4. Input your test-values into the automatically created controls which serve as interface to the SuperVI
  5. Run the SubVI

This makes life easy.

Some additional notes:

  • If this is just for testing, then go back to the SuperVI and make an Undo there, then the SubVI with all the automatically autorouted wires disappear and the original state is back. When you opened the SubVI before, you can keep it.
  • If you want to test a part of your code with a large data set, then run your SuperVI with the SubVI- Frontpanel open. The controls will then keep their data and you can run the SubVI on its own with the real-life data

And another way ist to use the quick-drop feature: select the block-diagram element you want to explore, then press Ctrl+Space, then Ctrl+D. For every unconnected terminal a control or indicator will be created. I often use this with the "Match Pattern" function to test my RegEx.

 

Greets, Dave
Message 7 of 9
(3,384 Views)

@Ben wrote:

@crossrulz wrote:

...

 

And if you don't understand a function even after reading the help, make a small VI and experiment with the function until it makes sense.


There you go!

 

One my early G-daddies told me "If you do not understand a fucntion, try "ctrl-n" ."

 

Ctrl-n is the short cut for "create new VI". One of the strong points of LabVIEW is that it is very easy to run a sub-VI with little effort.

 

Turn on the "ligth bulb" (execution highlighting) is also another goodw ayo to learn LV. When you get to the point where you can predict what you will see in execution highting mode... You will be "getting it".

 

Ben 


Experimenting is one of my favorite ways of learning LabVIEW.  The other way is by coming here and and asking questions.  The OP has already made use of the second way; now it's time to use the first.  🙂

 

Sometimes I will take a new feature in LabVIEW and beat it with a stick until either I tame it, or I decide it's not immediately useful to me.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 9
(3,315 Views)

Appreciate your answers, guys! I can feel that the community is very kind enough to help each other. Cheers!

0 Kudos
Message 9 of 9
(3,297 Views)