This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

ADC input selection change time

I am using internal ADC to sample 2 (sometimes 3) channels on about 333Hz frequency. What I do is:

  • set channel 1 as input (always two-thirds prescaling, VBG reference)

  • start 3ms repeated timer

  • when timer triggers, sampling at chan1 starts and app goes to sleep

  • wakeup when adc finishes - check one more time if it really is not busy - store result

  • change ADC input to channel 2 and start sampling - then go to sleep

  • wait for wakeup again, check if not busy, store result - change input to chan 1 - go to sleep

  • wait for another 3ms timer trigger...

My problem is that sometimes (very rarely, but regularly!) my readings seems to be connected, ex. Chan1 should read value about 0, Chan2 should read value about 1000. In most cases it is ok, but sometimes chan1 reads value about 1000 (just like CONFIG.INPSEL mux react too slowly). It is possible that my code is buggy, but I am wondering if it is possible that ADC reacts REALLY slowly for its input changes when sampling really fast.

Parents
  • I tried that. After LAST measurement in cycle I immediately change input to channel1. Channel 1 sampling is started by 3ms timer, so there is quite long delay after configuring, before starting. Still, sometimes channel1 gets samples similar to readings from last channel.

    I solved my problem by adding one additional dummy sampling before each channel. It doubles ADC usage, but it works. This solution is a bit dirty, it would be nice to understand what causes this problem to solve it properly...

Reply
  • I tried that. After LAST measurement in cycle I immediately change input to channel1. Channel 1 sampling is started by 3ms timer, so there is quite long delay after configuring, before starting. Still, sometimes channel1 gets samples similar to readings from last channel.

    I solved my problem by adding one additional dummy sampling before each channel. It doubles ADC usage, but it works. This solution is a bit dirty, it would be nice to understand what causes this problem to solve it properly...

Children
No Data
Related