EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

ADC sampletime on STM32F103

Started by kristoff November 12, 2015
Hi,


I'm currently learning how to use the ADC on a STM32F103RC. One of the 
parameters for reading the ADC is its sample-time.

Just wondering. What is the reason for being able to set this? Why would 
one choice a sample-time longer then needed (i.e. 1.5 cycles)?



Cheerio! Kr. Bonne.
On Thu, 12 Nov 2015 21:22:27 +0100, kristoff wrote:

> Hi, > > > I'm currently learning how to use the ADC on a STM32F103RC. One of the > parameters for reading the ADC is its sample-time. > > Just wondering. What is the reason for being able to set this? Why would > one choice a sample-time longer then needed (i.e. 1.5 cycles)? > > > > Cheerio! Kr. Bonne.
Power consumption & processor budget, mostly -- each sample takes a certain amount of energy, and a certain amount of processing ticks. The fewer samples you take per second, the less power (both meanings) you consume. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
Clifford (and Tim also, of course)



On 12-11-15 23:03, Clifford Heath wrote:
>> I'm currently learning how to use the ADC on a STM32F103RC. One of the >> parameters for reading the ADC is its sample-time. >> Just wondering. What is the reason for being able to set this? Why would >> one choice a sample-time longer then needed (i.e. 1.5 cycles)?
> The ADC input pin has a certain capacitance, and the source has a > certain impedance, so a longer sample time will allow the input more > time to stabilise - depending on your accuracy needs.
OK. Thanks. The application to use this is a port of the MMDVM (Multi Mode Digital Voice Modem) project. We are looking at sampling audio at 24 Ksamples/second, so this is interesting information. I'll forward it to the guy doing the actual electronic design of the interface.
> Tim's answer relates to how often you take a sample, not to how long the > sample gate is open for.
OK. Got it. :-) In the mean time, I found another reason: I was testing my code with the onboard temperature sensor. Apparently, that device requires a sampling-time of at least 17.1 µS. I do not if there are other sensors that require a longer sampletime.
> Clifford Heath.
Cheerio! Kr. Bonne.
kristoff <kristoff@skypro.be> writes:

> Clifford (and Tim also, of course) > > > > On 12-11-15 23:03, Clifford Heath wrote: >>> I'm currently learning how to use the ADC on a STM32F103RC. One of the >>> parameters for reading the ADC is its sample-time. >>> Just wondering. What is the reason for being able to set this? Why would >>> one choice a sample-time longer then needed (i.e. 1.5 cycles)? > >> The ADC input pin has a certain capacitance, and the source has a >> certain impedance, so a longer sample time will allow the input more >> time to stabilise - depending on your accuracy needs. > > OK. Thanks. > The application to use this is a port of the MMDVM (Multi Mode Digital > Voice Modem) project. We are looking at sampling audio at 24 > Ksamples/second, so this is interesting information. I'll forward it > to the guy doing the actual electronic design of the interface. > > >> Tim's answer relates to how often you take a sample, not to how long the >> sample gate is open for. > > OK. Got it. :-) > > In the mean time, I found another reason: I was testing my code with > the onboard temperature sensor. Apparently, that device requires a > sampling-time of at least 17.1 &micro;S. > > > I do not if there are other sensors that require a longer sampletime.
I haven't checked that part, but I believe the parameter you are speaking of, kristoff, is "sample and hold" time. This is the circuit that is just ahead of the ADC that samples the analog signal and holds it long enough for the ADC to convert it accurately. This is different than sample time, or sample period, is is 1 / sample rate. -- Randy Yates Digital Signal Labs http://www.digitalsignallabs.com
Randy,


On 13-11-15 21:05, Randy Yates wrote:
>> In the mean time, I found another reason: I was testing my code with >> the onboard temperature sensor. Apparently, that device requires a >> sampling-time of at least 17.1 &micro;S. >> I do not know if there are other sensors that require a longer sampletime.
> I haven't checked that part, but I believe the parameter you are > speaking of, kristoff, is "sample and hold" time. This is the circuit > that is just ahead of the ADC that samples the analog signal and holds > it long enough for the ADC to convert it accurately. > This is different than sample time, or sample period, is is 1 / sample > rate.
My source for this is the STM32F10X reference manual: it states "The recommended sampling time for the temperature sensor is 17.1 &mu;s." (see 234 of the document). Can you elaburate a little bit on this? I understand there are two parameters: the "sample and hold time" and the sample time (AKA sample periode, i.e. sample-and-hold time + conversion-time). But if you do not changing the conversion-time (i.e. resolution), does changing the sample-time mean that you actually play with the sample-and-hold time? Cheerio! Kr. Bonne
kristoff <kristoff@skypro.be> wrote:

 >My source for this is the STM32F10X reference manual: it states "The 
 >recommended sampling time for the temperature sensor is 17.1 ??s."
 >(see 234 of the document).

This is a realy funny sentence because a little bit lower they wrote:

     The offset of this line varies from chip to chip due to process
     variation (up to 45C from one chip to another)

Perhaps they should call this a random number generator. :-)

Olaf
Olaf Kaluza <olaf@criseis.ruhr.de> wrote:
> kristoff <kristoff@skypro.be> wrote:
> >My source for this is the STM32F10X reference manual: it states "The > >recommended sampling time for the temperature sensor is 17.1 ??s." > >(see 234 of the document).
> This is a realy funny sentence because a little bit lower they wrote:
> The offset of this line varies from chip to chip due to process > variation (up to 45C from one chip to another)
> Perhaps they should call this a random number generator. :-)
But the offset is measured at test time and slope and offset are documented in write-only memory. The user may use these calibration values and corrected values are quite good. Otherwise I don't see any connection between the two quute from the datasheet you give... -- Uwe Bonnes bon@elektron.ikp.physik.tu-darmstadt.de Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt --------- Tel. 06151 1623569 ------- Fax. 06151 1623305 ---------

The 2024 Embedded Online Conference