Hello, i am measuring Electromyograph using ESP32, and for the analog read the maximum value is 4095 due to the 12 bits ADC. Just wondering how can I read higher analog value? Do I need to use other microcontrollers?
Why do you need this?
I am making EMG based controller, so i'm using it to measure the EMG when making hand gestures like folding fingers, making fist etc. during the fist gesture, it only reached the limit 4095 so i couldn't see the actual analog value. I want to calculate the actual value to compare with other gestures.
What do you mean 'actual value'
because the ADC only limits to 4095 it means that the 'actual value' when making a fist is higher than that. I attached the graph for reference. Up until 127s is folding middle finger, you can see that the analog value is around 3000+, starting from 154s is making a fist it only stops at 4095 when the highest point for this gesture might be a little higher, i think? Please share your thoughts!
I think you are a little confused.
12-bit is the resolution, not what you think the "range".
100-bit resolution won't make it read more than the reference voltage you comparing to.
is that so? i see. then what do you recommend i change to measure the higher value? or does that limit depends on the sensor?
This doesn't make any sense.
The esp's reads values in the range of 0v -3.3v with 4096 equal to 3.3v
If you need to read higher voltages than you can use a voltage divider to adjust it to read a greater voltage. Then 4096 will be equal to that higher voltage
If you need higher resolution (smaller voltage difference between each number) than you need a separate ADC with higher bit resolution for example a 24 bit ADC. But it will still hit the maximum reading at 3.3v
Sounds to me that you need a voltage divider to scale the range properly.
The answer is more about hardware than software. Maybe you should post your schematic or datasheet of the device you trying to read the voltage from? what is it maximum output voltage? A simple voltage divider could help in this case
thanks for the suggestion! i'll look into it
I think you have a basic misunderstanding. Perhaps study a bit more.
The hardware is Myoware 2.0 EMG muscle sensor.
I'm a bit new to this so I am not really sure but I'll attach a link for the guide document https://cdn.sparkfun.com/assets/learn_tutorials/1/9/5/6/MyoWare_v2_AdvancedGuide-Updated.pdf
and the official website
https://myoware.com/
If it helps it is mentioned that
Supply Voltage:
min. = 2.27V,
typ. = +3.3V or +5V,
max. = +5.47VSurface EMG signals typically have an amplitude of 0 - 10 mV(peak to peak) and a frequency band of 10 - 500 Hz. MyoWare has a first-order passband of 20 - 500 Hz which is ideal for capturing the bulk of the power spectrum while removing unwanted signal sources such as motion artifacts.
- Just read the 1st post and seeing that you use ESP32, I assume you use the same 3.3V to power the sensor board? If not, please do not power the sensor board using 5V.
- There is a potentiometer on the device that marked "GAIN", I don't know if you have tried to turn it down a little?
- And you waveform looks like you're not using the RECT output? what output are you connecting to the controller board?
*My experience working with ESP32 is that its ADC isn't accurate. I have ESP32 in some commercial products and all of them had to be calibrated.
This↑↑↑
Your analog input divides the reference voltage into 4096 steps.
0 Volts = 0 analog counts
an input voltage = to the reference voltage would = 4095 counts
So to read a larger range you have to reduce the range of the voltage coming into the ADC of the processor.
You should read this to perhaps use the referenced attenuator to reduce the input voltage to a lower value before making the A to D conversion.
- I connected it to 5V on the board according to the reference figure in the guide document
- I haven't tried turning it down, will do later and update you on the difference!
- I am using envelope (ENV) output which is the amplified and rectified signal
If I remember correctly ESP32 runs on 3.3V, so does its ADC ref voltage.
- Try hook up 3.3V to your sensor board first (don't turn the GAIN yet) to see if it helps.
- if not then try turning that GAIN potentiometer.
Simply: the value of 4095 is represented as 1111,1111,1111 in binary.
So all 12 bits of resolution of the ADC are being used.
The easy way to resolve larger signals is to reduce the size of the signal to the ADC, by reducing the sensitivity - turn down the gain on the sensor board.
The ESP32 ADC is very non-linear especially at the high and low ends; AFAIKR the default range (ignoring the zero error) is 0 - 2450mV.
I dont see the non-linearity being an issue for this application.
@qpurr did you read the info sheet?
Setting up Envelope (ENV) Output
To output the ENV signal, simply connect the ENV pin to one of your measuring
device’s analog input. Unlike the other two outputs, the ENV output has an
additional gain stage that is adjustable via the gain potentiometer.
To adjust the gain, locate the gain potentiometer in the upper left corner of the
sensor (marked as “GAIN”). Using a Phillips screwdriver, turn the potentiometer
clockwise to increase the output gain; turn the potentiometer counterclockwise
to reduce the gain
I'd recommend you use the 3.3V to power the sensor.
You havent shown your code, can you do that?