Nowadays, lots of patients receive outpatient chemotherapy bringing a drop in their Neutrophils, which many cause life-threatening infection. However, to monitor their Neutrophils very often in hospital is quite costly and inconvenient. We want to develop a device simple for patients to use at home. Also, with counting the rough range of Neutrophils, the cost can be decreased to a acceptable level. In addition, it will be very user-friendly if we develop a UI with WIFI, Bluetooth and history storage function.

What we did and challenges we ran into

  1. Hardware We change several times for the circuit design. (1). We first built up a fundamental circuit with ESP32 connected to Camera and LCD Touchscreen. However, when we trying to connect the RTC, DS1302, we found that we already run out of all the useable pins on ESP32. It was a very serious problem because we still needed lots of pins for LED, switch and motor. (2). As a result, we make some changes. We changed DS1302 to PCF8523 because PCF8523 uses I2C which can share pins with LCD’s I2C pins. Also, we decided to use 74HC166 which is a parallel-in/serial-out shift register and can help us save 7 pins. However, when we tested the circuit, we found that the camera we use requires at least 10MHz which 74HC166 cannot follow. (3). We changed the design again and use two transparent latches, 74HC573, to handle the problem of lacking pins. And still for saving pins, we apply an inverter, 7404, so that we can use one pin of ESP32 to control the LE and OE of the latches at the same time. Finally, we solve the problem of lacking pins.

  2. Software (1). LCD driving The LCD we choose to use is the ILI9341, which is common and cheap. Compared to the 12864 LCD we used in previous Lab, this LCD is much more complex in several aspects: larger data which needs to be transferred, since this is 320x240 plus 2 byte color depth (RGB565); non-standard SPI interface, which needs to toggle Data/Command line for each communication; more configuring registers, as we need to specify contrast, brightness, driving voltage, sequential communication parameter, gamma correction and more to make it work. There are numerous libraries on the Internet, but they are mostly based on Arduino, which is heavy and based on bit-banging. This is not suitable for our application, as updating one frame to LCD will take up almost 1/2 second. And with bit-banging we will not be able to do anything else at the same time, which is not good for background tasks like wifi and Bluetooth. So we wrote a library from scratch to use hardware SPI and DMA to complete the data transfer. And we can then use interrupt with mutex semaphore to switch content back to rendering task. The DMA buffer has max length of 4094 bytes, so we used a DMA describer chain to hook up a series of DMA buffer to send entire frame. The toggling of D/C line is done by pre-transfer interrupt of SPI. (2). Camera driving We choose to use OV7670 as it is cheap and functional enough for our use. As the esp32 does not have dedicated driver for camera, we have to use some other solution to do the camera capturing. The OV7670 library for esp32 on the Internet is based on the version with FIFO buffer, which does not have frequency requirement for the device. But it is much more expensive and cost about 3 times than non-FIFO version. The difficulty for capturing with non-FIFO version is the camera has lowest frequency requirement of around 10MHz, and we are not able to read a byte from GPIO directly from ESP32 with given API in a single cycle, so we have to use something else to do the reading. There is a I2S peripheral on the esp32, which can be used to capture 16 bits data with external clock, so we can use this module to help.

3.Pump We use a stepper motor, a syringe and a tube to design and build up a cheap and functional pump. At first, the idea of the Penn medicine students about the pump was a blowing-air centrifugal pump. Then they changed their chip’s design to fit a sucking-air volumetric pump. Because the pump they use to test is a very expensive manual-controlled one, we decided to design our own pump by much more cheaper components whose volume, at the same time, can be controlled by our microcontroller. We chose a syringe and a tube with suitable size. And find a very cheap stepper motor (2.5V). Then after several times of trying, we came up with a way to fix the body of syringe and the motor on a paddle that cannot move and fix the end of syringe on the screw rod nut. We also design and build the complicated structure for the pump. Later, we came up with a design to fix on the switch on the board, so whenever the pump is going to reset, the stepper motor will not stop until it hits the switch, which bring a feedback to the microcontroller.

4.Mechanical We design an unbreakable and nice structure by laser-cutting acrylic to hold the whole system and case it by laser-cutting MDF. In the very beginning, we just held the camera and chip to test with rough stand and covered the structure with a box. In order to fix all the components of the system one thing for all, we learned SolidWorks from zero and finally design a structure by laser-cutting acrylic. The structure is fixed by lots of small part combined together and is mainly divided into several layers. The bottom layer is for pump made by syringe and stepper motor, which also have some structure to fix them on the bottom. The second layer is for the circuit. The third layer is just for camera. The forth layer is for chip to test. And there also a stand above it to hold the end of the tube which can perfectly fit into the chip.

What's next for Sanguis

Built With

  • c
  • esp-idf
  • esp32
  • ov7670
  • ili9341
  • drv8843
  • pcf8523
Share this project: