Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Led always on when I stop my loop

Solved!
Go to solution

 Dear All,

Now I used NI-6008 when I used case structure to program via digital output. It 's can turn on and off. But when I tried to turn On and then push stop button to while loop.The Led that I connect to is still on when I stop my program. How can I turn off this led when I stop my program?

 

Thanks

0 Kudos
Message 1 of 15
(5,128 Views)

Use a proper state machine architecture and turn the LED off as a last step before the loop stops. If you want more detailed advice, show us your code.

Message 2 of 15
(5,125 Views)

As this image I can turn and off but if I turn on then I stop loop.The led should not be alway turn on. But it still turn on.  Daq Assistant 2 is Digital output. Daq Analog in for compare. 

Many Thanks

0 Kudos
Message 3 of 15
(5,119 Views)

Your image is useless to show the problem. It is just a truncated picture and we don't even see where the loop condition is and how it is wired.

What is preventing you from attaching the actual VI?

 

 

0 Kudos
Message 4 of 15
(5,111 Views)

As the attachment file I need to set the data as default or (booloean 2) if I press the button stop please help

0 Kudos
Message 5 of 15
(5,102 Views)
Solution
Accepted by topic author Chairat

1. Your outter loop is not needed at all.

2. You have a lot of duplicate logic.  If you are not above your threshold, of course you will be less than it.  So you can do a lot to reduce your logic.

3. Things will make a lot more sense if you convert your DAQ data to a scaler immediately after the DAQ Assistant.

4. Move your writing of the digital output to outside of the case structure.  Also allow the timer to affect the case that is called.  This way, you can tell the output to just go to FALSE when your loop stop condition is encountered.

5. Since you are only gathering 1 analog value at a time, change your graph to be a chart.  A chart has a history built into it, which I'm sure you would like to have.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 15
(5,081 Views)

@Chairat wrote:

As the attachment file I need to set the data as default or (booloean 2) if I press the button stop please help


Sorry, it was way after midnight for me when you finally posted your code, but it seems that Tim already told you the gist of it all. 😄

 

There are a few more things that should be mentioned.

  • Do you really think it is necessary to check the elapsed time every nanosecond, as fast as the computer allows? All your toplevel loops need a small wait, especially if no hardware IO occurs.
  • Before attaching code, you should enter reasonable typical vaues for all the controls and make them the default before saving. Two time thresholds of zero make little sense.
  • Yes, the outer loop is useless because it never executes more than once. What is the purpose of the second inner loop? Just seems to pump hot air as fast as the computer allows.
  • Since the two loops have independent timeouts, one loop can end while the oter keeps on going. The loops can only restart after both loops terminate. Do you really want states like that?
  • Instead of your formula express VI that hides everything from the programmer, just use an expression node. Makes the code much more readable.
  • Give all your controls and indicators reasonable names that relate to their function. Names like "Numeric 3"  or "Numeric 4" are not useful.
  • You can resize all your express VIs so the unused terminals don't show.
  • Since you are taking single readings, it would make more sense to use charts instead of graphs.
  • Please pan the front panel so the important parts are in view.
0 Kudos
Message 7 of 15
(5,068 Views)

crossrulz wrote:

2.  If you are not above your threshold, of course you will be less than it. 


Well you could alse be equal to the threshold. 😄

 

(Still the logic could be simplified dramatically but you need two comparisons to identify one of three states. (greater, equal, less) another way would be to subtract the two inputs followed by the sign function).

0 Kudos
Message 8 of 15
(5,066 Views)

@altenbach wrote:

crossrulz wrote:

2.  If you are not above your threshold, of course you will be less than it. 


Well you could alse be equal to the threshold. 😄


1.  I was trying not to muddy the waters.

2. Since we are dealing with floating points, that probably will not be an issue.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 15
(5,052 Views)

I done the diagram as the picture but the led still on then on hardware is still on could you recommend for more?

Download All
0 Kudos
Message 10 of 15
(5,047 Views)