05-16-2014 08:07 PM
I am trying and utterly failing to generate a TTL signal that is high while my analog output task is running and low otherwise. I thought this would be simple by just using the ao/SampleClock to write 1s to the DIO, but this fails:
(link to human-readable version of the code below: http://pastebin.com/S0FdXffe )
myAnalogTask = new Task();
myAnalogTask.AOChannels.CreateVoltageChannel("Dev2/ao0", "galvo", -2.9, 3, AOVoltageUnits.Volts);
myAnalogTask.Timing.ConfigureSampleClock("/Dev2/PFI1", 8000, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, dacCyclesPerFrame);
digitalTask = new Task("RFswitch");
digitalTask.DOChannels.CreateChannel("Dev2/port0/line5", "RFswitch", ChannelLineGrouping.OneChannelForEachLine);
digitalTask.Timing.ConfigureSampleClock("/Dev2/ao/SampleClock", 8000, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, dacCyclesPerFrame);
myAnalogTask.Control(TaskAction.Verify);
digitalTask.Control(TaskAction.Verify);
AnalogMultiChannelWriter analogwriter =
new AnalogMultiChannelWriter(myAnalogTask.Stream);
DigitalSingleChannelWriter writerDigital = new DigitalSingleChannelWriter(digitalTask.Stream);
//load data into analog out
//...
for (i = 0; i < samples; i++)
{
digitaldata[i]=0xFFFF;
}
analogwriter.WriteMultiSample(false, analogdata);
writerDigital.WriteMultiSamplePort(true, digitaldata);
No error is generated, but the digital out lines all stay low. The analog out functions normally. Any ideas? Surprisingly NI does not provide sample code for synced DIO/AO.
05-16-2014 08:18 PM
Ah nevermind, that code does work. I just had a lose wire.