LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Concatenate series of chars

Solved!
Go to solution

Hi,

 

I need a function to concatenate a series of chars. 

The string concatenate function doesn't work because I have only one input, like I said it is a series of chars...

 

I want something like !-R-1-0-V-5-0-$-\n to become something like !R10V50$\n

I already tried to do a for loop with shift registers but there's another problem, I don't know how many chars it will be, I want it to stop when it finds a \n char

 

Do I have to worry about timing?

 

Thanks

 

0 Kudos
Message 1 of 24
(3,622 Views)

What exactly do you mean by "a series of characters"?  Is it a 1-D array of strings?

 

You can wire a 1-D array of strings into the concatenate function.  It will concatenate all the elements end to end give you a string as the output.

 

There is no reason why using a shift register and loops would not work.  Please post your existing code so we can help you with that.

 

I don't understand your question about timing or what it has to do with concatenating characters.

0 Kudos
Message 2 of 24
(3,620 Views)

Basically I have an asynchronous communication. The sender sends the chars and in Labview I have to put them together. 

The loop won't work (the way I thought) because I don't know the number of chars that will be sent.

 

The timing question is about being asynchronous, but forget it 😉

 

Thanks

0 Kudos
Message 3 of 24
(3,616 Views)

I don't see where you attempted to use a shift register.

 

If you want the Serial read to stop on the new line character, then you need to enable the termination character.  There is no need to redefine the termination character on every loop iteration since it is defined in the Serial Configure function.

 

You will also need to put some wait statement in your loop otherwise it will run as fast as it can.

 

Your VI doesn't show what you want to do with the data after you get it.  Normally, if you are using the termination character, then the bytes at port method is the wrong way to go.  Just enable the termination character and put in a sufficiently large number of bytes to read in your VISA Read, greater than the length of any message you expect to get.  The VISA read will terminate when it sees the termination character, reads the requested number of bytes, or hits the timeout value, whichever occurs first.

 

Message 4 of 24
(3,614 Views)

Thanks for your answer I can see it is better now.

 

Now I can scan the string, but now there are 2 problems. 

I can scan it as I should, only some values, seems to be a problem with the comma. And it is scaning it from the 1st value, not refreshing it. 

 

I'll send the .VI and a picture

Download All
0 Kudos
Message 5 of 24
(3,607 Views)

You didn't use the VI that I attached in the snippet.  I listed a few things you needed to fix in the program.

 

I don't know what you mean by "scanning from the 1st value, not refreshing it".

 

And I don't see a comma in your data, so I don't know what problem you are having.  Are you using some European system where the decimal point is not a period but is using a comma?  If that is what you mean, then you need to fix your OS settings or adjust the way the functions inteprets the decimal point.

0 Kudos
Message 6 of 24
(3,604 Views)

I'm using a period for decimal numbers. Sorry for the mistake.

 

As you can see in the attached picture of the last post, the scanned value is from the 1st read string. It's marked with a circle.

 

I changed a bit the VI according to my needs.

 

0 Kudos
Message 7 of 24
(3,599 Views)

Because you were building all the string data into a single string, the string functions were just acting on the data as you were presenting it, which means it will start at the beginning of the string.

 

Try this.

 

0 Kudos
Message 8 of 24
(3,598 Views)

That doesn't work, simply because of the 1st question I asked. The visa reader is getting each char at a time, I have to put it all together and then analyze it.

 

 

 

0 Kudos
Message 9 of 24
(3,593 Views)

You're getting one char at a time due to serial configuration. Set it up like suggested and you'll read it all at once.

If you for some reason want to read it one at a time, then you'll have to use shift register, concatenate string and a case.

/Y 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 24
(3,583 Views)