LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to send voltage to a device for a few seconds (1-5 s) while the main program keep running?

Please post any code in 2009 version.

-----

The best solution is the one you find it by yourself
0 Kudos
Message 11 of 25
(1,194 Views)

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.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 12 of 25
(1,190 Views)

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

0 Kudos
Message 13 of 25
(1,180 Views)

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.

 

 

Regards
Freelance_LV
TestAutomation Consultant
0 Kudos
Message 14 of 25
(1,163 Views)

that brings out a question:

 

what is the hardware you are using? post your updated code.

Regards
Freelance_LV
TestAutomation Consultant
0 Kudos
Message 15 of 25
(1,159 Views)

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

 

 

0 Kudos
Message 16 of 25
(1,152 Views)

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.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 17 of 25
(1,136 Views)

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

Regards
Freelance_LV
TestAutomation Consultant
0 Kudos
Message 18 of 25
(1,120 Views)

@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.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 19 of 25
(1,109 Views)

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 

0 Kudos
Message 20 of 25
(1,094 Views)