Data Acquisition Toolbox | ![]() ![]() |
Example: Generating Timer Events
This example illustrates how to generate timer events for a digital I/O object. The action function daqaction
displays the event type and device object name. Note that you must issue a stop
command to stop the execution of the digital I/O object.
You can run this example by typing daqdoc7_2
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
.
dio = digitalio('nidaq',1);
2. Add lines - Add eight input lines from port 0 (line-configurable).
addline(dio,0:7,'in');
3. Configure property values - Configure the timer event to call daqaction
every five seconds.
set(dio,'TimerAction','daqaction') set(dio,'TimerPeriod',5.0)
Start the digital I/O object. You must issue a stop
command when you no longer want to generate timer events.
start(dio)
4. Clean up - When you no longer need dio
, you should remove it from memory and from the MATLAB workspace.
delete(dio) clear dio
![]() | Starting and Stopping a Digital I/O Object | Evaluating the Digital I/O Object Status | ![]() |