LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stop Button is not working in Loop | General Question about data visualization, parallel loop & data logging

Solved!
Go to solution

Dear Community members, 

 

I am using this code to control a heater. The code works fine and serves my purpose. However, the problem is the stop button doesn't work. I want to use one stop button to stop the entire program, however, in my program it doesn't work. I feel I have not placed the stop button in right place but I can not figure out how to fix this. Any other suggestions regarding the code will also be appreciated.

 

I have further more questions about programming approaches. Any lead will be helpful.

a. I want to use Write to spreadsheet function to get data into excel files from the shift registers I used in the inner loop of the code. Is there a better way to do it? I plan to acquire data for 7 days at 2Hz sample rate. 

b. Can I do active logging in labview? So that in case the pc crashes, I still have the data. 

c. I have 6 more devices like the heater such as different kind of sensors and gas analyzer. I tested those on labview and those works fine separately. Now my plan is to integrate all of them to run simultaneously and acquire/log data for 7 days at 2Hz sample rate. Should I integrate everything into the loop with this one(heater) and run simultaneously? or there is a better way to do it?

d. If I want different sample rate for each of the devices, should I have separate while loop for each of the devices and run simultaneously?

 

 

I am not an expert in labview. However, I am willing to learn. Any help would be appreciated. 

 

Thanks.

0 Kudos
Message 1 of 6
(731 Views)
Solution
Accepted by topic author Jarir

the inner loop does not stop when you press the button because it is not wired to the stop condition. Add another OR and wire it in.

(I have not studies the rest of the code, but it seems a bit convoluted. 😉 )

0 Kudos
Message 2 of 6
(698 Views)
Solution
Accepted by topic author Jarir

Stop trying to do everything in one big loop (OBL)

 

Before you try to band-aid in logging learn about simple state machine architecture. 

 

Possible states are

  1. Initialize
  2. Measure
  3. Display measurements 
  4. Control (adjust your heater)
  5. Log measurements  
  6. Error
  7. Exit

Your program will probably spend most of its time in the measure, display, and control state. Then you can goto the log state what it's time to log.

The error state and be combined with the Exit sate to properly shut things down on error or user stop. 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 3 of 6
(652 Views)

Do you think a producer consumer design pattern will be more appropriate for this case? I have no experience working with state machine. I tried to dig in and get some knowledge on this. But no luck so far.

0 Kudos
Message 4 of 6
(630 Views)

@Jarir wrote:

Do you think a producer consumer design pattern will be more appropriate for this case? I have no experience working with state machine. I tried to dig in and get some knowledge on this. But no luck so far.


Sure but one if not both loops in a Producer/Consumer is usually contain State machines, at least mine always seem to... 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 5 of 6
(606 Views)

I think there are tutorials to learn about state machine. A consumer and product er + state machine will give you a lot of confidence when it comes to programming with LabVIEW. So I will encourage to keep learning how to use state machine. Don’t give up. I will take a look at your code.

0 Kudos
Message 6 of 6
(589 Views)