Reducing STM32 SPI HAL Latency

As part of my latest EOGee design, I have four devices on a single SPI bus – two 12-bit ADCs and two 12-bit DACs. Each of them is operating at 30kHz, which means that every 33us I have to send or receive 16-bits of data to each of them.

STMicro provide a HAL library which makes sending SPI data really simple using their commands HAL_SPI_Transmit_IT and HAL_SPI_Receive_IT.

So in theory it should be as simple as calling each of these functions four times sequentially, every 33us. With a clock speed of 10MHz, each transaction should take about 1.6us which would easily fit inside the 33us. However it turns out that the HAL library is very inefficient when it comes to small transactions.

Continue reading “Reducing STM32 SPI HAL Latency”

Mini Project: Monoprice 3D Printer Modification for Flexible Filament

About a year ago I decided to purchase a 3D printer. I didn’t need anything too fancy, and I didn’t want anything too big. I settled on a Monoprice MP Select Mini 3D Printer V2 which is a small desktop printer for about $200.

I’ve been very impressed with it’s reliability – it has only needed to be tuned once since I set it up, and since then it very rarely fails a print using PLA. But for an upcoming project I want to print in a flexible material, so I ordered some TPU filament from Sainsmart.

Continue reading “Mini Project: Monoprice 3D Printer Modification for Flexible Filament”

Project EOGee: EOGlass1

I want to develop the EOG algorithms to do something useful, but having three electrodes dangling from your head and plugged into a box is quite uncomfortable and annoying. This is a frustration that I have seen echoed in papers, for example Bulling and Gellersen report the difficulties of capturing a labelled dataset in their paper Robust Recognition of Reading Activity in Transit.

Continue reading “Project EOGee: EOGlass1”

Project EOGee: EOGee2 and DC Coupling, Part 3

The main barrier to getting a DC coupled signal using EOGee1 was that the DC offset voltage of the EOGee signal was much larger than the actual signal itself. Because the signal itself is so small we need a large gain to amplify it, but this also amplifies the offset voltage which then saturates the amplifier.

My solution is to use a signal chain like this:

sigchain

EOGee2 Signal Chain

Continue reading “Project EOGee: EOGee2 and DC Coupling, Part 3”

Project: EOGee – Noise, Part 1

Previously we have focused on the mains interference component of noise in the EOG signal. This is because it has been the dominant source. However we have seen that this noise can be significantly reduced with appropriate shielding and we could reduce it further still with shorter leads.

Now that the 60Hz noise is reduced, there is a very clear spiking signal coming from somewhere. The signal does not have any obvious periodicity but it is significantly larger than the other noise and also generally affects only one sample. It is easier to see the noise if I remove R108 which means that the final gain stage is disconnected from previous gain stages so the ADC is driven to midrail and is not affected by 60Hz noise at the input.

Screenshot 2020-04-11 at 17.58.50

The signal spikes occasionally

Continue reading “Project: EOGee – Noise, Part 1”

Project: EOGee – DC Coupling Part 2

A couple of posts ago I discussed the reason that the current circuit is AC coupled rather than DC coupled, and managed to get DC coupling briefly working. The advantage of this is that it enables us to measure the absolute voltage across the eyes, rather than just the changing voltage, which gives us more information. Now I am going to address how we can get to a fully DC coupled solution to work all the time.

Continue reading “Project: EOGee – DC Coupling Part 2”

Project: EOG – Making PCB Snap Connectors

Now that I have an EOG system working to some extent, it is inconvenient to wire myself up each time I want to take a measurement. Not to mention that the silver chloride electrode pads are single use which is wasteful and expensive (I reuse them multiple times, but the connection and adhesion definitely degrade). On top of this, I don’t like being connected to the system while it is connected to any mains powered device due to risk of an electrical fault being directed straight to my head – I can unplug my laptop, but my oscilloscope isn’t battery powered. So I decided to make an adapter from my signal generator to the snap connectors so I can inject false EOG signals.

Continue reading “Project: EOG – Making PCB Snap Connectors”

Project EOGee: Analog Analysis and DC Coupling Part 1

As of the last post, the digital aspect of the project is mostly pulling its weight. Although we are filtering the 60Hz noise in the digital domain, I mentioned that it would be ideal to prevent the noise in the first place by improving the analog side. There are three aspects I want to start diving into.

The first is shielding the signal –  a lot of the noise is picked up on the long wire from the electrode to the device and this can be improved by shielding the wires (potentially more complex than it sounds). Secondly, I want to better understand the analog signal path that is based on the backyard brains design and where it can be improved to lower noise and provide a larger signal. Finally I want to try and DC couple the signal, rather than using AC coupling as is currently the case. With AC coupling we are only able to detect movements of the eyes, and not absolute positions. Today we will be looking mostly at the second, and skimming the surface of the third.

Continue reading “Project EOGee: Analog Analysis and DC Coupling Part 1”