09-28-2009 08:24 AM
Hi,
Using my limited experience in Labview I have attempted simulating an alogrithm that we need to test.
The algorithm measures human pulse and breathing in real time, analyses it and provides real time biofeedback to the user.
However as you would notive, in doing that I have made excessive use of local variables and sequence structure.
Thealgorithm superficially consists of one loop that continuously measures pulse and breathing, filters them, processs it and calculates some parametres. The second loop uses these parametres to guide the user sat in front of the laptop screen.
So first loop is continuoulsy gathering data and processing it and second loop is using an array calcated in the first loop to provide some instrctions to the user. This is a biofeedback system and rusn in real time.
As you would see from the VI, I am not using many sub VI's and extensively using local variables to read and write to arrays.
Could you please suggest me what algorithm structure should I use. Now that the code works, I want to improve the way things are done.
My idea is to-
use Sub VI's for each process. Hence a Sub VI for acquistion, a Sub VI for filtering, a few Sub Vi's for processing data and a sub VI for user feedback.
I am not sure of how should I pass data amongst these sub VI's. I could use global variables or clusters (comments/suggestions)
I am not too sure of my current architecture where I have two while loops running at the same time, Is that the best way to incorporate parallel processes?
I have so many questions but am hoping to solve them one by one, possibly starting form suggestions for the main VI architecture and ways of passing data amongst sub VI's.
Note- Pulseread+hrv22.vi si the main VI.
Regards,
Jas
09-28-2009 09:51 AM
Hi Jas
I had a look at your code and it's a bit to large and a bit to complex to get into fast but here are some general things I saw:
1. Yes, you need to create some subVIs. You usually say that all the code in a single VI should be visible without having to scroll.
2. Have a look at an alternate way of transfering data between loops. Queues are one example.
3. Shift registers to save data between iterations
4. Clusters for clustering data and saving on wiring
5. Case structures can decide based on other things that just booleans (integers for instance). Right now in one portion of your code you have 11 case structures and 22 comparisons doing the job of one case structure and a singel comparison.
Hope this gets you started
Best Regards
David
NISW
09-29-2009 06:22 AM - edited 09-29-2009 06:23 AM
Hi David,
I had though about that earlier butcouldn't find an alternative. Let me put it separately here so that others can understand.
I am using a set of rules to calculate a parameter called Guided_breathing based on a parameter called RSA_breathing which is calculated real time
Based on the value of former at the red dot, the case structures determine what value to store at Guided_breathing.
So if RSA_breathing is in the range 9 to 8, use 8
if RSA_breathing is in the range 8 to 7, use 7 and so on.
Is there a way to better implement this logic than the way I have used here using multiple case strucutre.
09-29-2009 07:15 AM
Hi
You can actually replace the eleven case structures by only one.
Here is an example that can help:
http://decibel.ni.com/content/docs/DOC-6293
09-29-2009 07:19 AM
09-29-2009 07:22 AM
09-29-2009 07:35 AM
Hi Jas,
I would just like to add that the NI Example Finder is very good for showing examples on how to use certain code, such as Queues, as recommended by David. To open the NI Example Finder, go to Help -> Find Examples. Then you can go to the Search tab -> type a keyword such as queues -> double click keyword -> double click example.
I hope the Example Finder is of use to you and others, it's a great resource for both new users and more experienced programmers.
Regards,
Imtiaz Chowdhury
Project Manager
Green Running / Austin Consultants
09-29-2009 07:42 AM - edited 09-29-2009 07:43 AM
Hi Guetter,
I would love to use Labview 2009, but am still on 8.6 😞
Jas
09-29-2009 07:46 AM
Hi Jas,
Here's the example code that Guetteur pointed to converted to LabVIEW 8.6 version.
Regards,
Imtiaz Chowdhury
Project Manager
Green Running / Austin Consultants
09-29-2009 09:48 AM - edited 09-29-2009 09:50 AM
Hi Jas
In you case the code could look something like this:
Best Regards
David