Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Receive and analyze strings from VISA

Hi,

 

I'm new to LabVIEW and I have now a problem looking for solution.

I have an interface in LabVIEW communicating with a microcontroller with VISA (through RS232). So I'm sending a string from the microcontroller and receiving it in LabVIEW. That's fine until now. 

 

Now I have no analyze that string, the string is something like "!13R45.965V0.220$  1" and I want to get those values in different indicators. I tried scan from string already and it doesn't work. The problem is relatively simple, LabVIEW doesn't see the entire string, it sees it char by char. 

So what I want is a function that builds a string from those chars in the input.

 

 

0 Kudos
Message 1 of 10
(4,204 Views)

LabVIEW's Scan From String sees whatever string you send to it. If you are sending it a single character, then that would be a fault of the way you've written your program. Simply saying it does not work does not really help explain your problem. How exactly do you want that string formatted?

0 Kudos
Message 2 of 10
(4,199 Views)

Basically what I want is to concatenate incoming chars into a string. But the number of chars is variable.

0 Kudos
Message 3 of 10
(4,188 Views)

The concatenate string function is available in the string palette

greetings from the Netherlands
0 Kudos
Message 4 of 10
(4,185 Views)

yes, but I have only 1 input

0 Kudos
Message 5 of 10
(4,181 Views)

@Baioneta wrote:

Basically what I want is to concatenate incoming chars into a string. But the number of chars is variable.


That's a basic operation with a loop and a shift register for the concantanate function. You should attach your code. With serial, it's easy to know how many characters to read or how to stop a loop with the read in it.

0 Kudos
Message 6 of 10
(4,179 Views)

Here it is.

 

the code to print it through the port is

 

 

void transmite(char c)
{
while(!TRMT); 		//waits if the transmitter is busy
TXREG=c;} 		//sends char c

void imprim(char *texto){
index=0; 
while(texto[index]!=0) transmite(texto[index++]);} //Sends the chars untill it finds a null char

 

 

 

0 Kudos
Message 7 of 10
(4,177 Views)

Your wiring is sloppy and you should use a shift register instead of a local variable but you should be getting the complete string now.

0 Kudos
Message 8 of 10
(4,174 Views)

Smiley LOL I'm new to LabVIEW Smiley LOL

I used the local variable because I want my output to show all the last data, to do it with the shift registers I'd have to add a lot of shift registers, right?

 

 

0 Kudos
Message 9 of 10
(4,171 Views)

ok, I guess I figured out what I have to do. Now I have just one more problem. The "for" loop runs even if there's no new char. 

I'm thinking about creating a delay to do some sort of synchronization.

The changes are in the new .vi

0 Kudos
Message 10 of 10
(4,167 Views)