LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Attaching a Physical Switch to start/stop Analog Data Acquisition

Solved!
Go to solution

Hello Everyone,

 

I am using an NI 6002 to gather voltage data across two channels. I want to attach a switch to the system allowing me to write data by pressing a physical button. Write data when the physical button is pressed. Stop writing data when the physical button is released.

 

It is my understanding that I cannot have digital and analog together in the same task so I separated them to their own respective tasks. The NI 6002 is specified to 5V, so in order to trigger the system I have supplied the 5V though a battery. Here is the switch circuit I used where the light bulb in Digital Channel 0. When I pressed the button it does not write to my VI. Instead I get error Property Node DAQmx Trigger (arg 1) in DAQmx Start Trigger (Digital Edge).vi:3930001.

I think I am super close, but I just can’t determine what I am doing wrong.

 

Attached is my VI

Any advice would be appreciated!

Thanks

0 Kudos
Message 1 of 11
(4,463 Views)

A couple of points.  Go to the Web and look up "TTL" (which stands for Transistor-Transistor Logic), and which may explain why 0 and 5 V.  It seems (to me) that you have two entirely-independent (i.e. "parallel") tasks -- acquiring analog data and deciding (based on a TTL signal) whether or not to write data to disk.  Have you considered the timing of these two tasks?  Are you contemplating something like "Write every other point to disk because I flip the switch back and forth every other acquired analog point"?  [I doubt it -- it is probably more likely that you'll want to "turn on" or "turn off" saving of the data, with a time resolution of, perhaps, a tenth of a second].

 

Suppose you decide that you want to acquire analog data at 1KHz, and want to decide on "Save or Not Save" every tenth of a second.  Suppose you sampled 100 points at 1KHz using Continuous Sampling -- this will give you data every 0.1 second.  In the same loop, you can read your Digital Input line -- if it is high (1), save the data, otherwise don't save.  You use the A/D "clock" to also "clock" the Digital Input line.

 

Bob Schor

Message 2 of 11
(4,445 Views)

Hi Kurtz,

 

You could create a two separate tasks and use the digital input change detection to start and stop the continuous analog acquisition task.

 

I believe this should work for your device:

 

Change Detection Event Registration

 

Ingram

Ingram | CLA
0 Kudos
Message 3 of 11
(4,415 Views)

Bob,

 

Thank you for the reply. To answer your question I want to use the switch to "turn on" or "turn off" saving of the data. My professor mentioned using TTL’s to do this, but he never clarified how or why. Reading online, a TTL is type of integrated circuit which outputs a 5V when “high” and 0V when "low." So for my purposes when the TTL is "high" save data and when it is "low" don’t save data. This sounds like something that needs to be purchased. How do I determine which one to buy? Also why is a TTL even necessary? Doesn’t a physical switch connected to a 5V battery accomplish this?

 

Regarding the tasks, I have two running in parallel, because I thought I could not combine Digital and Analog tasks. Does LabVIEW allow this? If it is possible, I would like to combine the tasks to reduce timing issues.

 

I don’t exactly understand the LabVIEW explanation in the second paragraph. Especially regarding clock speed. Could you provide an example code? Bear with me as I am not an Electrical Engineering Major.

 

Thanks AGAIN!

 

 

0 Kudos
Message 4 of 11
(4,396 Views)

You have +5V available on one of the connectors, so all you need is to connect it to the DI. No circuit needed or battery, etc. Follow the diagram in exercise 3 here for the conventional way to do this.

 

TTL here refers how voltage levels translate into boolean state. Typically <0.8V is FALSE and >2V is TRUE. The switch here will toggle the input between 0 and +5 volts, and thus between F and T.

 

 

Message 5 of 11
(4,392 Views)

Attenbach, 

 

Thank you so much for the demo! I got it working; however, do you know how to do this without DAQ Assist but with DAQmx? 

 

Also, I intend on having a physical trigger not a digital one. The VI you linked does not cover how to implement this. So how do I make LabVIEW sense 5Vs with a digital channel ?

 

Thanks

0 Kudos
Message 6 of 11
(4,367 Views)

Altenbach, 

 

I just got digital channel 0 to accept the 5V input using DAQ Assist. I'm still trying to figure out how to do it with DAQmx. 

0 Kudos
Message 7 of 11
(4,361 Views)

If you wire 5V to a TTL Digital In terminal, it will return "High"/"True"/1, while if you wire 0V, it will return "Low"/"False"/0.  For many digital inputs, if the input is not connected to a voltage source, it will "float" and may be configured to be Low if unwired or High (some devices let you specify this).  Your device should have +5V that you could wire (with a switch) into the DI pin.  

 

If you can do Analog Input or Output with DAQmx, it's not clear to me why you can't figure out how to do DI (which, if anything, is simpler).  Of course, you didn't attach your code, so I can't make suggestions ...

 

Bob Schor

Message 8 of 11
(4,351 Views)

Bob, 

 

Thank you for the reply. So I got my physical trigger working with the Digital Input. 

Could you look at the code? See if there are any problems or design choices I should fix? You are much better at LabVIEW than I am. 

 

Thanks for helping me with the Trigger and the Producer/Consumer Template!

 

0 Kudos
Message 9 of 11
(4,341 Views)
Solution
Accepted by KurtzC1

Does it work correctly?

 

Some things I noticed from a casual glance at the code:

  • Index array is resizeable, and if you want the two first elements in order, you don't even need to wire the indices. Index array also probably should be inside the case structure, because the other case does not need the individual elements.
  • Your "calibration" case structures architecture seem a bit strange. Why is the left button and outer case structure even needed?
  • Your queue should probably be a 1D array. The second dimension serves no purpose.
  • Your formula nodes seem completely unnecessary.
  • The data of the two shift registers keeping track of the max should be wired across the case structure above, eliminating the local variables. Or use feedback nodes instead.
  • etc.
  • etc.
  • (I cannot comment on the DAQ parts, because I don't have DAQmx installed. All I see is placeholder code)
Message 10 of 11
(4,336 Views)