Thursday, February 18, 2021

Working with MAX30100 and MAX30102 Blood Oxygen SPO2 Detector

 I am working with the MAX30100 and MAX30102 Blood Oxygen SPO2 Detectors trying to get them to work.  First I bought the MAX30100 and then later the MAX30102 but they did not work.  I have tried several libraries to no avail.  Then, finally, I came across the issue that the 4.7K pull up resistors are tied to 1.8 volts and they are not high enough for a five volt processor.  

The first solution is to remove the three 4.7K resistors (marked 472 in the picture) and replace them with external 4.7K resistors to 3.3 or even 5 volts.  The second solution is to cut the run connecting them to 1.8 volts and jumper them over to the 3.3 volt regulator.  The run to cut is marked in yellow in the following picture and then add the jumper marked in red.

This is a simplified schematic of the circuit board. Basically there are two voltage regulators.

Once that change is made the MAX30100 works great.  The "Minimum" example gives beat detection, BPM and SPO2 to the Arduino serial monitor.  Just add a little code and redirect it to a LCD and this is what you get.

However the MAX30102 requires a different library and I could not find one nearly as good as the library for the MAX30100.  Someone has commented that not only is the device ID different (15 instead of 11) but the register addresses are also different.  Well, not only that, but the register for the LED's changes to one register (4 bits per LED) to two registers (8 bits per LED)! 

I decided to fork the MAX30100 library and make it into a MAX30102 library.  It is not nearly as easy as changing the register numbers!  Here is what I have done so far:
1. Copy all src files and rename them as MAX20102_XXXX
2. Edit all src files contents to replace MAX30100 wit MAX30102
3. Change device ID from 11 to 15
4. Change registers as follows:
    A. 01->02
    B 02->04
    C 03->05
    D 04->06
    E 05->07
    F 06->09
    G 07->0A
    H 09->0C and 0D
    I 16->1F
    J 17->20
5. Create second LED2_PA register (addx 0D above)
6. Biggest issue:  MAX30100 has 16 bit analog converters fitting into 2 byte transfers.
                            MAX30102 has 18 bit analog converters fitting into 3 byte transfers!
Here is the solution (I think) I wasted 2 bits of data but fit it into 16 bits:
              .red=(uint16_t)((buffer[i*6+3]<<14)|(buffer[i*6+4]<<6)|buffer[i*6+5]>>2) });

Wednesday, February 10, 2021

I am working on an update to the 6DOF Servo Arm project

 I am updating the 6DOF Servo Arm project.  The old arm had some issues.  Like the servos at the wrist position jammed on each others limiting the range of motion.  Here is a picture of the old arm.

This is what the new arm looks like.  Note the spacer in the middle and how the last two servos are connected together.  This arrangement gives a much better range of motion.

First I need to improve the "Claw".  The clear plastic claw looks better if it is painted black.  But the plastic where it attaches keeps breaking, so I made an aluminum bracket to do the job.

Then I needed to improve the controller.  The servo or I/O shield for the Arduino has many issues that I have covered in another post.  I thought I would use the Nano Shield as the Nano has two more outputs that ne Uno.  Those being A6 and A7.  That way it can run 21 servos!  But the Nano shield could not even run six servos without smoke rolling out of it.  The problem is that the five volt power source on the shield uses the five volt regulator located on the Nano and it is woefully underpowered.  To fix it I cut the run to the 5V pin of the Nano (Circled in red in the picture below) and then jumpered the power input to the 5V terminal.  At first I had jumpered the VIN terminal to the 5V terminal, but then smoke rolled out of the diode that is between the input jack and the VIN pin to protect against reversing the power.  That diode also costs you about 1 volt of power to the servos and at four volts they do not work very well at all.

A video of the first successful test run is on YouTube: