02-04-2011 08:08 AM
USB-6343
VB 2008 .NET
Windows XP Pro
I am trying to create a task that reads an analog input based on a trigger from another analog input. It works fine if I use AFPI0 for the trigger input, but I get error -200265 ("An attempt has been made to use an invalid analog trigger source.") if I use "ai0" for the trigger as shwon below:
triggerTask = New Task
'Create a virtual channel for the trigger input
triggerTask.AIChannels.CreateVoltageChannel("dev1/ai0", "ai0", _
AITerminalConfiguration.Rse, Minimum, Maximum, AIVoltageUnits.Volts)
'Create a virtual channel
triggerTask.AIChannels.CreateVoltageChannel("dev1/ai1", "ai1", _
TerminalConfig, Minimum, Maximum, AIVoltageUnits.Volts)
triggerTask.Timing.ConfigureSampleClock("", TimingInfo.SamplesPerSecond, _
SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, _
TimingInfo.SamplesToAcquire)
triggerTask.Triggers.StartTrigger.ConfigureAnalogEdgeTrigger("ai0", _
AnalogEdgeStartTriggerSlope.Rising, TriggerInfo.Level)
'Verify the Task
triggerTask.Control(TaskAction.Verify)
triggerReader = New AnalogMultiChannelReader(triggerTask.Stream)
triggerReader.SynchronizeCallbacks = True
triggerReader.BeginReadWaveform(TimingInfo.SamplesToAcquire, _
AddressOf ReadAnalogCallback, Nothing)
Thank you in advance for your assistance.
Mike Parks
02-07-2011 10:27 AM
Hello Mike,
I am attaching a link that addresses this issue, it is coded in LabVIEW but it uses the same DAQmx functions. I think that you may just need to include the device prefix in the trigger source name ie. "dev1/ai0". Let me know if this helps you out.
http://digital.ni.com/public.nsf/allkb/6F50064F936FA29186257537005B244A?OpenDocument
Thanks,
Justin
02-07-2011 12:38 PM
Justin,
Thanks for the information.
When I previously attempting to use a standard AI channel for the trigger, I did not fully qualifying it with the device name (i.e."Dev1/"). I modified my code to do this, but it still does not work. The discussion you referenced also indicates that the AI channel being used as a trigger must also be read, and it must be defined prior to the analog input that you want to read after the trigger. As you can see from the code I provided, I did add "ai0" (trigger) to the task prior to "ai1" (channel to read). Is there more that I need to do? Can you provide me with a code example, or at least some idea of what is wrong with the code I provided?
I appreciate your help.
Mike Parks
02-07-2011 12:56 PM
Hi Mike,
You can find many examples in the NI-DAQ folder under Examples»DotNETx.x. One example that looks close to what you are trying to do is under Analog In»Measure Voltage»AcqVoltageSamples_IntClkAnalogStart.
Regards,
Justin
02-07-2011 01:47 PM
Justin,
I've been all over the examples... this one shows how to use AFPI0. It is where I obtained my initial code for this function, and it works properly with that input. The problem comes when I attempt to use a standard AI channel, which is perfectly legitimate according to the specifications. I would not be asking if it was as simple as looking at one of the samples already provided... this is why I asked for your help.
The only change I made to my code based on your feedback is to fully qualify the analog input when setting up the trigger ("Dev1/ai0"). I would very much appreciate some more advanced assistance if you have the time.
Thanks again,
Mike Parks
02-07-2011 02:43 PM
Hi Mike,
I noticed that you are using the USB-6343. This device does not support analog triggering only digital. One option is to create two analog input channels as you were doing, then acquire data on the trigger line and apply some comparative logic that triggers the acquisition on the other channel once the threshold has been met on the trigger line. A digital trigger can be sent in on any PFI line.
http://www.ni.com/pdf/manuals/370786c.pdf
Regards,
Justin
02-07-2011 03:12 PM
Justin,
I apologize for the mixup... we are using the USB-6363 right now. We are looking at using the USB-6343 for one of our other projects, and I mistakenly gave you that model number.
I am currently able to use the AFPI0 input with an analog trigger. What I am trying to do now is use AI0 with the same signal.
thanks,
Mike Parks
02-08-2011 11:08 AM
Hello Mike,
I was able to run this code successfully, the input configuration must be set to RSE explicitly. Also you can create both channels in one function call. Let me know if you are able to get this to work.
' Create a virtual channel
myTask.AIChannels.CreateVoltageChannel("Dev4/ai0,Dev4/ai1", "", _
CType(10083, AITerminalConfiguration), Convert.ToDouble(minimumValueNumeric.Value), _
Convert.ToDouble(maximumValueNumeric.Value), AIVoltageUnits.Volts)
myTask.Timing.ConfigureSampleClock("", Convert.ToDouble(rateNumeric.Value), SampleClockActiveEdge.Rising, _
SampleQuantityMode.FiniteSamples, Convert.ToInt16(samplesPerChannelNumeric.Value))
myTask.Triggers.StartTrigger.ConfigureAnalogEdgeTrigger("Dev4/ai0", _
referenceEdge, Convert.ToDouble(triggerLevelNumeric.Value))