Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronize analog out and counter out..

Dear people, 

 

How can I synchronize analog and digital outputs? I would like to generate continuous waveforms by PXI-6333 in parallel with digital pulse trains made by PXI-6624. In the simplest the digital pulse trains can be just one pulse per one analog sequence. 

Here is my current program which has a problem that the analog outputs and digital lines are drifting little. The frequencies are not very high (speedRPM variable up to 3000).

 

Yours sincerely,

Ilkka

 

 

// Analog outputs

// The arbitary waveforms are stored in _combData and _fuelData arrays.

// Those two arrays have data from one revolution of a rotating machine.

 

public void StartAOs(double speedRPM)

{

int numSamples = _combData.Length; _genPressures = new Task("AOTask");_genPressures.AOChannels.CreateVoltageChannel("PXI1Slot2/ao0", "ao0", 0, 5, AOVoltageUnits.Volts);

_genPressures.AOChannels.CreateVoltageChannel("PXI1Slot2/ao1", "ao1", 0, 5, AOVoltageUnits.Volts);

double samplesPerSecond = numSamples * speedRPM / 60.0;

_genPressures.Timing.ConfigureSampleClock("", samplesPerSecond, SampleClockActiveEdge.Rising, SampleQuantityMode.ContinuousSamples, numSamples);

 

// One counter output starts analog waveform generation..

_genPressures.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger("PFI1", DigitalEdgeStartTriggerEdge.Falling);

_genPressures.Control(NationalInstruments.DAQmx.TaskAction.Verify);

 

// generate data buffers

int numChannels = _genPressures.AOChannels.Count;

double [,] data = new double[numChannels, numSamples];

for (int i = 0; i < numSamples; i++) data[0, i] = _combData[i];

for (int i = 0; i < numSamples; i++) data[1, i] = _fuelData[i]; AnalogMultiChannelWriter writer = new AnalogMultiChannelWriter(_genPressures.Stream);

writer.WriteMultiSample(false, data); //write data to buffer

 

_genPressures.Start();

}

 

// Simple digital pulses in two frequencies (later we would

// like to generate continous digital patterns but at the moment

// this is enough. So we would like to have one digital pulse per

// one analog output waveform and an other counter output which has

// 360 pulses..

 

public void StartPulseGenerator(double speedRPM)

{

_generatePulses = new Task("COtask");

double freq = speedRPM / 60.0;

_generatePulses.COChannels.CreatePulseChannelFrequency("PXI1Slot5/ctr0", "TDC", COPulseFrequencyUnits.Hertz, COPulseIdleState.Low, 0, freq, 0.1);

double numOfPulses = 360; // The second channel has 360 pulses

_generatePulses.COChannels.CreatePulseChannelFrequency("PXI1Slot5/ctr1", "Teeth", COPulseFrequencyUnits.Hertz, COPulseIdleState.Low, 0, freq * numOfPulses, 0.1);

_generatePulses.Timing.ConfigureImplicit(SampleQuantityMode.ContinuousSamples);

_generatePulses.Start();

}

0 Kudos
Message 1 of 2
(2,874 Views)
Hello IIkka

 

The little drifting you observe occur due to the fact that both PXI boards use their own clock for the signal generation. For a better Synchronisation between your analog and counter output i suggest that you use the clock of one board for both Outputs. To accomplish this task you will have to export the sampleclock of the first task to a RTSI Line and use this RTSI line as clock source for the task on the other board. To choose witch RTSI line to use you may have a look at the rooting table in MAX (Measurement and Automation Explorer).

 

Regards

Wetzer
0 Kudos
Message 2 of 2
(2,852 Views)