02-16-2018 06:17 PM
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
Solved! Go to Solution.
02-16-2018 07:54 PM
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
02-17-2018 06:49 AM
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
02-17-2018 12:17 PM
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!
02-17-2018 12:52 PM - edited 02-17-2018 06:42 PM
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.
02-17-2018 05:40 PM - edited 02-17-2018 06:02 PM
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
02-17-2018 06:13 PM
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.
02-17-2018 09:00 PM
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
02-17-2018 11:55 PM
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!
02-18-2018 01:23 AM
Does it work correctly?
Some things I noticed from a casual glance at the code: