08-23-2010 02:17 AM
Hi,
I would like to acquire data from two PCI-6259 synchronisely with an external clock triggered every second. I was able to do that using one board. I configured the channels and the clocking signal pins. Start the "BeginReadMultiSample" and wait for the trigger. As triggered arrived, in the callback rountine, I called "EndReadMultiSample" to get the data and restart the "BeginReadMultiSample". However, by using two boards (connected with RTSI) cable, I similarly configured the two boards similarly, however, I got errors in the callback routine. I would like to see if there is any sample example code for reference as I don't know if I should configure both boards having callback or just the master board having callback and read the data from both in the callback.
Thanks
Mike
08-24-2010 11:10 AM
Hi Mike,
If you look under Start » All Programs » National Instruments » NI-DAQ » Text-Based Code Support, you will be able to find all of the text-based examples for your device.
In theory, for synchronization across two devices, the master device will export its sample clock and start trigger to the slave device, and the slave device will import the sample clock and use that for its own while triggering off the external trigger line. So in configuring the master to use its own clock and export a trigger, the slave will be set up to use external clock/trigger.
08-24-2010 09:17 PM
Hi Kyle,
Thanks a lot for your reply. Sorry that I couldn't find the text-based code example with the path you mentioned, actually, there is no such option in NI-DAQmx ! Anyway, I would like to state my problem and set up in details and see if you could help.
I got two PCI-6259M boards and would like to acquire data simultaneously. My PC is running XP and the application is written in VB.net 2005 using Measurement Studio 8.0 and I installed the NIDAXmx 8.3.
The master board is supplied with an external clock. I created a task for the master board like this:
AITask = New Task()
AITask.AIChannels.CreateVoltageChannel("dev1/ai0" & ":" & NoOfModule, "", AITerminalConfiguration.Rse, -10, 10, AIVoltageUnits.Volts)
AITask.Timing.ConfigureSampleClock("/dev1/pfi12", 35000, SampleClockActiveEdge.Falling, SampleQuantityMode.ContinuousSamples, NoOfSampling)
AITask.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger("/dev1/pfi4", DigitalEdgeStartTriggerEdge.Falling)
AITask.Control(TaskAction.Verify)
Actually, I used to run one board and this worked fine. But now I need some more channels, so I added another board and connected them with RTSI cable. Also,I created the RTSI cable device in MAX as well and added the two DAQ board under it.
To control the second board, I added another task, AITask2, as follows:
' ********* Second DAQ board ***************
AITask2 = New Task()
AITask2.AIChannels.CreateVoltageChannel("dev2/ai0" & ":1", "", AITerminalConfiguration.Rse, -10, 10, AIVoltageUnits.Volts)
AITask2.Timing.ConfigureSampleClock("/dev1/pfi12", 35000, SampleClockActiveEdge.Falling, SampleQuantityMode.ContinuousSamples, NoOfSampling)
AITask2.Timing.ReferenceClockSource = AITask.Timing.ReferenceClockSource
AITask2.Timing.ReferenceClockRate = AITask.Timing.ReferenceClockRate
AITask2.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger("/dev1/ai/StartTrigger", DigitalEdgeStartTriggerEdge.Falling)
AITask2.Control(TaskAction.Verify)
' ************ Second DAQ Board *************
I don't know if the above codes are correct or not. If not, I would like your comment, thanks.
Then I created two multichannel readers to read two boards every second in the designated callback function.
' ********** For Continuous Sampling **********
SamplingTimeCount = 0
AIReader = New AnalogMultiChannelReader(AITask.Stream)
AIReader.SynchronizeCallbacks = True
AICallBack = New AsyncCallback(AddressOf AnalogInCallBack)
AIReader.BeginReadMultiSample(NoOfSampling, AICallBack, AIReader)
' ********** End for Continuous Sampling **********
' ********** Second DAQ board Continuous Sampling **********
AIReader2 = New AnalogMultiChannelReader(AITask2.Stream)
AIReader2.SynchronizeCallbacks = True
AICallBack2 = New AsyncCallback(AddressOf AnalogInCallBack2)
AIReader2.BeginReadMultiSample(NoOfSampling, AICallBack2, AIReader2)
' ********** End for Second DAQ board continuous Sampling **********
The two callback functions are similar with the EndReadMultiSample commands.
' ***************** callback function *********************
Private Sub AnalogInCallBack2(ByVal ar2 As IAsyncResult)
If TaskRunning = True Then
data2 = AIReader2.EndReadMultiSample(ar2)
AIReader2.BeginReadMultiSample(NoOfSampling, AICallBack2, Nothing)
End If
End Sub
' ***************** end Callback function *****************
The questions are:
1. I'm not sure if my codes are correct esp the AITask2 configuration;
2. If I use two callback functions, there may be a siutation that the 2nd callback start while the 1st callback doesn't complete. Actually, I prefer using
one callback to acquire data from the two boards, how can I do that ?
I don't think the things that I wanna do is special, it may be a very common application but I couldn't find any example for reference. Much appreciated for any help.
08-25-2010 03:21 PM
Hi Mike,
For the examples, here you can find more info about where those examples are located on your machine: NI-DAQmx, NI-VISA and NI-488.2 .NET Example Locations
Where does your external clock come from? Where does your external trigger come from? As far as the Slave Device goes, you will need to export signals to your slave, otherwise it will not see the signal. This includes your trigger line and sample clock line. From .NET 3.0 Help:
Public Sub ExportHardwareSignal( _
ByVal signal As ExportSignal, _
ByVal outputTerminal As String _
)
Then you can set the terminal on your slave device that you export to to be the source for that particular function (timing or trigger).