LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read Streaming byte array

Solved!
Go to solution

Hello there:

 

Could anyone trhough me some light, how could I impliment three lines of  code into Labview?

I have a pulse oximetry sensor conncected to Labview via VISA serial port. Communication is fine, and I do read 5 bytes successfully. 

However, every cycle, the context of 3rd byte changes. Question is how can I build an array within the while (main) loop, which would pass the value of the 3th byte into an other array. 

 

Byte0 | Byte1 | Byte2 | Byte 3|  Byte4

# of sample1    1         255      255       100      255

# of sample2    1         255      255        50      255

# of sample3    1         255      255        98      255

 

The sensor sends 25 pakets of 5bytes, three times per second. 

The Streaming variable could represent 1D table consists of 25 values of Byte#3.  

Then the rest of algorithm would go over that spidific array, print the third value. 

 

For ( i=0; i<=25; i++) 

{

InByte[i]= Streaming value;}

 

Serial.print("inByte[# of preferred byte to be printed]");

 

Could anyone recommend a proper approch rather arrays? or that is the right path to take?

I have attached the datasheet of the sensor page7 explaines data strucutre in detail. 

Any help would be appreciated. 

 

K.D

Download All
0 Kudos
Message 1 of 15
(6,909 Views)

Try this approach. I think this is same array then try this otherwise pass different array.

 

This code will tell you how to make array of 3rd element inside while loop only.

 

Tell me one more thing, When actally you want to plot the grahp of 3rd data i.e. simultanously as soon as data read from serai port or after completion of read operation.

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 2 of 15
(6,888 Views)

Hey Ranjeet:

 

My machine runs labview 9, can you save the file into previous version?

I would plot the 3rd data in real time, as the data being read from the serial. Or that is what I aim to do.

 

Cheers,

0 Kudos
Message 3 of 15
(6,881 Views)

Then why you want to build array of 3rd data. If so then why cant you put the graph inside while loop only as you did already.

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 4 of 15
(6,870 Views)

By 3rd byte, I mean the forth elemet of the incoming data from buffer. 

The reason that I want to make a 2D array is that, the 4th elemet changes at each cycle. and it represents different type of information.bytes.png

I want to distiguish the Spo2 and HR MSB and HR LSB from the streaming data. 

For instance, each time while runs the value of Byte#4 changes, only samples #3 and #16  of that Byte, would be desired to be saved into an 1D array. 

I am suprised how hard the arrays are in the labview, cpmparing to c. It is been two days and I still strugle with three lines of code. 

 

Do you think that I should pass the contect of Byte#4 into an other loop and save them into an array? Could that solve my problem?

 

Thanks by the way for the efort and converting the file.

Cheers

 

0 Kudos
Message 5 of 15
(6,850 Views)

I don't quite understand your problem. You are taking extra code to extract the byte you want. You simply need to use the Index Array function on the byte array. No need to convert to a cluster and then to another array. Take the elements you want and just wire them to a Build Array. If you want a 2D array inside the loop, the simplest is with a shift register and the Build Array function. If you want it after the while loop finishes, you wire the 1D to the while loop's edge and right click and select 'Enable Indexing'. The wire that exits will be a 2D array.

0 Kudos
Message 6 of 15
(6,843 Views)
Solution
Accepted by topic author kiandr

Here is an example similar to what Dennis recommended.

 

Lynn

0 Kudos
Message 7 of 15
(6,836 Views)

Hi Dennis:

 

Could you give me a sktch of what you are talking about. I imagin that would be understandable for someone who had mastered Labview, but it is less undrestanding for amature laview user, who think in coding manner, with not enough visualization skill. 

 

Cheers.

KD

 

0 Kudos
Message 8 of 15
(6,835 Views)

Look up "shift register". Here are a couple of possibilities:

Nonin_AVI_alternatives_BD.png

0 Kudos
Message 9 of 15
(6,825 Views)

John, Dennis and Ranjeet:

 

That looks the proper approch, I will work on that solution. Should be the perfect solution, so fare. 

My supervisor, just came to my office asking for the report.You guys just saved me  days of work. 

 

Thank you.   

0 Kudos
Message 10 of 15
(6,823 Views)