Increased sampling rate through measurement data interlacing of channels
Some EtherCAT analog inputs support distributed clocks, i.e. the measured value acquisition is triggered cyclically by the local clock. This feature can be used to have two devices scan the electrical signal alternately on a timer-controlled basis. The two data streams can then be combined (interlaced) on the control side so that the effective sampling rate of the signal is twice as high as when sampling with just one channel.
This example shows the implementation of a 200 ksamples/s (ksps) analog value acquisition with two EL3702 (100 ksps each).
- Task: A ±10 V analog signal with 50 kHz is to be sampled. It is a bit data stream that is coded in amplitude. For the sake of simplicity, a sinusoidal signal is considered, this shows the maximum number of level changes (50 kHz ~ 100 kbit).
- Experiment: An EL3702 is operated with 10x oversampling and a TwinCAT EtherCAT cycle time of 100 µs, thus achieving a sampling rate of 100 ksps or 10 µs sample difference. This is 2 times the signal frequency, could therefore theoretically (Nyquist/Shannon) be just enough to see all level changes.
- At the beginning the signal is 10 kHz:
The levels of terminal channel 1 are still clearly visible in the TwinCAT Scope
Electrically, care must be taken in such experiments to ensure that the source (here: signal generator) can drive against the impedance of the analog channel (here: EL3702 with industry-compatible 220 kOhm) and that the amplitude does not collapse on the generator side.
- Signal 50 kHz
The terminal can no longer detect a continuous signal; due to the frequency similarity (multiples) of 100 µs to 50 kHz with a very slight deviation, a beat effect occurs.
At all frequencies around 50 kHz, a changed beat frequency can be recognized (here: 49 kHz).
Peak values can be seen depending on the position, but in some sections with small amplitudes that are not usable:
Note: 16-bit INT values are recorded. However, a scale factor is entered in the TwinCAT Scope, which enables the display on the ±10 V Y-axis.
- The signal is now applied to channel 1 of both terminals.
Note: The two channels of the EL3702 work simultaneously, therefore a second terminal must be selected for an interlacing (= time-delayed measurement). The second channel cannot be operated with a time delay to the first.
- In the EtherCAT Distributed Clocks settings, the 2nd terminal is "shifted" by +5 µs.
In this example, the default value "-10 µs" results in "-5 µs". - In the PLC, the code is:
Both data streams are therefore interlaced in the TwinCAT PLC:
Display of the interlaced 49 kHz signal in TwinCAT Scope
It is easy to see that the interlaced signal results from the addition of both signals.
- The originally tracked 50 kHz signal is now recognizable with a temporal resolution of 5 µs. Beat effects no longer play a role due to the 4-fold higher sampling rate.
With this data, it is now possible to carry out a clear evaluation of the levels and bits and thus achieve the experimental goal. A simple bit interpretation "Amplitude > 0 = TRUE" delivers the 10 µs bits cleanly for a signal "1000" with analog f=25 kHz, DutyCycle = 25 %:
Note input attenuation With such a concept, it is important to consider the input attenuation of the analog inputs used. Although the effective measurement data rate is doubled, the input characteristic (keyword: cut-off frequency, -3 dB point) is not increased. |
TwinCAT filter library TF3680 The TwinCAT filter library TF3680 can be used to attenuate or amplify the analog signal in a frequency-selective manner. |