Estimate State for Digital Clock

This example shows how to estimate the high and low state levels for digital clock data. In contrast to analog voltage signals, signals in digital circuits have only two states: HIGH and LOW. Information is conveyed by the pattern of high and low state levels.

Load clockex.mat into the MATLAB® workspace. clockex.mat contains a 2.3 volt digital clock waveform sampled at 4 megahertz. Load the clock data into the variable, x, and the vector of sampling times in the variable, t. Plot the data.

load('clockex.mat','x','t')
stem(t,x,'markerfacecolor',[0 0 1]); xlabel('Seconds'); ylabel('Volts');

Determine the high and low state levels for the clock data using statelevels.

levels = statelevels(x)

The low-state level estimate is 0.0027 volts and the high-state level estimate is 2.3068 volts. This is the expected result for the 2.3 volt clock data, where the noise-free low-state level is 0 volts, and the noise-free high-state level is 2.3 volts.

Use the estimated state levels to convert the voltages into a sequence of 0s and 1s. The sequence of 0s and 1s is a binary waveform representation of the two states. To make the assignment, use the following decision rule. Assign any voltage within a 3%-tolerance region of the low-state level the value 0, and any voltage within a 3%-tolerance region of the high-state level the value 1.

Determine the 3%-tolerance region around the low-state level.

lowtol = [levels(1)-3/100*(levels(2)-levels(1)) ...
    levels(1)+3/100*(levels(2)-levels(1))];

Determine the 3%-tolerance region around the high-state level.

hightol = [levels(2)-3/100*(levels(2)-levels(1)) ...
    levels(2)+3/100*(levels(2)-levels(1))];

Use logical indexing to determine the voltages within a 3%-tolerance region of the low-state level and the voltages within a 3%-tolerance region of the high-state level. Assign the value 0 to the voltages within the tolerance region of the low-state level and 1 to the voltages within the tolerance region of the high-state level. Plot the result.

y = zeros(size(x));
y(x>= lowtol(1) & x<= lowtol(2)) = 0;
y(x>= hightol(1) & x<= hightol(2)) = 1;
subplot(211)
stem(t,x,'markerfacecolor',[0 0 1]); ylabel('Volts');
subplot(212)
stem(t,y,'markerfacecolor',[0 0 1]); ylabel('{0,1}'); xlabel('Seconds');
set(gca,'ytick',[0 1])

The decision rule has assigned all the voltages to the correct state.

Was this topic helpful?