Data Acquisition Unit in the programmable terminals

(only for devices with 32-bit CPU, see feature-matrix / "DAQ")


  1. DAQ Principle
  2. DAQ Configuration
    1. Configuring DAQ channels to 'feed' Y(t)-diagrams
  3. Connecting DAQ channels to analog inputs (and similar onboard I/O)
  4. DAQ Sampling Rate
  5. DAQ Trigger
  6. Reading DAQ channel memories via Script
  7. DAQ Examples

1. Principle

The data acquisition unit (called DAQ hereafter) is a multi-channel digital sampler for signals received via CAN, or signals digitized by the onboard analog inputs, etc.

Samples acquired by the DAQ are first stored in a FIFO (circular buffer for all channels). This FIFO can be used as data source to plot the sampled data as a function of time with high resolution. In addition, certain devices can access the data in the FIFO via script, to process them in many ways (e.g. Fast Fourier Transform to analyse a signal's spectrum; e.g. find peak frequencies and magnitudes of vibrations in real time, etc).

DAQ block diagram and signal flow

For 'normal' displays (numeric, or as diagramm with sampling rates below 10 Hz), the DAQ unit is not required.
In most cases, the DAQ is used as fast-sampling sampling buffer for Y(t)-diagrams.

Key features:

When triggered (or periodically), the contents of the DAQ's channel memories can be plotted into the UPT's Y(t)-diagram, using the interpreter command dia.plot_daq .

2. DAQ Configuration

Normal sources for the measuring channels of the DAQ unit are defined on the Variables property of the programming tool. Use the checkmark in the right part of the definition screen:

To connect a variable to one of the DAQ channels, just set the checkmark Connect to DAQ Channel.
The programming tool will try to find the next unused DAQ channel, and automatically enter the channel number (index running from 0 to 7) into the edit field right next to the checkbox.
This way, the DAQ will know how to receive, and decode, a certain signal.

To disconnect a variable from the DAQ, uncheck the option. This will automatically remove the DAQ channel number from the variable definition table.

On a sufficiently large screen, you can see the DAQ channels 'occupied' by UPT display variables in the last column of the variable definition table:

Variable definition table with DAQ channel numbers shown on the right
The above screenshot was taken from application 'DAQ_test.cvt'.
In this example, the DAQ was used for a fast-running Y(t)-diagram.

2.1 Configuring DAQ channels to 'feed' Y(t)-diagrams

To (re-)configure an existing Y(t)-diagram to use the DAQ to achieve higher sampling rates, you can use the button labelled 'Connect XYZ to DAQ' (where XYZ is the variable name for the currently selected diagram channel, e.g. 'Motor_RPM') on the 'Channels, Mode, Timebase tab in the diagram configuration dialog.
The use of the button is almost trivial:
First select (mark) the desired diagram channel in the definition table (under 'Channels').
Only if the diagram channel's source is not a DAQ-channel yet (e.g. 'RPM' instead of 'daq[0]'),
the button mention above is enabled, and (for example) offers to Connect 'RPM' to DAQ.
The programming tool will automatically pick the next unused DAQ channel.

   Notes about the DAQ in combination with Y(t)-diagrams:
        The DAQ-channel-number is not necessarily equal to the diagram-channel-number !

        Since 2018-09, the firmware starts collecting data for diagrams
        before a diagram gets visible even without the DAQ.

3. Connecting DAQ channels to analog inputs (and similar onboard I/O)

In addition to UPT-'display'-variables, a DAQ channel can also be connected to any of the 'onboard' analog inputs (if such inputs exist). This allows sampling those inputs faster than possible by other means (like polling system.analog_in[] in a script).

DAQ channels and -options in the programming tool's main menu.
To assign DAQ channels to analog and similar inputs at design time, select
    'Options'..'Data Aquisition Unit' in the programming tool's main menu,
then select the channel (0..7) in the sub-menu, and enter the one of the following keywords in the input box (instead of the name of a display variable):
First 'onboard' analog input (exists in most 'MKT-Views', see Feature Matrix).
Scaling as for the corresponding script function system.analog_in[0] (floating point, 0 to 1.0 or -1.0 to +1.0).
Second 'onboard' analog input.
Scaling as for the corresponding script function system.analog_in[1] (floating point, 0 to 1.0 or -1.0 to +1.0).
3rd 'onboard' analog input (only exists in certain devices like MKT-View IV, on an extra connector like "X4")
4th 'onboard' analog input (only exists in certain devices like MKT-View IV, on an extra connector like "X4")

Microphone input. In devices like MKT-View IV, the microphone signal (from 3.5-mm connector "X8") can be fed into the DAQ like a high-gain analog input. For historical reasons, the value range is -32767 .. +32767.

state of the first 'onboard' digital input (0=logic low, 1=logic high)
state of the second 'onboard' digital input

frequency measured at the first 'onboard' digital input (only for certain devices; must be enabled and configured as described here)
frequency measured at the second 'onboard' digital input

number of pulses counted at the first 'onboard' digital input (only for certain devices; must be enabled and configured as described here)
number of pulses counted at the second 'onboard' digital input

The names (tokens) listed above can also be used in the channel definitions of a diagram (Y(t) or X/Y plotter).
If a DAQ channel is already 'occupied' by a variable, it will have the variable's name shown in the list (see screenshot).
By clearing or overwriting the name in the input box, the old variable will be 'disconnected' from the DAQ, and the channel can be connected somewhere else (see list above).

4. DAQ Sampling Rate

All channels connected to the Data Acquisition Unit are sampled at the same rate (same number of samples per second). Since the DAQ is usually (but not necessarily) used to collect data for a diagram, the sampling rate will be automatically set to match the diagram's 'timebase'-setting.

But in some cases, you may want to use the DAQ unit for other purposes (without a diagram, for example to collect data in the DAQ's array for processing via script). To define the DAQ sampling rate, and allow the DAQ to 'collect data' even if there is no diagram, select
    'Options'..'Data Aquisition Unit'..'Sample Rate' in the programming tool's main menu,
and enter the desired sampling rate (measured in Hz aka 'samples per second) in the dialog box.

The maximum realizeable sampling rate was 1000 Hz for older devices (like MKT-View, MKT-View II).
For devices with a faster CPU, much more can be achieved (MKT-View IV : 20 kSamples/second).
To develop 'portable' applications suitable for old hardware, keep the sampling rate as low as possible to keep the CPU load low.

5. DAQ Trigger

Note: The features described in this chapter are a work-in-progress, and currently only available in the most recent 'Beta' of the programming tool and device firmware for MKT-View IV !
Until finished, details are only available in the German variant of this document.

6. Reading DAQ channel memories via Script

Besides feeding diagrams with fast-sampled input, the DAQ unit can also be used for digital signal processing via script. The script command

  daq.read_channel( <DAQ channel number>, <destination array> );
can be used in your scripts to read data from a DAQ channel into an array variable. An example using this function can be found in the test/demo application 'DAQ-Test' (in the programming tool, under programs/DAQ_Test.cvt ). This demo uses the DAQ to retrieve blocks of samples from the microphone input (or other analog inputs), then uses an FFT to calculate the short-time spectrum, logarithmizes the result, and plots the spectrum into a diagram as explained here.

Since November 2018, arrays declared in your script can not only store samples (and the number of samples), but also a timestamp (<Array-Name>.unix_time) and the sampling interval (<Array-Name>.t_sample, which is the reciprocal of the sampling rate). No extra variables need to be declared for this. The command daq.read_channel uses these components of the array-header to store the timestamp of the most recent sample in the array, and the time between two sample points. When plotting such arrays in a multi-channel Y(t)-diagram, these timing parameters are used for the horizontal scaling.
If this automatism is not desired, the script can always overwrite these parameters in the array-header after calling daq.read_channel.

6. DAQ Examples

A few DAQ examples are in the file DAQ_test.cvt (located in the programming tool's "programs" folder). The application consists of several display pages:

On the first display page ("Analog"), the DAQ is used to collect samples from analog inputs (and, when available, the microphone input) for a simple Y(t)-diagram (here: digital storage oscilloscope for low-frequency signals). This simple example does not require a script - just connect a diagram channel to a DAQ channel, the firmware will to the rest.

Example for a diagram fed with analog inputs via DAQ (here: first page in 'DAQ_Test.cvt'),
running with 20 kSamples/second on an MKT-View IV.

For the second display page ("CAN"), the DAQ collects samples from received CAN messages, with 1000 samples / second (more would be possible from the DAQ's point of view, but it's not realistic with a CAN bus at 500 kBit/second).
Waveforms of some signals received via CAN, collected by the DAQ with 1000 samples/second.
Also taken from applikation 'DAQ_Test.cvt', 2nd page, here running on an MKT-View IV.

The third display page uses the DAQ to collect 'audio samples' as explained here, which are then processed via script (using the FFT) as explained here. .
Example for a diagram with background image (here: spectrogramm from 'DAQ_Test.cvt').
Uses the DAQ to collect samples for the FFT from the MKT-View's microphone input.
The spectrogram (in the background of the curve) is painted via script into a Canvas object.

Last modified: 2018-12-08 by WB / MKT Systemtechnik .