LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

problem interpretation of data from serial data.... help please!

0 Kudos
Message 11 of 57
(1,934 Views)

@Fonsi wrote:
1- If you look at the capture, In the bytes read, one of the readings is 0A, always when get bad readings appear only 0A. If i could to remove this byte and the next 5 bytes the data will be perfect!!.
Even simpler : just put a boolean false on the "enable termination char" input on the VISA Configure serial port vi ! $OA is the ASCII equivalent of LineFeed... Desynchronization could occur if there is any random noise during the data transmission. You should never suppose that the transmission is "perfect", and always keep a way of maintaining synchrony. May be the 240 data are not sent as a continuous stream, but with a small delay between the series of 6 bytes ? Such a delay could be tracked as a mean to maintain synchrony. Another method is to check the correctness of the data. Since you know the possible value range of your readings, you could check if the series of 3 readings is correct, and if not, try to re-allign the data by shifting bytes until the readings seem correct again.


2-Sencod error is, i cant use this data until pass 240 readings. I would like to use this data each reading. For that i need remove the 'case structure', and put while loop or another structure. But i'm not able to get it.
Two solutions :
1/ put all the post-reading processing operations in the same loop as the serial readings !
2/ pass the readings to a queue, and read the queue in a parallel while loop where you can process the data. There are shipping examples explaining how out to use queues in LV.

CC
Chilly Charly    (aka CC)
Message 12 of 57
(1,921 Views)
Hi CC,

Thank you very much!!.

The problem 1 is solved!, I put a boolean false on the "enable termination char" input on the VISA Configure serial port vi, and the data is perfect, i know is possible i loss any byte or timing, right now is perfect, with generator wave, not error, only get error if in the start get values in the midle of the serial 240 data, but when arrive at the sync bytes, start perfect.! good!.

The second problem, i dont know. what?.

Two solutions :
1/ put all the post-reading processing operations in the same loop as the serial readings !
2/ pass the readings to a queue, and read the queue in a parallel while loop where you can process the data. There are shipping examples explaining how out to use queues in LV.


I dont understand, i would like to see any example. 1 option.
and the second option too, any example.

thanks for all, the more important works great, i dont know on serial port, and help me a lot to my application.
Regards.
0 Kudos
Message 13 of 57
(1,910 Views)
if you can show any option in my vi, will be perfect!.

I will use this vi inside other main vi. I will push 'start' and i want it read the serial data and go to sending the 6 bytes to the output of this vi and use this data in my math calculates and show in graphs... Thats why i need read each time the vi read 6 bytes...

Regards
0 Kudos
Message 14 of 57
(1,904 Views)
I have tried to demonstrate both options.
I made some mods to your vi, to imbed a graph display in serial read loop.
Then I also added a queue : each new value read on the serial port is added to the queue, while in a parallel loop, each new value is dequeued and dispalyed in a graph.
Also attached is a small example vi that illustrate the queues properties.

Hope this helps

CC

Message Edited by chilly charly on 03-25-2005 12:47 PM

Chilly Charly    (aka CC)
Message 15 of 57
(1,887 Views)
Hi CC,

Thanks for the vis....

But i dont get use it well. I need use this vi like subvi, then i need the vi send the each readings of 3 sensors outsite, and can read each sensor doing any calculates and show in different graphs...

I need send the 3 sensors to the queue, i only got to put one sensor, and with the output of vi the 3 readings to use in the main vi...

Can you help me?. what is the problem?.
Regards.

files
0 Kudos
Message 16 of 57
(1,875 Views)
The problem is that the structure of the read serial vi is not appropriate. You won't be able to use it as a sub-vi unless you modify it deeply.
I think you misused the queue idea. Think of a queue as a pipe. Some parts of your program just input data at one end, while other parts remotrieve data from the other end. Of course if nothing is fed in, nothing can be removed at the other end, and the program just wait. If the feed rate is larger than the removal rate, the pipe "inflate" until it reaches the limit size imposed by the Max queue size parameter (or by the computer memory !). You may have several inlet points and several outlets.

Attached is a possible solution to your problem, far from optimum, since the serial read vi never stops. I have removed most of the indicators from the serial read, since they will be read outside, in the main. Without your instrument, there is n o way I could test it. So if it does not work you'll have to figure it.

By the way, I don't understand why you have added a case structure in the central serial read loop. Is it really necessary ?

CC

Message Edited by chilly charly on 03-29-2005 02:12 AM

Chilly Charly    (aka CC)
Download All
Message 17 of 57
(1,861 Views)
just a correction...

Message Edited by chilly charly on 03-29-2005 02:40 AM

Chilly Charly    (aka CC)
Message 18 of 57
(1,857 Views)
Hi CC,

Thanks, the vis runs ok!.

You are right on the case structure, with the condicional option is enough to remove any byte only in the first reading of serial 240...

It runs, but why it doesnt stop?. With low timeout the vi should to stop... but it continues running... how i can stop it?. i suppose exist any option to stop the vi.

Best regards.
0 Kudos
Message 19 of 57
(1,846 Views)

Fonsi wrote:It runs, but why it doesnt stop?. With low timeout the vi should stop... but it continues running... how i can stop it?. i suppose exist any option to stop the vi.

You are right : the read serial vi should stop if there is nothing arriving on the line during 10 seconds (that's what you introduced at initialisation). Otherwise, you could also stop it using a global variable (the simplest even if not not the most elegant...). There are other methods such as passing a reference of the stop button to the read serial, and reading the value of the button in the read serial vi using a property node, or using a functionnal global (search the Discussion forum for these methods, it is a recurent subject...)

Hope this helps !

CC
Chilly Charly    (aka CC)
Message 20 of 57
(1,842 Views)