LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

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

Hi guys,

I send from pic16f877 3 readings of hex number, from 3 sensors.
The pic send 3 readings, but the moment of send is when the pic finish the count of first sensor, its frequency of flywheel, and if turn at 50hz then the pic send when know the number of cycles in us, and the readings of other sensors.

I got see the readings in string, The problem is i want the values in decimal way.
And like i know, already i am testing wave generator at 50hz and the other sensors off.
The correct readings is 4E00, 0,0. i get noise in the third sensor and get any low numbers... but the problem is when i put in decimal way the program only show the first digit ---> 4E00 the program get 4E = 78, 00 = 0, but it is 4E00 = 19968 =50.08hz.

Another problem is, the serial take only 2 digits, and sometimes show 154E or 004E, moving the data, or show 0,0,4E00... When i need the first value the freq 4e00 and later 0 and later 0. This values separates in arrays. I need the data is not moving..

I attached the vi and capture.
Any help will be very grateful for me...
0 Kudos
Message 1 of 57
(6,567 Views)
0 Kudos
Message 2 of 57
(6,559 Views)
Seems that you have several problems here.
1/ see in the attached vi how to convert a string to an array of U16 data.
2/ you also have an alignement problem : your data begin with a zero byte, and then you get
484E 0000 0000
454E 0000 0000
464E 0000 0000
etc...
The bytes are in reverse order.

The attached vi do not solve the alignement problem, and you still have to find a way of synchronizing the readings with the emission...

Hope this helps...

CC
Chilly Charly    (aka CC)
Message 3 of 57
(6,549 Views)
Hi CC,

Thank you very much!!, is works.

About the alignement problem, synchronizing the readings , i forgot comment, the pic send in the start one sync values. send ffff,ffff,ffff each 240 readings.
Then i MUST to adjut the vi to wait the FFFF,FFFF,FFFF and start with the correct synchronitation. Then all the values will be perfect.
I only need that!! but i dont know how adjust it in the code.

Can you help me?.
The idea is vi, wait until bytes sinc. and start with the correct position of readigns.
The pic send the same bytes each 240 readings of 3 sensors.

Regards.
0 Kudos
Message 4 of 57
(6,547 Views)

Fonsi wrote:...The idea is vi, wait until bytes sinc. and start with the correct position of readigns.
The pic send the same bytes each 240 readings of 3 sensors.
Try to read in a loop (by chunks of 6 bytes) all the bytes coming out of the serial link, and search for the FFFFFFFFFFFF pattern. Then concatenate the possible bytes left after the pattern with the following bytes, to get your 240 x 3 x 2 string.
Have a look at the attached vi. No garantee that it will work, but the basic idea is there.

CC
Chilly Charly    (aka CC)
Message 5 of 57
(6,525 Views)
Hi CC,

Thanks for your help!.

The idea is only wait to the first FFFF,FFFF,FFFF. And later get all the readings since will be save well, the rest of bytes sinc. i will delete with easy for loop...

I did some changes, and it runs but sometimes fail, since the sync sometimes is with value in the final byte, which is very strange, since pic send this value fixed, maybe is noise, the i.e FFFF,FFFF,FF56.

Other thing is i need the data directly to draw in the any graph, i must to read 6bytes and draw it, and this vi read values until you close the loop...

If you know any way easier tell me....

Regards,Fonsi.
0 Kudos
Message 6 of 57
(6,515 Views)

@Fonsi wrote:
The idea is only wait to the first FFFF,FFFF,FFFF. And later get all the readings since will be save well, the rest of bytes sinc. i will delete with easy for loop...
I did some changes, and it runs but sometimes fail, since the sync sometimes is with value in the final byte, which is very strange, since pic send this value fixed, maybe is noise, the i.e FFFF,FFFF,FF56.
Other thing is i need the data directly to draw in the any graph, i must to read 6bytes and draw it, and this vi read values until you close the loop...


You should maintain the synchro loop after reading a series of data bytes, alternating synchro on 6 bytes and acquisition of the 240x3x2 bytes : if any byte was lost, for one reason or the other, then, without resynchronizing, you would loose definitively all the incoming data. The series of FFFF FFFF FF56 is exactly that : one byte was missed, and the last 56 value probably belong to the following set of data !..
There is probably a better way of re-synchronisation : looking for the last FFFF of a longer series of FFFF's. As it stand in my last proposal, when a byte is lost, all the following data are garbage, then you will not be able to synchronize on the first series of FF's since the first one will be already imbedded in the data field, and you will have to wait until all the data byte chunk has been passed again.
Provisionnaly, I suggest you only read 239 values.
Plotting to a graph should not be a problem : do the data acquisition in a for loop, as I did for the synchro, reading only 6 bytes in a row, 240 times, and send the values (a single M1, M2, M3) to 3 waveform charts, without further processing. That should do the job...

CC
Chilly Charly    (aka CC)
Message 7 of 57
(6,508 Views)
Hi CC,

Your vi works perfect!, the data is perfect and i get the synchro well.
But is not valid to my application. Since I need send the 3 readings in real time directly to graph and use the data to some calculates to get curve graph.
Other problem is, With this vi, the freq always is the same until finish the 240data, and in real life the freq will be vary all the time, Thats why i need the vi read the 3 sensors, and send to calculate and read again... send to the graphs or formulates, and again....so all the time.
If the data start correct, i dont know why the vi can to loss the good position of data.... i would like it read and send, read and send...

I would like to know if its possible. In theory, if i start the correct way in the start, i could to acquiere the data correct way, until the next synchro bytes.

Also, i dont get, save the values, since i only get save the last values in the loop, i would like save all the values from each loop number...

Any advise or idea?
0 Kudos
Message 8 of 57
(6,493 Views)
0 Kudos
Message 9 of 57
(6,492 Views)
Hi CC and guys,

I got to adjust the file to read 6 bytes to bytes...
I put one 'For loop' 240 times, and use if/else to adjust only remove any byte later of sync. bytes, only in the first time, the rest 239.. read directly, it runs ok, only when missing bytes do this data corrupte and the later readings too until arrive to the next synchro. bytes, when arrive the synchro start well again...

I have 2 problems.

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!!. Can you help me with the adjust of vi?. I need search the string at False loop, when read directly, remove the 0A and the next 5 bytes...

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.

Can you help me with this adjustement?.
Thanks for all!.
Regards.
0 Kudos
Message 10 of 57
(6,469 Views)