Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Avoid voltage reseting to zero at the end of a sequenced multi-sample write on NI USB-6343 using DAQmx C# driver

My objective is to generate hardware timed sequences of tensions on three alalog outputs of a NI USB-6343 (eom) card. I managed to make it work with the following code:

```
PathWriteTask = new DAQmx.Task();

DAQmx.AOChannel aOChannelX = PathWriteTask.AOChannels.CreateVoltageChannel(
DaqName + "/" + XAxisPin, "XAxisChannel", 0, 10, DAQmx.AOVoltageUnits.Volts);
DAQmx.AOChannel aOChannelY = PathWriteTask.AOChannels.CreateVoltageChannel(
DaqName + "/" + YAxisPin, "YAxisChannel", 0, 10, DAQmx.AOVoltageUnits.Volts);
DAQmx.AOChannel aOChannelZ = PathWriteTask.AOChannels.CreateVoltageChannel(
DaqName + "/" + ZAxisPin, "ZAxisChannel", 0, 10, DAQmx.AOVoltageUnits.Volts);

// Verify the task is correct (not sure what it does yet)
try {
PathWriteTask.Control(DAQmx.TaskAction.Verify);
} catch (Exception) {
State = CONTROLLER_STATE.ERROR;
throw;
}

// Set sample type to following sample clock ticks
if (PathWriteTask.Timing.SampleTimingType == DAQmx.SampleTimingType.OnDemand) {
PathWriteTask.Timing.SampleTimingType = DAQmx.SampleTimingType.SampleClock;
}

// Configure Sample clock
PathWriteTask.Timing.ConfigureSampleClock(
"", // "" for hardware clock
(TargetVelocity * 1000) / Precision, // clock frequence
DAQmx.SampleClockActiveEdge.Falling,
DAQmx.SampleQuantityMode.FiniteSamples,
300 // number of samples
);

// Create writer
pathAnalogWriter = new DAQmx.AnalogMultiChannelWriter(PathWriteTask.Stream);

// Write some data
pathAnalogWriter.WriteMultiSample(false, data);
PathWriteTask.Start();
// Block thread until task is over
PathWriteTask.WaitUntilDone();
// Stop the task so it can be re-started later
PathWriteTask.Stop();
```

 

My problem is that after the last sample is generated, the tension goes back to 0. I would like it to stay at the last tension sent. How may I do this ?

0 Kudos
Message 1 of 1
(589 Views)