11-18-2010 06:15 PM
I am using the 6351 and have two tasks:
AnalogInputTask has 3 AI channels
AnalogOutputTask has 1 AO channel
When I set up both of these tasks to trigger off a single digital channel, I have no problem. But when I want to use an analog trigger, I get error 50103 when the second task (doesn't matter which order they are in) is committed. Are there some restrictions with setting up an analog trigger?
The code looks something like this:
public AnalogInputChannel(ConfigSettings config, SweepSettings sweep, SweepType sweepType)
{
AnalogInputTask = new Task();
AnalogInputTask.AIChannels.CreateVoltageChannel(voltageChannelName, "Voltage Sense", AITerminalConfiguration.Differential, -5, 5, AIVoltageUnits.Volts);
AnalogInputTask.AIChannels.CreateCurrentChannel(currentChannelName, "Current Sense", AITerminalConfiguration.Differential, -15, 15, currentSense, AICurrentUnits.Amps);
AnalogInputTask.AIChannels.CreateVoltageChannel(irradianceChannelName, "Irradiance Sense", AITerminalConfiguration.Differential, 0, 5, AIVoltageUnits.Volts);
AnalogInputTask.Triggers.StartTrigger.ConfigureAnalogEdgeTrigger(sweepTriggerAIChannel, AnalogEdgeStartTriggerSlope.Rising, aiTriggerLevel);
AnalogInputTask.Timing.ConfigureSampleClock(string.Empty, rate, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, length);
AnalogInputTask.Stream.ReadAllAvailableSamples = true;
AnalogInputTask.Stream.ReadWaitMode = ReadWaitMode.Poll;
Reader = new AnalogMultiChannelReader(t.Stream);
AnalogInputTask.Control(TaskAction.Commit);
AnalogInputTask.Start();
}
public AnalogOutputChannel(ConfigSettings config, SweepSettings sweep, SweepType sweepType)
{
AnalogOutputTask = new Task();
AnalogOutputTask.AOChannels.CreateVoltageChannel(vOutChannel, "Voltage Source", -10, 10, AOVoltageUnits.Volts);
AnalogOutputTask.Triggers.StartTrigger.ConfigureAnalogEdgeTrigger(sweepTriggerAIChannel, AnalogEdgeStartTriggerSlope.Rising, aiTriggerLevel);
AnalogOutputTask.Timing.ConfigureSampleClock("", rate, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, length);
Writer = new AnalogSingleChannelWriter(t.Stream);
Writer.WriteMultiSample(false, waveform);
AnalogOutputTask.Control(TaskAction.Commit); //ERROR HAPPENS HERE
AnalogOutputTask.Start();
}
Solved! Go to Solution.
11-19-2010 08:26 AM
You get the error because you try to create the trigger again. Instead, reuse (route) the trigger of the first task.
I'll try to write the code-lines (I'm a LV'er).
AnalogOutputTask.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger(AI.StartTrigger);
Felix
11-19-2010 11:44 AM
I can't find a way to do this in c#. It will only take a string as the "virtual channel or terminal" so I don't know how to pass the existing StartTrigger.
Can you show how to do it in LabView? I might be able to get it translated.
11-19-2010 12:10 PM
Instead of AI.StartTrigger, try using the DAQmx Terminal Name "/Dev1/ai/StartTrigger".
Best Regards,
11-19-2010 12:59 PM
This seems to work! Thank you
So will the two tasks be triggering off the same signal or is the second task triggering off the first task? That is, will there be any kind of delay between the two?
11-19-2010 01:19 PM
Both of the tasks will be triggered in hardware off of the same signal. Technically the routes would be slightly different, but any delay wouldn't be more than a few ns and should be unnoticeable.
One caveat is that you'll want to start the AO task first in software. This way it will always be armed and ready to go before the AI Task has the possibility of receiving a trigger.
Be careful if you try to specify a rate that is not an integer divide-down of one of the internal timebases (100 MHz, 20 MHz, or 100 kHz). The board can only generate clock rates at integer divide-downs of the timebases, so the driver will coerce any values that do not comply. AI tasks always get rounded up, whereas AO tasks get rounded to the nearest available rate.
Best Regards,
11-20-2010 04:39 AM
I suggest you study this tutorial:
http://zone.ni.com/devzone/cda/tut/p/id/3615
If I read your code correctly, you should also assign a shared reference clock to both tasks.
For the very details of timing, check out the M-Series user manual:
http://digital.ni.com/manuals.nsf/websearch/2025C99AB0614F9E8625748000577B9A
In Appendix B: Timing Diagram you find more about the internals than you ever want to know.
Felix