Project: EOGee – Injecting Fake Signals with FakeEyes for Frequency Analysis

In order to further characterise and test the EOGee prototypes, it is important to be able to inject known signals and measure the output. This is not trivial, as the devices are configured to measure micro-volts of signal and a normal signal generator cannot synthesising a signal of such small magnitude. Secondly, the device takes a differential measurement, and so a differential signal is required rather than a single-ended one, as most signal generators produce.

To fix this issue I designed FakeEyes, a PCB to take a 3.3V peak single ended signal and convert it into a 1700uV peak differential signal.

FakeEyes PCB on a 3D printed base

The board is powered either via USB or a 5V header. The input signal is connected via the BNC connector at the bottom of the device. This signal is then converted to a differential signal before being divided down to the appropriate magnitude. Finally the signal is connected to the left and right electrodes of the EOGlass prototype via two U.FL coax connectors on the left and right extremes. A ground connection is also provided in the top middle, although this is not required.

FakeEyes Schematic

Firstly, U2B creates a mid-rail voltage, either from the voltage divider to create 1.65V or from an external voltage on J4, depending on the setting of jumper JP1. This is necessary for the conversion from a single-ended to a differential signal.

The signal from the signal generator is injected via J3 and is buffered by U2A. The signal is then inverted with respect to mid-rail by U2D. This signal is again inverted by U2C.

The signal at the output of U2C is the inverse signal of the signal at U2D with respect to the mid-rail. We then have a balanced resistor divider from R12, R14 and R13 which achieves a 1/1001x gain from the signal between J5 and J6 which connect to the EOGlass electrodes.

In the future I intend to do a more detailed analysis, of the FakeEyes design, including comparing a couple of different designs with respect to noise and offset. For now a full schematic can be found on my GitHub.

FakeEyes connected to the EOGlass2.1 prototype

With the design complete and manufactured, I connected the PCB to power, my signal generator and the EOGlass2.1 prototype. This allowed me to capture data from the EOGlass prototype while injecting sinusoidal signals of varying frequency.

1.3Hz sinusoidal data captured on the EOGlass prototype

I captured data ranging from 1.3Hz to 1584.9Hz. This allowed me to measured the magnitude of the output signal as a function of the input frequency. My initial algorithm used an FFT (Fast Fourier transform) to find the peak frequency in the data and find the magnitude of this frequency.

FFT of the 1.3Hz signal shows a peak around 1.3Hz which should be proportional to the signal size

I performed the FFT for each input frequency and found the output signal magnitude. I then plotted this data on a graph of input frequency vs output signal magnitude. However the result was not as smooth as I was expecting.

The problem comes from the limited resolution of the FFT algorithm. For example, with 10 seconds of data we only get a resolution of 0.1Hz. This means that it is very easy to miss the actual peak, for example if the signal is 1.3Hz but the FFT only calculates the magnitudes at 1.25Hz and 1.35Hz. This is the case seen above where the peak of the FFT is somewhere between two sample points.

Output signal magnitude as a function of frequency isn’t very smooth using this algorithm

In order to fix this I used the peak frequency of the FFT as an initial guess of the true frequency, with an uncertainty equal to the resolution of the FFT. I then sweep over the range of guesses at a much higher resolution and use IQ demodulation to find the frequency which provides the largest response. In the example below I sweep between 1.1Hz and 1.5Hz with a resolution of 0.01Hz to find the frequency with the largest response, corresponding to the true frequency of the signal.

Output of IQ demodulation over a range of frequencies shows the true peak at 1.3Hz

This new algorithm provided a much more accurate measurement of the frequency and magnitude of the output signal. Once again I repeated this algorithm for each different input frequency to create a graph of input frequency vs output signal magnitude – this time it was much smoother as expected.

Output signal magnitude as a function of frequency is much smoother using the new algorithm

The plot clearly shows a low pass response which allows low frequency signals to pass but rejects high frequencies. This is a result of a combination of the digital and analog filters used in EOGee.

The digital filter is a simple averaging filter. While the data is outputted to the computer at a sampling rate of 937.5Hz, the data is actually sampled at a frequency of 30kHz. The microcontroller takes an average of each group of 32 samples and reports that value (30000Hz/32 = 937.5Hz). We can simulate the response of this digital filtering in python by synthesising the input data sampled at 30kHz and then downsampling by 32 to observe the result.

We can also simulate the frequency vs magnitude curve of the analog filter using LTSpice.

LTSpice model of the low pass filter in the EOGee signal chain
Frequency response of: Measurement, Simulated Digital Filter, Simulated Analog Filter, Simulated Combined Analog+Digital Response

This plot shows the individual responses of the simulated analog and digital filters, along with the combined response of the two. The simulated combined response very closely agrees with the measured response and the two lines for measured and simulated data are almost perfectly overlaid.

While it is positive to see the simulation and measurement agreeing so closely, there is a problem. Specifically, at frequencies above the nyquist frequency (468.75Hz), we will see aliasing effects where high frequencies appear as low frequencies.

The simulated and measured input signal frequency vs output signal frequency

This plot confirms that input signals above the nyquist frequency are aliasing to lower output frequencies in the expected way which means, for example, that an input frequency of 1250Hz will appear at the output as a 312.5Hz signal. This is problematic because at this frequency we only see an 80% (-14dB) reduction is signal and the signal doesn’t reach 99% (-40dB) attenuation until around 1600Hz! This is due to the very slow frequency roll-off of the single-pole analog filter combined with the SINC shape of the digital filter which has large side-lobes.

Simulated frequency response of digital and analog filters over a much wider frequency range

This needs to be corrected in the next design as this may be creating unexpected artefacts and increased noise. The way to do this is to replace the analog filter with another filter with a sharper cut off frequency, so that frequencies at or above the nyquist frequencies are significantly attentuated.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s