LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

USB 6008 channel on/off for specific times

Solved!
Go to solution

Hi,

 

I am new to Labview so I have no idea if this is easy or hard to do.

 

I have a VI attached which writes digital outputs to 12 channels.

 

What I´d like it to do is to be able to write each channel for a specified amount of time (software timing is fine - it doesn´t have to be super precise but it does need to turn off automatically after a set amount of time).

 

For example:

 

When I click, channel 1, I want it to go on for 1 second, then turn automatically turn off, and wait for the next command.

When I click, channel 2, I want it to go on for 0.5 seconds, then turn automatically turn off, and wait for the next command.

When I click, channel 3, I want it to go on for 5 seconds, then turn automatically turn off, and wait for the next command.

etc.

 

So, after I click run, I might click channel 1, wait a few seconds, then click channel 1 again, wait a minute, then channel 3, wait 10 minutes, then channel 2, etc, in whichever order.

 

Is this easy to do? Is it possible?

 

Thanks in advance for any advice.

 

Jon

0 Kudos
Message 1 of 5
(2,666 Views)
Solution
Accepted by topic author Jon2

Hi Jon,

 

If you want to set the times separetly, my guess is it would be easier for you to create the channels separetly. It is more handwork, but i believe it's better than coming up with a time-supervision algorithm to all channels at once.

 

To trigger the output, I think it's better to pool the inputs, so maybe it would be good to take them out of the array as well.

 

In while loop, you can check the button's value and then just write 1 to the port, wait for the timeout with the time delay vi, and then wrtie 0 again.

 

If you create all tasks separately and don't merge error, the process for each channel will run in parallel, so one delay will not affect the other channel's action.

 

Regards,

Mariana.

 

 

 

undefined

 

 

Message 2 of 5
(2,651 Views)

Mariana, thanks for your solution. I implemented what you suggested, and it works! I also added an indicator that lights up when a channel is in the ON state, since the way it´s programmed, only one channel can be on at one time. This isn´t a big problem for me, but it´s useful to know when the current channel turns off so that I know that I can click the next channel.

 

I have a couple more questions.

 

First, when the USB 6008 DAQ powers up, it sets all of the channels to the ON state (voltage at 5 V). Is there anyway to initialize all the channels first, setting them all to the OFF state (voltage at 0 V) prior to starting? Perhaps, by using a filmstrip. But I´m not sure if this is the right way.

 

Second, right now the STOP button has to wait until the timer finishes counting before it can stop the program. I know this is because the STOP button is outside of the case loops so it has to wait for the case loop to finish. However, when I press STOP, I´d like it to immediately set all channels to OFF (0 V) and then immediately stop the program. Is there an easy way to do this?

 

Thanks!

0 Kudos
Message 3 of 5
(2,628 Views)

Hi Jon,

 

I believe you can configure the initial state in MAX - Measurement and Automation Explorer that is installed with your DAQmx Software.

Find your USB hardware and try hit "Properties". I have a PCI on my current system and I can configure the initital states.

 

Another way to do it is just to write all false right before the while loop starts.

 

Yes, there is a way to stop the loop imediatelly, but then you'll have to create the time delay vi yourself, with the possibility of stoping it when stop button is hit. This can be done in different ways. You could for instance make a for loop which waits 100ms and then configure how many times you want it executed based on your delay for each channel (number of times = channel delay/100ms). Another way to do it is to create a delay vi with the stop button reference as input. I did this vi once, and the only thing I did was to put this for loop inside a subroutine.

 

THe code I did is attached. You should wire stop button reference to all delays. It will have a small delay of about 150ms, but if your system is not time-critical, I believe it won't be a problem.

 

Regards,
Mariana 

Message 4 of 5
(2,621 Views)

Mariana - ok, I figured out how to do it using the AbortableDelay vi that you provided. Thanks for all your help!!

0 Kudos
Message 5 of 5
(2,597 Views)