Closed Gruftgrabbler closed 2 years ago
Hi Gruft,
that's a good question.
As far as I know, there are at least two factors which impact the acquisition frequency that you can obtain.
The first one involves the sensor itself. It is designed to be fully configurable in terms of led brightness, pulse width, length of the array of averaged samples, ADC range; however, as you may read on Maxim datasheet (page 23), some of the combinations of the previously mentioned parameters do not work as expected (while they're still allowed by the driver), because of technical limits such as delays in A/D conversion.
The second one involves the MicroPython port for ESP32. As can be seen on MicroPython docs, MicroPython is implemented on top of the Espressif’s development framework for the ESP32, which is a real-time OS (FreeRTOS). This additional layer makes your μPython applications run much slower than they would do as bare-metal C++ applications.
While a MicroPython application is much faster to deploy, it is important to check the real obtained rate, and this is the reason why I decided to provide a simple way to check the real acquisition speed.
It seems strange to me that you are not able to reach 50Hz. May you describe your equipment, please? Are you using a genuine Maxim sensor?
I will also try the 800, 8
configuration as soon as I have some spare time.
Bye, Nicola
Hi Gruft,
I think that the very first value of the measured acquisition frequency is often higher because the sensor is faster at the beginning (can't explain why, tho).
I tested with (800, 8) and the sensor initialization is returning an acquisition frequency of 100Hz (period 10ms). However, the system isn't able to reach 100Hz with the default values.
Please do a test using these parameters:
from lib.MAX30102 import MAX30105_PULSEAMP_LOWEST
sensor.setADCRange(2048)
sensor.setPulseWidth(69)
sensor.setActiveLEDsAmplitude(MAX30105_PULSEAMP_LOWEST)
sensor.setSampleRate(800)
sensor.setFIFOAverage(8)
and let me know if you're able - as me - to reach 100Hz acquisition frequency.
Bye, Nicola
Thank you for your comments. I am going through them carefully asap.
I just made a test on an Arduino UNO using the Sparkfun MAX30105 Library
The result of this single experiment yields the exact sample thing. So it is definitely not a micropython thing.
Thank you and Cheers
In fact. Using exactly your sensor configuration yields a acquisition frequency of 86. I am using a raspberry pi pico, but could run the test on an esp32 which has twice the clock speed.
INFO:MAX30102:(MAX30105) MAX3010x sensor found!
INFO:MAX30102:(updateAcquisitionFrequency) Acq. frequency: 100.000000 Hz
INFO:MAX30102:(updateAcquisitionFrequency) Acq. period: 10.000000 ms
Starting data acquisition from RED & IR registers...
acquisition frequency = 86.0
acquisition frequency = 86.0
acquisition frequency = 86.0
acquisition frequency = 86.0
acquisition frequency = 86.0
acquisition frequency = 86.0
acquisition frequency = 86.0
acquisition frequency = 86.0
acquisition frequency = 86.0
acquisition frequency = 86.0
acquisition frequency = 86.0
You're very welcome!
Most probably 86Hz is the maximum capability of the Pi Pico with the given configuration.
Let me know your future findings,
bye, Nicola
Gotcha!
Exact same configuration on ESP32 and Arduino UNO: Both with a measured and correct acquisition frequency of 100Hz!
So I know I have to be very careful and selective in deciding which configuration I want to use in my project.
Thank you ^^
Fine!
You're very welcome, good luck with your project!
Nicola
Hi Gruft, may you tell me which model of sensor are you using? Is it a MAX30102 or a MAX30105? Thanks, Nicola
Hey. I have a MAX30102, but I don't have a Link at the moment because I get it from our university institute.
Thank you! I am just looking for MAX30105 owners to understand if the driver works. Again, good luck with your project!
Hello. First thank you for this amazing library ;)
I stumbled on a question while adjusting the sample rate and fifo average. Say I set the sample rate to 1600 and fifo average to 32. This represents a sensor accusation frequency of 50Hz.
The measured accusation frequency starts with 40 and then drops to 13 very fast. Do you have any idea why this bevavour occurs? Is the code just too slow executed? I am showing the terminal outcome below. I removed the printing of the values.
`INFO:MAX30102:(MAX30105) MAX3010x sensor found! Setting up sensor with default configuration.
INFO:MAX30102:(updateAcquisitionFrequency) Acq. frequency: 50.000000 Hz INFO:MAX30102:(updateAcquisitionFrequency) Acq. period: 20.000000 ms INFO:MAX30102:(updateAcquisitionFrequency) Acq. frequency: 200.000000 Hz INFO:MAX30102:(updateAcquisitionFrequency) Acq. period: 5.000000 ms INFO:MAX30102:(updateAcquisitionFrequency) Acq. frequency: 50.000000 Hz INFO:MAX30102:(updateAcquisitionFrequency) Acq. period: 20.000000 ms Reading temperature in °C.
22.875 Starting data acquisition from RED & IR registers...
acquisition frequency = 40.0 acquisition frequency = 13.0 acquisition frequency = 13.0 acquisition frequency = 13.0 acquisition frequency = 13.0 acquisition frequency = 13.0 acquisition frequency = 13.0 acquisition frequency = 13.0`
This is of cause just an example. I tried different combinations.
sample rate, sample avg, sensor acquisition, measured acquisition 3200, 32, 100, 13 3200, 16, 200, 25 3200, 8, 400, 50 3200, 4, 800, 100 ... 1600, 32, 50, 13 1600, 16, 100, 25 1600, 8, 200, 50 1600, 4, 400, 100 ... 800, 32, 25, 13 800, 16, 50, 25 800, 8, 100, 50 # However here the sensor initialisation is returning a acquisition frequency of 50Hz?
Given fro the data you can clearly see that the ratio of sample rate and sample avg does not match the acquisition frequency. why is that?
thank you and Cheers Gruft