Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Parsing serial data into different sets

Hello i am continously sampling data from the ADC on my micro the format my data is sending is as followed

 

$1,2,3,...................,$GPStime,$

 

i have a dollars sign at the beginning of the adc values and a dollar sign at the beginning of time and commas. I use the scan from string to separate the two but i get the following error.

 

Possible reason(s):
 
"LabVIEW:  An input parameter is invalid. For example if the input is a path, the path might contain a character not allowed by the OS such as ? or @."
 
 I dont understand why i am sending straight ascii values, When i send just one type the spreadsheet string to array works just fine but i obvuously cant use that for different types. Please see attached of code and block diagram. I would greatly appreciate comments.
Download All
0 Kudos
Message 1 of 13
(5,601 Views)

A more exact example of your read string and what you expect as the output would help a lot here.

 

The $ make no sense.  Just use comma seperation and then end the message with a carriage return (0xA).  Then you just tell the VISA Read to read a really large number of bytes (more than your message) and it will stop reading when that CR is encountered.  This makes sure you have a complete message.  From there, you can use all kinds of tools to parse the string depending on the data in it.  Again, we need a more precise string to help you more there.


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
0 Kudos
Message 2 of 13
(5,595 Views)

okay the data is voltage values and time from a GPS  reciever and it continuously sends data for as long as my micro is sampling the voltage and once i parse the data i expect the put the two into a build waveform the "t0" and "y". I am trying to get a phase angle and timestamp the data with gps. So the $ sign is there so to start the serial transmisson of the data and also cause the buffer sends 512 numbers at a time and $ indicates every 512 numbers and the $ for the time stamp works the same. It separate the two as well. t\Take a look at the read buffer of the visa read. You can see at the bottom of the picture the $ sign that indicates the time after and then on the next picture of read buffer another $ that indicates the voltages values after the time. I tried to use the scan from string to do that but i get errors and it doesnt work. I also tried the termination character on visa to catch every $ sign

0 Kudos
Message 3 of 13
(5,569 Views)
You've been told about the asynchronous nature of your communication. It appears you've chosen to ignore that and the given advice.
0 Kudos
Message 4 of 13
(5,543 Views)


That is not my problem i am able sync cause i am sending a byte to signal the beginning of the buffer which is $, and same with time, everything runs fine when i dont include the time so i know my program works. My problem is  when i include the time, I just want to know what might work so i can separte the time and voltage in the data string. and also catch every $.  used the termination character on visa it works just with the adc values but not when i add the time.

0 Kudos
Message 5 of 13
(5,536 Views)
Since you are using the same termination, you DON'T know if the received byte is part of the amplitude stream or the time. Did you modify the sketch and VI to send data with specific requests? You could also append the time to your amplitude stream. Either as the first or last byte. Separate them with specific writes or include both. Up to you.
0 Kudos
Message 6 of 13
(5,523 Views)

I could change the time haracter to !. And no the data just comes as one string and and the time is after the voltage values but still one string so I tired to use the string scan function but I get error is there another function that could possible separate them cause I tried a few and no luck or what approach could I take 

0 Kudos
Message 7 of 13
(5,513 Views)
No, don't change the character. Send a1,a2,a3,...a512,t<LF>. You would use the Spreadsheet String to Array and then just index out the timestamp.
0 Kudos
Message 8 of 13
(5,510 Views)

what does t<LP> mean and also as you said, this is what coming

 

$a1,a2,....a512,$time,$a1,a2,...a512 and so forth alternating between the too and the termination character on visa would catch $ for both but when i use "split 1 d array" im not sure what index i would put to get time cause the termination character is starting the set over and over again and then how to transforming the time to time format to send to build waveform.

0 Kudos
Message 9 of 13
(5,500 Views)
Should have been LF for line feed.

No. As you describe it, the data alternates and I'm saying just tack the timestamp onto the end of your amplitude string. One string with no $ and a lf at the end. Finding the last element on an array is trivial. You are the one who said you have 512 amplitude values. One more means 513, correct? You also have the Array Size function.

0 Kudos
Message 10 of 13
(5,489 Views)