Reading from the Counter Input Channel
This example shows how to collect data from the SensorDAQ counter input channel using the Support Package. By default, the counter counts edges; that is, the number of times the signal has changed digital states.
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 counter input (pin 7 on the terminal block) to the session.
The first line retrieves one sample of counter data from the device and stores it in data. The second line tells MATLAB to display the data.
data = s.inputSingleScan; data %#ok<NOPTS>
data = 0
Note that data is 0 because no state changes were recorded in the short amount of time the counter was measuring data.
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 acquiring multiple samples 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