02-11-2013 09:19 PM - edited 02-11-2013 09:37 PM
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
Solved! Go to Solution.
02-11-2013 11:12 PM
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.
02-11-2013 11:27 PM
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,
02-12-2013 12:19 AM
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.
02-12-2013 12:42 PM - edited 02-12-2013 12:43 PM
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.
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
02-12-2013 01:00 PM
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.
02-12-2013 01:16 PM
Here is an example similar to what Dennis recommended.
Lynn
02-12-2013 01:17 PM
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
02-12-2013 01:23 PM
Look up "shift register". Here are a couple of possibilities:
02-12-2013 01:26 PM
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.