LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Setting analog outputs to 0

I would like to start by cautioning you that I am not a programmer.  I have been trained in LabVIew basics, so naturally I am trying to write a much more than basic code. 

 

I am writing a test sequence in which I am using a sequence structure to setup and sequence various test functions. For part of the code I am writing I am trying to control a pressure output, I start the task outside a while loop, I write to the task to control control pressure inside the while loop after leaving the while loop and then stiop the task outside the while loop, but the analog output remains at the last commanded value, how do I set it to 0? 

 

I have tried writing a constant 0 to the task after I leave the loop and then stoping the task but this does not appear to work. I have a number of analog and digital outputs in this code that I would like to set at 0 before I proceed to the following sequence. 

0 Kudos
Message 1 of 12
(3,040 Views)
That should work, any chance of posting your VI?  Or a sanpshot of the loop section?
0 Kudos
Message 2 of 12
(3,034 Views)

First, I would recomend that you abandon the sequence structure. It's just one of those things that should seldom be used. A state machine is much better. You would simply have a stop state that sets the outputs the way you want.

 

Second, if you are writing a value to the task in one part of your code, writing a 0 to it another part should be no different and in fact is the correct way to set the output(s) to 0. Do you get any errors when you write the 0? Are you sure the task is still active? Can you post your code?

0 Kudos
Message 3 of 12
(3,032 Views)

Again, Dennis was faster than me and again he is correct. Only one comment here:

You hopefully don't stop the VI using "Abort", don't you?

 

 

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 12
(3,029 Views)

I have attached the portion of the code I have been using for troubleshooting.  I am sure that you will spot a few instances of where I can be doing things better. 

 

I have been waiting for the code to finish and checking the output voltage afterwards. 

 

 

 

0 Kudos
Message 5 of 12
(3,021 Views)

Looking into your VI does not reveal any attempt to configure any output to 0. Therefore, it naturally does not return to 0. Outputs of a common DAQ device keeps putting out the last written value until the power supply is switched off......

You should definetly use a state machine in order to clean up your code. Thinking in a "state machine manner" helps a lot in preventing issues like this......

 

hope this helps,

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 6 of 12
(3,014 Views)

My appologies, I have been going through a number of trial and error phases with this code.  Here is an example of when I was trying to write a 0 to the channel, in this version I used a case structure to tell it to go to 0 when the test sequence would be complete.  I arrived at this potential solution after having no success with earlier attempts. 

 

As far as state machines go, like I said I have only been to LabView basics I and II, would I be able to convert the sequence structure to a case structure and put that in a while loop of some sort to control the sequencing?

0 Kudos
Message 7 of 12
(3,002 Views)

Ok, i am not sure if this is what you are talking about: Digital Out Valve 3 is set to FALSE after the last loop....so, this should work as desired.

The other output tasks  are not set to 0 or FALSE, so they keep going on with their last value...

 

Switching to a state machine should be quite easily possible since state machines are part of the Basic I content......

 

hope this helps,

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 8 of 12
(2,992 Views)

I'm having a bit of trouble understanding what you are doing. Part of that is the use of tasks saved in MAX and I have no idea if they are analog out or digital out. The simplest thing is to place the code that sets the analog out to 0 is outside the loop and right before the stop task. If you don't have automatic error handling turned on, please use an error indicator to see whether any occur. If you do have an error, the DAQmx Write will not run.

 

p.s. The use of the single input compound Arithmetic in a couple of locations is just plain silly. The sequence structure you have is not doing anything. You could simply wire from that first loop to the second and control execution order. What the state machine would do is allow you to place the separate acquisition loops you have in separate states, or you could have a single acquisition loop and two separate analysis states.

0 Kudos
Message 9 of 12
(2,990 Views)

I tried writing a 0 to the task right after the loop and before the stop but had no success, one thought was that the task was stopping before it had the time to write to 0, so I tried to put it in the loop.  I will try again with an error indicator attached.   

0 Kudos
Message 10 of 12
(2,986 Views)