Data Acquisition Toolbox    

Example: Writing and Reading Digital Values

This example illustrates how to read and write digital values using a line-configurable subsystem. With line-configurable subsystems, you can transfer values on a line-by-line basis.

You can run this example by typing daqdoc7_1 at the MATLAB command line.

1. Create a device object - Create the digital I/O object dio for a National Instruments board. The installed adaptors and hardware IDs are found with daqhwinfo.

2. Add lines - Add eight output lines from port 0 (line-configurable).

3. Read and write values - Write a value of 13 to the first four lines as a decimal number and as a binary vector, and read back the values.

Write a value of 3 to the last four lines as a decimal number and as a binary vector, and read back the values.

Read values from the last four lines but switch the most significant bit (MSB) and the least significant bit (LSB).

4. Clean up - When you no longer need dio, you should remove it from memory and from the MATLAB workspace.


 Reading Digital Values Generating Timer Events