AnsweredAssumed Answered

2351A / 235x C continuous analog w/3 x counter pulse width

Question asked by RDeveloper on Aug 27, 2012
Latest reply on Aug 30, 2012 by thong-lin_tan
Hi, I am ramping up on controlling instruments for a project and can use some assistance. In C# I have the continuous measurement of analog in 1-3 working based off an example program. Also working is the acquisition of 3 pulse widths on Counter1. I am trying to combine them so they happen in parallel. My first try was to just spawn tasks to call each function ... but it either serializes the acquisition or generates errors.

Can both these methods (see below, mostly based off of the C# example code) be running at the same time?

1. The essential C# code in function captureAnalogChannels():
                IAgilentU235xAnalogInMeasurement analogMeasure = this.driver as IAgilentU235xAnalogInMeasurement;
                ...
                while (DateTime.Now < endCaptureTime)
                {
                    ...
                    try
                    {
                        analogMeasure.ReadMultiple(channelList, ref rawResults);
                        for (int i = 0; i < pwWorkItem.getAnalogChannelCount(); i++)
                        {
                            channelResults[i].recordMeasurement(rawResults[i]);
                        }
                        ...

2. The essential C# code for the function capturePulseWidth():
                IAgilentU235xCounters counters = this.driver as IAgilentU235xCounters;
                IAgilentU235xCounter counter1 = counters.get_Item("Counter1");

                counter1.Totalizer.InitialValue = 0;
                counter1.Totalizer.Direction = AgilentU235xTotalizerDirectionEnum.AgilentU235xTotalizerDirectionIncrement;
                counter1.GateSource = AgilentU235xCounterGateSourceEnum.AgilentU235xCounterGateSourceInternal;

                counter1.Measurement.Function = AgilentU235xCounterMeasurementEnum.AgilentU235xCounterMeasurementPulseWidth;

                for (int i = 0; i < pulseCount; i++)
                {
                    try
                    {
                        counter1.InternalGateEnabled = true;

                        double dataValue = counter1.Measurement.PulseWidth;

                        counter1.InternalGateEnabled = false;
                        counter1.Totalizer.Clear();
                        ...

Edited by: developer@signalfury.com on Aug 27, 2012 9:53 AM  

Outcomes