01-18-2010 01:36 PM
Using 3 PCI 6713 cards to generate analog data that has to be synchronized.
The problem is that the first card is one sample ahead of the two others. I am unsure of how to make the synchronization correctly.
First a clock generator is setup at dev0:
private void SetAndStartRPMClock( ICallContext context ) { double frequency = ( ( m_RPM * 4.0 ) / 60.0 ) * ( (double)m_SimulationData.TriggerPulses.Value ); m_CurrentSampleFrequency = frequency; if ( m_RPMTask != null ) { m_RPMChannel.PulseFrequency = frequency; } else { m_RPMTask = new Task( "RPMGeneratorTask" ); string name = m_Generator1.GetPhysicalChannels( PhysicalChannelTypes.CO, PhysicalChannelAccess.External )[ 0 ]; m_RPMChannel = m_RPMTask.COChannels.CreatePulseChannelFrequency( name, "RPMClockGenerator", COPulseFrequencyUnits.Hertz, COPulseIdleState.Low, 0.0, frequency, 0.5 ); m_RPMTask.Timing.ConfigureImplicit( SampleQuantityMode.ContinuousSamples, 1000 ); m_RPMTask.Start(); context.Log( String.Format( "Setting RPM Generator to {0}[Hz]", frequency ) ); } }
This is routed to RTSI0
DaqSystem.Local.ConnectTerminals(String.Format("/{0}/Ctr0Out", m_Generator1.DeviceID), String.Format("/{0}/RTSI0", m_Generator1.DeviceID), 0);
And the 3 cards are setup:
//"RTSI0" foreach ( Task t in m_DeviceTasks ) { if (t != null) t.Timing.ConfigureSampleClock("RTSI0", 1000.0, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, (int)SAMPLE_LENGTH); } m_DeviceTasks[1].Triggers.StartTrigger.ConfigureDigitalEdgeTrigger(String.Format("/{0}/ao/StartTrigger", m_Generator1.DeviceID), DigitalEdgeStartTriggerEdge.Rising); if ( cylinderCount > 8 ) { m_DeviceTasks[2].Triggers.StartTrigger.ConfigureDigitalEdgeTrigger(String.Format("/{0}/ao/StartTrigger", m_Generator1.DeviceID), DigitalEdgeStartTriggerEdge.Rising); }
It's getting a bit late now, and I am unsure what information You need but please ask and I will supply.
/Allan Juul Larsen
MAN Diesel
Copenhagen DK.
01-19-2010 02:26 AM
Hi Allan,
When using an RTSI cable, you will need multiple tasks for multiple cards. The sample clock for the slave tasks will be the master sample clock.
From the attached the code it seems that you are doing just that.
An addition tip you should remember when programming is to call the slave tasks before the master task so that the acquisition will start at the same time.
You might already seen this vb example on Multiple Device Cont. AI sync:
"C:\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples\DotNET1.1\Synchronization\Multi-Device\AIContAcquisition\vb"
Please let me know if this helps.
01-19-2010 03:54 AM
Hi Dennis.
Thanx for the reply, I actually looked a long time to find the examples, the are nice to have.
I have 4 tasks:
1 signal generator. (m_RPMTask)
3 analog output tasks (m_DeviceTasks[ 0 1 2 ])
Should I have m_RPMTask and m_DeviceTasks[ 0 ] in one task? they use the same HW device.
At the moment the m_RPMTask is started first would it be more correct to start this as the last one?
/Allan
PS. I think I have had contact with You or Your college (Eirikor) some time ago regarding the same matter? Case # 780510
01-19-2010 05:52 AM
Hi Allan,
It is not possible to have AO and AI in just one task. You need to split them up into two serparte tasks.
Depends on what you want to do, you can try to start the AO task first on the Master Device and then AI tasks on Slave devices and at last start the AI task on the Master device. This way all three AI tasks should be synchronized to the AO task.
Hope it makes sense.
01-25-2010 07:01 AM
Just to in form.
I found the error that made card 2-3 ofsett one sample. I removed the triggerstart lines to card 2,3 these were redundant. The cards start when the generator is started via ao/sampleclock from card 1.
/Allan