02-10-2012 05:25 PM
Hi all,
I'm trying to synchronize 2 PCI 6259 M series boards for a synchronized analog output operation using C#. NET. I did check the example provided for AI and borrowed heavily from the same. I did verify the hardware connectivity using the RTSI cable. Unfortunately, I'm unable to get the master task to start, while the slave starts without the master trigger. A quick gist is as follows.
1. Sample output waveform read from file, sample rate and samples per ch defined
2. Master and Slave channels defined, timing and synchronization set up w.r.t master (code snippet attached)
3. The Slave is set to start once the master task is fired.
When I run the task thru debug mode, I do get the desired output, all output signals are in sync. But when run "normally", the master does not get started while the slave outputs an arbitrary portion of the waveform. No exceptions thrown, but I'm nowhere near a desired result. Any help on this is greatly appreciated.
Code:
//Declare all the tasks
myTask = new Task("inputTask"); // AI task
myMaster = new Task("masterTask");
mySlave = new Task("slaveTask");
myMasterWriter = new AnalogMultiChannelWriter(myMaster.Stream);
mySlaveWriter = new AnalogMultiChannelWriter(mySlave.Stream);
# Waveform Read from file, outputting 2 double arrays.......
//Configure the master and slave task
myMaster.AOChannels.CreateVoltageChannel("Dev1/ao0", "", -10, 10, AOVoltageUnits.Volts);
myMaster.AOChannels.CreateVoltageChannel("Dev1/ao1", "", -10, 10, AOVoltageUnits.Volts);
myMaster.Timing.SampleClockRate = outputSampleRate;
myMaster.Control(TaskAction.Verify);
double correctUpdateRate = myMaster.Timing.SampleClockRate;
myMaster.Timing.ConfigureSampleClock("", correctUpdateRate, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, outWF.GetLength(1));
myMaster.Control(TaskAction.Verify);
myMaster.Stream.Timeout = -1;
//Second the slave
mySlave.AOChannels.CreateVoltageChannel("Dev2/ao0", "", -10, 10, AOVoltageUnits.Volts);
mySlave.AOChannels.CreateVoltageChannel("Dev2/ao1", "", -10, 10, AOVoltageUnits.Volts);
mySlave.Timing.SampleClockRate = outputSampleRate;
mySlave.Control(TaskAction.Verify);
double correctSlaveUpdateRate = mySlave.Timing.SampleClockRate;
mySlave.Timing.ConfigureSampleClock("", correctSlaveUpdateRate, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples, outSlaveWF.GetLength(1));
mySlave.Control(TaskAction.Verify);
mySlave.Stream.Timeout = -1;
//Synchronize master and slave by using on-board clock
myMaster.Timing.ReferenceClockSource = "OnboardClock";
myMaster.Control(TaskAction.Verify);
mySlave.Timing.ReferenceClockSource = myMaster.Timing.ReferenceClockSource;
mySlave.Timing.ReferenceClockRate = myMaster.Timing.ReferenceClockRate;
mySlave.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger("/Dev1/ao/StartTrigger", DigitalEdgeStartTriggerEdge.Rising);
mySlave.Control(TaskAction.Verify);
myMasterWriter.WriteMultiSample(false, outWF);
mySlaveWriter.WriteMultiSample(false, outSlaveWF);
//Start the tasks
mySlave.Start();
myMaster.Start();
myMaster.Stop();
mySlave.Stop();
myMaster.Dispose();
mySlave.Dispose();
02-16-2012 12:03 AM - edited 02-16-2012 12:04 AM
Hi Dawdler,
Have you tried this code with different clock rates? And then, have you tried this setting a small delay between the start task command? Would you post your code in a file?
Regards,