09-04-2012 11:35 PM
Please post any code in 2009 version.
09-04-2012 11:40 PM
Please do not rely on sequence structures to implement code like this. Learn uhow to use state machines. They are much more flexible and easier to maintain.
09-05-2012 03:33 AM
Hi Freelance,
Thank you so much for uploading the code. I think it is very close to what I am looking for.
However, I want to explain my problem in bit more detail. Please refer to attached image.
Basically, during cuff inflation (rising plot), I calculate a ratio R and based on R, I calculate a time T_RUN in seconds. T_RUN changes from individual to individual.
Based on T_RUN, I want to operate my motorized pressure valve. So, for example, I start taking somebody's blood pressure by inflating the cuff. I find in real-time that their T_RUN is 1.66 seconds. So for them, my motorized valve should be operated for 1.66 seconds only, to create appropriate permanent leakage in the system. For another person this time may be 2.33 seconds and for them the pressure valve should run for 2.33 seconds.
The code you uploaded, sends data from Loop 1 to Loop 2 and runs Loop 2 for a fixed time interval, which is excellent. But I want to send T_RUN data (time data) from Loop 1 to Loop 2 and run Loop 2 exactly for T_RUN seconds for supplying voltage to my pressure release valve.
Thank you all for your continued support. I really appreciate it!
Cheers,
Saif
09-05-2012 05:15 AM
Hi
If you want to send the data, wire the data to the queue element. if you want to send T_RUN, wire that value. however you process it.
I had only given you an idea of how to make parallel loops pass data from one to another.
You have to improve on that code, to pass T_RUN, or pressure or whatever parameter you want to pass. Use an array as the queue element if you have more data to be passed. the queue element could be any type of data, but you will have to define it when you obtain the queue.
Read more about Queues and Producer Consumer architecture on the NI webstie.
Coming to supplying output for 1.33 seconds/2.33 seconds, you will have to use either a timed loop (i have never used a timed while loop and not sure if this would meet your requirement) or go for real time daq modules. i am not sure if you can precisely stop the generation after 1.33 seconds or any such fraction.
09-05-2012 05:20 AM
that brings out a question:
what is the hardware you are using? post your updated code.
09-05-2012 07:54 AM
Thank you so much Freelance!
Will try what you suggested and post the updated code.
I am using NI9263 and NI9239 on a 8-slot NI cDAQ 9172 USB Chassis.
Cheers,
Saif
09-05-2012 09:29 AM
When using messaging bewteen loops I generally prefer to use a generic data type. More often that not I have a cluster which contains a message type (can be ENUM or string) and a variant. By using the generic cluster different messages can have different data. Some may have no data at all. This type of messaging scheme is very flexible and easy to extend. Only the sender and receiver of a specific message need to know how to interpret the data portion of the message. If you define a very specific data type for the message it makes it very difficult to extend.
09-05-2012 11:30 PM
Hello Mark
I would generally use the generic cluster in my applications. However, for explaining things here, i put in a sample code which, i believed, could be better for a start.
Thank you
09-06-2012 02:09 PM
@Freelance LV wrote:
Hello Mark
I would generally use the generic cluster in my applications. However, for explaining things here, i put in a sample code which, i believed, could be better for a start.
Thank you
Understood. But it is useful when teaching folks to show them proven and accepted methods for doing these types of things. We can save a new person some pain by giving the more robust solution.
09-09-2012 03:54 AM
Hi All,
As you advised, I am now trying to have a Timed Loop in parallel with my main loop. From the main loop I am sending a crisp value out, for example, 3.5 s means send voltage to my device for 3.5 seconds.
I am struggling a bit with wiring the Timed Loop as its structure is slightly different. Basically, I want the timed loop to run for the time specified in the main loop.
Please see my code attached code. Any help would be much appreciated!
Cheers,
Saif