LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Automatic change output values to USB-6009

Hi, 

I am using the USB-6009 to control a motor. I am able to set 1 output value, but in my case I will need to set up 2 output values which automatically are able to work alternately ... first value to work for 2 seconds then the other value works  for 2 seconds. Can anyone kindly help me with this?

 

0 Kudos
Message 1 of 7
(650 Views)

Hi Nemra19,

 

the attached VI will do the job for you.

I am waiting for your feedback or questions.

 

Best Regards,

Akos_43

NI

Message 2 of 7
(600 Views)

For doing anything other than the most simple (some might say "trivial") examples of DAQ I/O, you should learn how (easy it is) to use DAQmx and really get control of your hardware.  There is an excellent White Paper available -- do a Web Search for "Learn 10 Functions in NI-DAQmx and Handle 80 Percent of your Data Acquisition Applications".  Another good source for help and inspiration are the Examples that ship with LabVIEW, one of which Akos_43 used as a "solution", but without giving credit to NI nor explaining how it worked.

 

It is often a good idea to think what you want to do, and to figure out, sometimes with the help of MAX, how you might do it.  Have you used MAX to "explore" your device?  [I think the White Paper mentioned above discusses this].

 

Think about what you want to do.  One way to describe your output signal is that it has voltage V1 for 2 seconds and voltage V2 for 2 seconds, then repeats.  This could be described as a waveform having two points, V1 and V2, and an update rate of 1/(2 sec) or 0.5 Hz.  There are numerous ways to create such a signal, a Waveform being the most compact (you can ignore t0, set dt, the update time, to 2 (seconds), and set the Y array of values to the two-element array [V1, V2]).  Now, using the 3-5 VIs that you learned about in the "Learn 10 Functions" White Paper, you can write very simple DAQmx code that will play out this Waveform until you push the Stop button.  Note that the While Loop will play out "entire cycles", so it might output what seems like an "extra" cycle -- if you need things to "stop immediately", you will need to "rethink" this method.

 

Bob Schor

Message 3 of 7
(590 Views)

Both of the previous hints will not work since you can only set digital (or analog) outputs on a USB-6009 with software-timing.

 

Regards, Jens

Kudos are welcome...
Message 4 of 7
(584 Views)

You are correct.  I actually tried to generate a DAQmx Task to do this and plugged in a USB-6009, but I also had a USB-6002 plugged into the same PC, and chose the wrong USB device for my test.  My apologies.

 

So the problem definitely simplifies (though you run into other problems that are "solved" by LabVIEW's Data Flow model, one that allows the "Pulse Train Loop" to run independently, and in parallel with all the rest of the code.

 

So let's just concentrate on generating a two-state DC signal, switching every 2 seconds. 

  • What structure do you want to use that "does something every 2 seconds"?  [What's the Structure, and what makes it run once every 2 seconds?]
  • How do you make it do something "alternating" each time through the loop?  ["Alternating" is particularly easy.  Only slightly more difficult is making it cycle through 3, 4, 5, or some other fixed finite set of alternatives.  For "extra credit", think about cycling between a list of 15 values.]

Write the code, try it out, if it works, come back and let us know (and say "Thank you"), and if it doesn't, feel free to return and post your code (no pictures!).

 

Bob Schor

Message 5 of 7
(579 Views)

Hello Akos_43,

thank you for your help. I figured out another way to make it work, I really appreciate you help.

Best regards 

Nemra

0 Kudos
Message 6 of 7
(559 Views)

thank you all for your help. At the end I was able to manage it someway by using Elapsed time with a case structure as shown in the attached picture.

Thank again 

Nemra

 

0 Kudos
Message 7 of 7
(556 Views)