From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to trigger from analog input channel

sorry, I forgot to attach the code. 

0 Kudos
Message 11 of 22
(1,910 Views)

Hey Henry,

 

First, let me clarify something: Are signals A, B, X, and Y all analog input signals being read by the same card? If so, you can't really "control" one analog input with the other analog inputs. Although, you could acquire ALL this signals at the same rate (most likely a fast rate to catch the triggers). Then in software you can setup a condition where if A is above a certain value, then save the corresponding value of X, and when B is above a certain value (or within a certain range) then save the corresponding value on Y. This would essentially be a software workaround for what you are trying to do.

 

To split the signals, you can just use the index array function to grab the individual channels like shown below:

separate signals.JPG

 

Also, how often and how many samples are you wanting to acquire per trigger? If you just want one sample each time you receive a trigger, you can monitor the trigger lines and start an analog input task for the specific channel that you receive a trigger for. If you are planning on receiving the triggers at the same time, then you could make an analog task that always acquires your X and Y channels not matter if B or A triggers, but then only saves channel data that corresponds to which trigger hit. For example, every time A OR B triggers, you will collect a sample from X & Y, and then if trigger A was the one that actually fired, you would only save the sample from channel X. 

 

Basically, there are various ways you can implement this in software, but you have the limitation of not being able to simultaneously record analog at different sample rates with different triggers (i.e. - all analog inputs that you want to acquire at the same time must be on the same task, and acquiring at the same speed. What you do with the data after you acquire it though can produce the functionality you’re looking for). I hope this helps!

 

-Nathan H

Software Developer
National Instruments
0 Kudos
Message 12 of 22
(1,907 Views)

Hey Henry,

 

Sorry I didn't see your most recent update before I added that last one. It looks like you figured out the index array function. The device name should be what appears in MAX (you can always change it). So if it's "Dev1", then analog input channel 1 would be "Dev1/ai0". You should be able to select this from the drop down menu. If not, right click the device name constant and select "I/O name filtering.." and limit the selection to your device.

 

Also, it looks like you have posted this question here as well: http://forums.ni.com/t5/LabVIEW/Synchronize-Triggers-for-both-digital-and-analog-signals-with/m-p/17... In the future, try to just ask your question on just one forum thread. This makes it easier to respond to, prevents confusion, and allows for other user's questions to be answered as well.

 

-Nathan H

Software Developer
National Instruments
0 Kudos
Message 13 of 22
(1,899 Views)

Hi Nathan,

 

Thanks for your reply. Sorry for that, I will post my question on one forum now. Sorry.

 

For the code you sent to me, if I only need to sample 2 analogue inputs(A and B), how should I configure the physical channel? 

 

In terms of the index array function, now I am using the AI Sample Channels.vi which I know how to configure the physical channels, but in this vi, it requires me to type the device number to be connected to. So what drop down menu do you refer to and what should I type to connect the device terminal of the AI Sample Channels.vi?

 

Thanks for your help!

 

Regards,

Henry

0 Kudos
Message 14 of 22
(1,894 Views)

Hey Henry,

 

The device number is just whatever the name is in Measurement and Automation Explorer. For example Dev1 is a common device name. So your channel would be "Dev1/ai0" for analog input zero of that device (you could also enter "Dev1/ai0:1" for channels 0 AND 1 of device 1).

 

I'm not sure what VI you are referring to when you say "AI Sample Channels.vi", do you mean DAQmx Create Virtual Channel.vi? Press CTRL+H to bring up context help, then hover over the VI in question to see the actual name. Most DAQmx VIs that require a channel name will allow you to add a constant or control to the input, and that constant or control will have an arrow button on the right side that allows you to expand a drop down menu as shown below, which makes it easier to find your device name.

 

drop down menus.png

 

I hope this helps!

 

-Nathan H

Software Developer
National Instruments
0 Kudos
Message 15 of 22
(1,876 Views)

Henry,

 AI Sample Channel.vi is part of the traditional DAQ driver package. This is an older driver and I'm not sure if it will support your card. You should use the DAQmx driver.

Now Using LabVIEW 2019SP1 and TestStand 2019
0 Kudos
Message 16 of 22
(1,848 Views)

Hi Nathan,

 

Sorry to disturb you again. I just wonder how much delay will be introdeced in this way? I mean using the PCI-6251 to sample 2 analogue input channels together. Since these 2 signals can not be sampled at the same time, there should be some delay between them, can you tell me how much is that? Plus, is it correct say that the higher the sampling rate, the less the delay between the measurement? And can you tell me what is the frequency of the sample clock inside the PCI-6251? I have searched some info regarding this, but I just got 1. MS/s for multichannel, what does that mean?

 

Thanks very much!

 

Regards,

Henry

0 Kudos
Message 17 of 22
(1,840 Views)

Hi henry,

 

To be able to calculate the delay between the two signals been sampled, you can go to this link that explains how the different clocks inside a card works and how to know the delay in time between the switch from one to another channel.

 

About the 6251 card, what the manual says, as you mention it, is that you can have 1MS/s multichannel and also that this is aggregate, this means that this will be shared between the active channels, in this case you can have up to 500KS/s in each channel.

 

About the frecuency clock in this card, if by frecuency clock you mean the clock timebase, there is a 20MHz clock inside this card that will work as the timebase. But if you mean the sample rate, this rate will depend on the one that you set up, the timebase clock will divide and set the most accurate rate compared with the one that you set. You can find more information about this in page 4-25 from the M card manual (found here)

 

I hope this will help you,

 

Regards,

steve.bm
AE | NI
0 Kudos
Message 18 of 22
(1,832 Views)

Hi Steve,

 

Thanks for your reply. Just I am a little bit confused about samples per second. Can you tell me what does 50KS/s mean? Does it mean that the fastest sampling rate is 50K Hz?

 

Thanks very much!

 

Regards,

Henry

0 Kudos
Message 19 of 22
(1,828 Views)

Henry,

 

50 KS/s means 50,000 Samples per second

So yes you are sampling at 50,000 Hz.

 

Kyle Hartley
Senior Embedded Software Engineer

0 Kudos
Message 20 of 22
(1,813 Views)