Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Triggering PCI-6250 boards via RTSI

I have two PCI NI-6250 boards named  'Dev1' and 'Dev2' that are connected via an RTSI cable named 'RTSI0'. I am trying to set them up via a C# program so that Dev1 is the master and Dev2 follows Dev1's timing and trigger signals.

 

I wrote an object named DAQmxSingleChannel which represents a single NI-6250 board. By itself it runs and collects a set number of samples just fine. However, when I try to tie the timing and trigger of the two boards together in a second object named DAQmxDualChannel the data collection never starts.

 

The code listing below is from DAQmxDualChannel where I am setting up the data collection parameters. In this case ch1 represents Dev1 and ch2 represents Dev2:

 

 

            // configure channel 1 for internal clock and no trigger
            ch1 = new DAQmxSingleChannel();
            ch1.PhysicalChannelName = "Dev1/ai0";
            ch1.ReferenceName = "ch1";
            ch1.ClockSource = "";
            ch1.StartTriggerType = StartTriggerType.None;
            ch1.TriggerSource = "/Dev1/ai/StartTrigger";
            ch1.SampleRate = 1000000;
            ch1.Samples = 1000;

            // configure channel 2 for external clock and RTSI cable trigger
            ch2 = new DAQmxSingleChannel();
            ch2.PhysicalChannelName = "Dev2/ai0";
            ch2.ReferenceName = "ch2";
            ch2.ClockSource = "/Dev1/ai/SampleClock";
            ch2.StartTriggerType = StartTriggerType.DigitalEdge;
            ch2.TriggerSource = "RTSI0";
            ch2.SampleRate = 1000000;
            ch2.Samples = 1000;

            // start ch2 first since it will wait for ch1 
            ch2.Start();
            ch1.Start();

 

 

Am I naming the timing or trigger signals incorrectly, or is something else going on here? I've attached the full code of both single and dual channel objects to this post in case it is needed.

 

Thanks!

 

Download All
0 Kudos
Message 1 of 4
(3,617 Views)

Estiers,

   This seems interesting. Why did you not select a ClockSource for ch1? Have you had any progress since this post?

 

Regards from Austin,

 

Ben J.
National Instruments
Applications Engineer
0 Kudos
Message 2 of 4
(3,593 Views)

Ben J-

 

Thanks for the reply, I *think* I made some progress this afternoon - the cards are getting triggered and data is getting collected now at least.

 

I didn't select a clock source for ch1 specifically in the initial code - my very thin understanding of DAQmx leads me to believe that specifying that channel as an empty string causes it to use its internal clock. I could be wrong, I'm very new to DAQmx. Anyway, I re-wrote the code to just include two Tasks instead of representing each DAQ board with its own object, and gave specific timing info to each Task just to be certain of what they were doing.

 

The code that worked in terms of collecting data is listed below. The one thing that I'm not confident of is the RTSI routing. It seems I can specify signals from the Dev1 card as inputs for the Dev2 card which suggests that these signals are routed automatically, but I'd love to know how to verify that this is true. Our measurement is very sensitive to clock skew between the two cards so checking that the RTSI signals are properly routed would put a lot of minds at ease.

 

Best regards,

Eric

 

 

 

        void IDAQmxCards.ColectData()
        {
            // set up channel 1
            try
            {
                task1 = new Task("Task1");

// Channel definition aiChannel1 = task1.AIChannels.CreateVoltageChannel( "Dev1/ai0", "Dev1_ai0", AITerminalConfiguration.Differential, ch1MinVoltage, ch1MaxVoltage, AIVoltageUnits.Volts );
// Sample Clock task1.Timing.ConfigureSampleClock( "OnboardClock", sampleRate, SampleClockActiveEdge.Falling, SampleQuantityMode.FiniteSamples, samples );
task1.Control(TaskAction.Verify); task1.Done += new TaskDoneEventHandler(Task1_Callback); } catch (DaqException dEx) { MessageBox.Show(dEx.Message, "NI-6250 Ch1 Error"); task1.Stop(); task1.Dispose(); } // set up channel 2 try { task2 = new Task("Task2");
// Channel definiton aiChannel2 = task2.AIChannels.CreateVoltageChannel( "Dev2/ai0", "Dev2_ai0", AITerminalConfiguration.Differential, ch2MinVoltage, ch2MaxVoltage, AIVoltageUnits.Volts );
// Sample Clock -> use Dev1 clock task2.Timing.ConfigureSampleClock( "/Dev1/ai/SampleClock", sampleRate, SampleClockActiveEdge.Falling, SampleQuantityMode.FiniteSamples, samples );
// Trigger off Dev1 StartTrigger task2.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger( "/Dev1/ai/StartTrigger", DigitalEdgeStartTriggerEdge.Falling );
task2.Control(TaskAction.Verify); task2.Done += new TaskDoneEventHandler(Task2_Callback); } catch (DaqException dEx) { MessageBox.Show(dEx.Message, "NI-6250 Ch2 Error"); task2.Stop(); task2.Dispose(); } // Start tasks, begin task2 first since it will wait for signals from task1 task2.Start(); task1.Start(); }

        // Callbacks
        void Task1_Callback(object sender, TaskDoneEventArgs e)
        {
            // read
            AnalogSingleChannelReader reader = new AnalogSingleChannelReader(task1.Stream);
            ch1Data = reader.ReadMultiSample(samples);

            // stop task and release hardware
            task1.Stop();
            task1.Dispose();
        }
        void Task2_Callback(object sender, TaskDoneEventArgs e)
        {
            // read
            AnalogSingleChannelReader reader = new AnalogSingleChannelReader(task2.Stream);
            ch2Data = reader.ReadMultiSample(samples);

            // stop task and release hardware
            task2.Stop();
            task2.Dispose();
        }

 

 

0 Kudos
Message 3 of 4
(3,586 Views)

Hi Eric,

 

I'm not terribly familiar with .NET, but you are correct that you can route the trigger signal from the master to the slave via the RTSI cable. As long as you have the cable connected properly and you are specifying the source of the task2 trigger as the task1 ai start trigger, your devices will be synched.

 

Thanks,

0 Kudos
Message 4 of 4
(3,573 Views)