LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Best way to control voltage with my code?


@belopsky wrote:

Im not sure what you mean by, why am i closing the queue reference? i am not? i did not think I was..


I'm not asking why you are closing the queue, but rather why NOT?

When you open a queue reference you need to close that reference again, else you will get into problems later.

 


@belopsky wrote:

...

The queu is being used for acquisition and logging. Somewhat a producer/consumer.

...

 


No, you do not have anything remotely close to Producer/Consumer pattern, sorry.

One reason for that is, you create, write and read in the same case in the same while loop.

There is no need for that queue, it has no function that a direct waveform wire from DAQmx read can't do.

0 Kudos
Message 11 of 26
(979 Views)

guess thats me being a noob. 

 

i will make the changes you suggested

0 Kudos
Message 12 of 26
(975 Views)

And then to the = question:

 Rube Boolean.png

 

Try to answer the two questions.

0 Kudos
Message 13 of 26
(973 Views)

And don't take my comments the wrong way, I'm just trying to help you a little more on the way to better programming.

 

0 Kudos
Message 14 of 26
(963 Views)

The loop will never stop since there is nothing wired to the end loop terminal Smiley Wink          Couldn't resist.

Doug

"My only wish is that I am capable of learning each and every day until my last breath."
0 Kudos
Message 15 of 26
(930 Views)

Thank you Doug, great help.

0 Kudos
Message 16 of 26
(916 Views)

This is my Pulse Train vi:

 

pulse_train_cont.PNG

 

That is the subVI I use to control the continuous pulse-train with my main code. The issue I have is that once this starts, my UI 'freezes' and I cannot press anything. as this is continuous, it never stops. I must click the red STOP in LabView to quit the program.

 

I understand that currently, the way the while loop is, it will run until an error or the stop button is pressed.

 

What is the best way for me to implement this to stop when the user presses a stop button on the main front panel (the code posted in my first post).

 

Is there a better way for me to run this subVI?

 

Thanks!

0 Kudos
Message 17 of 26
(908 Views)
No reason at all to even have the while loop. Why did you write it that way?
0 Kudos
Message 18 of 26
(892 Views)

It's still not clear to me if you are adjusting an analog voltage or controlling a digital PWM signal.  The code looks like a PWM signal so I will show what I have done for this.

 

I created a functional global variable with an init/start case,  a modify case, and a stop/close case as shown below.  That way I can start supplying the signal, go off and do lots of other stuff, change the d/c and frequency as needed along the way and then close it when I am done for the day.

 

I feed the d/c out for other purposes and is not required just create the signal.  The 6221 daq I use has two timer/counters so I can select either one as needed.

 

I also limit the range for the d/c and frequency.  Get much below 20kHz on the frequency and you can start hearing it depending on what you are sending it to.  Brushless motors in my case.

 

pulse-1.png

pulse-2.pngpulse-3.png

Doug

"My only wish is that I am capable of learning each and every day until my last breath."
0 Kudos
Message 19 of 26
(882 Views)

Dennis, the while loop is there just as in the 'Counter - Continuous Output.vi'

 

 

 

0 Kudos
Message 20 of 26
(865 Views)