Setting the Analog Output Channel
This example shows how to output a voltage to the SensorDAQ analog output using the Support Package. Note that the channel will be set to this voltage until the device is reset or until the voltage is manually changed.
This line will always be the same for any Support Package function that uses the Session-based interface (all but digital io).
s = sdaq.createSession;
This line adds the analog output (pin 9 on the terminal block) to the session.
The first two lines tell the session to set the voltage of the analog output to 3 volts. The voltage can be set to anything between 0V and 5V.
voltage = 3; s.outputSingleScan(voltage); fprintf('Voltage level set to %d V\n',voltage);
Voltage level set to 3 V
Deleting the session object prevents it from interfering with other session objects. Always do this when you're done with the channel (including from within a script or function). This will prevent odd errors elsewhere.
Note that if you're planning on changing the voltage multiple times in one session, you don't have to delete the session until you're done. In fact, it's much faster to not have to create a new session every time you want data.
MATLAB Support Package for Vernier SensorDAQ Version 1.0