2021-09-05 01:07 AM
I am using STM8S003F3.
Currently my application requires sampling two ADC channels, which are interfaced with:
1) Output of a resistor divider network which is routed directly to the microcontroller's ADC CH 3
2) Analog output of a sensor module PCB connected to the microcontroller PCB module via connector to the ADC CH 4.
Initially, I was using SINGLE CONVERSION MODE to scan the channels, by initializing the ADC with the next channel number each time, one after the other, after scanning a particular channel.
In this scenario, when sensor PCB was disconnected, there was no floating voltage observed on the ADC CH 4, as a result the logic seemed to work fine.
Later, I switched to SINGLE SCAN MODE, when I thought it was a much efficient way to scan multiple channels. I was able to get correct ADC values from the data buffer.
However, in this case, when sensor PCB was disconnected, a floating voltage around 1V- 2V was observed on the ADC CH 4, which impacted the application's function.
I do not wish to make changes in the microcontroller PCB module, since it is already manufactured. Is there a way to tackle this floating voltage on analog pin via software, so that there is 0 V, when the sensor is not connected, without having to add a pull down resistor from the ADC pin?
And why did this occur after using the SCAN MODE and not during the SINGLE CONVERSION MODE?
Any input will be of great help.
2021-09-05 01:25 AM
If ADC pin is left open, it has no defined voltage level. It is the responsibility of user to connect an appropriate low-impedance signal source, otherwise the readout values are undetermined.
The sampling capacitor of ADC may be charged to certain voltage from the previous conversion; the task of the external signal source is to charge/discharge this capacitor to the input voltage during the sampling period. You don't have this external source so the capacitor partially retains its previous voltage. If you "manually" switch channels, this may take long enough for this voltage to be discharged through leakages, or the voltage on the sampling capacitor may be different through some internal action of the ADC.
> I do not wish to make changes in the microcontroller PCB module, since it is already manufactured. Is there a way to tackle this floating voltage on analog pin via software, so that there is 0 V, when the sensor is not connected, without having to add a pull down resistor from the ADC pin?
Some microcontrollers allow to use the internal pullup/pulldown also in analog mode. I am not familiar with the STM8Sxxx.
JW