Behaviour when reading 10 ADC Channels
Posted: Mon Feb 01, 2021 1:26 pm
Hello,
I'm using an ESP32 Dev Module with Visual Studio Code, PlatformIO and Arduino framework.
I'm using all of the GPIOs from the the board in this configuration. 10 Anolog inputs to read a signal from external hallsensors.
And 10 Digital Output channels with PWM Signal on 200-400Hz.
And GPIO15 is used as 25KHz PWM Output for fan control.
GPIO15 is also connected to GND over a 10K resistor to prevent the ESP sending startup information.
The PWM Outputs are not connected to anything at the moment.
Also connected is a I2C LCD and an MCP23017 I2C portExtender, which are handled in Core0 to keep the cycletime of Core1 clean.
Now my problem is, everything is working fine, but the values which I get from the ADCs are not useable.
I connected all of the 10 analog inputs except GPIO25 and 26 to a 2V Voltage which generated with a 1M potentiometer out of the 3.3V pin.
Then I get this result:
564 656 683 695 701 705 0 0 714 711
Ok, this is a huge difference between 564 and 711, however, not calibrated.
But as soon as I connect GPIO25 or 26, everything gets messed up and I get something like this:
44 0 0 0 0 0 342 537 622 668
So as soon as I connect these pins to the same voltage, the values of the other inputs are messed up.
I'm monitoring the voltage on an oscilloscope and its constant at 2V.
So what's going on there?
Any ideas how I can get correct values on all 10 Channels?
I'm reading every 5ms at the moment.
I'm reading all 10 Inputs in a loop:
and I configured it once at startup:
What I'm doing wrong?
I'm using an ESP32 Dev Module with Visual Studio Code, PlatformIO and Arduino framework.
I'm using all of the GPIOs from the the board in this configuration. 10 Anolog inputs to read a signal from external hallsensors.
And 10 Digital Output channels with PWM Signal on 200-400Hz.
And GPIO15 is used as 25KHz PWM Output for fan control.
GPIO15 is also connected to GND over a 10K resistor to prevent the ESP sending startup information.
The PWM Outputs are not connected to anything at the moment.
Code: Select all
//--------------------------------------------------------
// ADC Inputs
//--------------------------------------------------------
#define PIN_HALL_K0 36 //GPIO36 / ADC1 CH0
#define PIN_HALL_K1 39 //GPIO39 / ADC1 CH3
#define PIN_HALL_K2 34 //GPIO34 / ADC1 CH6
#define PIN_HALL_K3 35 //GPIO35 / ADC1 CH7
#define PIN_HALL_K4 32 //GPIO32 / ADC1 CH4
#define PIN_HALL_K5 33 //GPIO33 / ADC1 CH5
#define PIN_HALL_K6 25 //GPIO25 / ADC2 CH8
#define PIN_HALL_K7 26 //GPIO26 / ADC2 CH9
#define PIN_HALL_K8 27 //GPIO27 / ADC2 CH7
#define PIN_HALL_K9 14 //GPIO14 / ADC2 CH6
//---------------------------------------------------------
// PWM Outputs
//---------------------------------------------------------
#define PWM_K0 12 //GPIO12
#define PWM_K1 13 //GPIO13
#define PWM_K2 2 //GPIO2
#define PWM_K3 4 //GPIO4 / ADC2 CH0
#define PWM_K4 16 //GPIO16 / RX2
#define PWM_K5 17 //GPIO17 / TX2
#define PWM_K6 5 //GPIO5
#define PWM_K7 18 //GPIO18
#define PWM_K8 19 //GPIO19
#define PWM_K9 23 //GPIO23
#define FAN_PWM_OUT 15 //GPIO15
Now my problem is, everything is working fine, but the values which I get from the ADCs are not useable.
I connected all of the 10 analog inputs except GPIO25 and 26 to a 2V Voltage which generated with a 1M potentiometer out of the 3.3V pin.
Then I get this result:
564 656 683 695 701 705 0 0 714 711
Ok, this is a huge difference between 564 and 711, however, not calibrated.
But as soon as I connect GPIO25 or 26, everything gets messed up and I get something like this:
44 0 0 0 0 0 342 537 622 668
So as soon as I connect these pins to the same voltage, the values of the other inputs are messed up.
I'm monitoring the voltage on an oscilloscope and its constant at 2V.
So what's going on there?
Any ideas how I can get correct values on all 10 Channels?
I'm reading every 5ms at the moment.
I'm reading all 10 Inputs in a loop:
Code: Select all
ADCValue = analogRead( PinNr );
Code: Select all
analogReadResolution(10); //Set 10-bit resolution
analogSetAttenuation(ADC_11db);
What I'm doing wrong?