08-14-2012 09:12 AM - edited 08-14-2012 09:16 AM
I am performing an analogue input task and would like to export the sample clock on a PFI pin. However, I have tried using both the
Task.ExportSignals.ExportHardwareSignal() method
and the
DaqSystem.Local.DisconnectTerminals() method
and cannot for the life of me see anything on the output pin. I was expecting a pulse at a frequency of 100Hz.
I've written a piece of test code to remove all the complexity of my larger application but with no luck. I've reduced my actions to creating an AI task with an internal clock, acquiring data continously and (attempting) to export the sample clock to PFI13. Here's my stripped down method:
Task myTask = new Task();
myTask.AIChannels.CreateVoltageChannel("Fast1/ai0",
"",
AITerminalConfiguration.Differential,
-10,
10,
AIVoltageUnits.Volts);
myTask.Timing.ConfigureSampleClock("",
100.0,
SampleClockActiveEdge.Rising,
SampleQuantityMode.ContinuousSamples,
1000);
myTask.ExportSignals.ExportHardwareSignal(ExportSignal.SampleClock,
"/Fast1/PFI13");
myTask.Control(TaskAction.Verify);
analogInReader = new AnalogSingleChannelReader(myTask.Stream);
analogInReader.SynchronizeCallbacks = true;
analogCallback = new AsyncCallback(AnalogInCallback);
asyncResult = analogInReader.BeginReadMultiSample(100,
analogCallback,
null);
I can see no output on PFI13 when I use this (acquisition is taking place - I plot the data on a graph). I also see no output if I change the 'ExportHardwareSignal()' method to
DaqSystem.Local.ConnectTerminals("/Fast1/ai/SampleClock",
"/Fast1/PFI13");
Or if I use the properties of 'ExportSignals':
myTask.ExportSignals.SampleClockOutputTerminal = "/Fast1/PFI13"; myTask.ExportSignals.SampleClockOutputBehavior = SampleClockOutputBehavior.Pulse;
Other info:
I'm now out of ideas and rapidly running out of time and would really appreciate some help.
Thanks.
CAS
08-15-2012 04:06 AM
Well it turns out that there is nothing wrong with that code. I wasn't seeing an output due to the configuration of the custom electronics I was using to access the PFI pin. This was not coping well with the narrow sample clock pulse.
This has at least highlighted to me that the width of the pulse may be a problem for the hardware I am connecting it to so I have decided to modify my method to give me a wider pulse. As this information may be useful to others I thought I'd share it here. The basics (and LabVIEW method) can be found in this Knowledgebase Article.
To achieve a wider pulse I have replaced the line
myTask.ExportSignals.ExportHardwareSignal(ExportSignal.SampleClock,
"/Fast1/PFI13");
with
myTask.ExportSignals.SampleClockOutputTerminal = "/Fast1/PFI13"; myTask.ExportSignals.SampleClockOutputBehavior = SampleClockOutputBehavior.Level;
As mentioned in the article, this causes the output on PFI13 to go high at the beginning of the sample and low when the last AI Convert begins. If data is being acquiring from a single channel, a delay can be inserted between the sample clock pulse and the AI convert signal by setting the properties:
Task.Timing.DelayFromSampleClockUnits Task.Timing.DelayFromSampleClock
Also, if data is acquired from multiple channels, a further option is to modify the inter-channel sampling rate within the sample period using the property:
Task.Timing.AIConvertRate
Hopefully this'll prove a useful summary to others.
CAS