Analog I/O Demo 3 -- Acquiring data on the analog to digital converter ================================================================================== .. Note:: You can only use ADC/DAC with the full version of a device; the lite version does not have ADC/DAC capabilities. This demo generates data on the DAC0 and 1, which is then read continuously on ADC 0/1 using an internal loop-back. As in Demo 1, we must set up the ADC schedule with the right terms. This time, since we are continuously buffering the values, the 4th argument is set to zero. ``Datapixx('SetAdcSchedule', 0, adcRate, 0, [0 1], adcBuffBaseAddr, nAdcBuffFrames);`` The first zero is the schedule start delay, the adcRate was defined before as 10000 Hz, the second zero here means this schedule will run until we stop it by hand: ``Datapixx('StopAdcSchedule');``, ``[0 1]`` means we are looking at ADC 0/1, ``adcBuffBaseAddr`` is where the data will be in the ram and ``nAdcBuffFrames`` is how much memory is allocated to buffer data. In this case, ``nAdcBuffFrames`` is defined to be ``100*adcRate``, therefore it will be able to contain 100 seconds of data. We can then read the buffer and its time tags at regular intervals using ``Datapixx('ReadAdcBuffer', nReadFrames, -1);`` ``nReadFrames`` is the number of data available, and can be obtained using ``status = Datapixx('GetAdcStatus');`` ``nReadFrames = status.newBufferFrames;`` The ``-1`` signifies we use the same buffer defined in the previous ``SetAdcSchedule`` call (a buffer starting at ``adcBuffBaseAddr``). .. literalinclude:: ../DatapixxToolbox/DatapixxDemos/DatapixxAdcStreamDemo.m :language: matlab :emphasize-lines: 45, 48, 65, 66, 79 :linenos: