cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4, ADC multichannel getting wrong values

jpablo
Associate II
Posted on January 09, 2014 at 18:37

 

 

The original post was too long to process during our migration. Please click on the attachment to read the original post.
6 REPLIES 6
Posted on January 09, 2014 at 18:48

It samples into a capacitor, understand t

he ADC's input impedance relative to that of the signal source

.

Tie the inputs to opposite supplies to confirm their sequencing.

The DMA is not stopped by the debugger, or the slowness of the USART output. Make sure TIM4 is not saturating the processor with interrupts.

Spin on the TXE flag, not TC
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
chen
Associate II
Posted on January 10, 2014 at 10:16

Hi

''It samples into a capacitor, understand t

he ADC's input impedance relative to that of the signal source

.''

If you do not know much electronics - if you leave the ADC input with no connection and expect to read 0V (0 value) - it is unlikely to work.

To read 0V/0 value - you must put 0V on the ADC ie connect it to 0V.

(There are plenty of tutorials on electronic on the WEB)

A simple way to put a 'known voltage' onto the ADC is to use a variable resistor, (try 10K - linear) one end to the + volt other end to 0V and the wiper/variable bit to the ADC.

You can then measure the value to the ADC with a volt meter.

DO NOT SHORT CIRCUIT THE +V TO 0V!

jpablo
Associate II
Posted on January 10, 2014 at 12:14

Hello,

thanks your suggestion were helpful to understand more. To code is working fine now. I also change from TC to TXE (I take a look on the datasheet and seems that there is not such a big difference by using one of those).

My test, now, was to attach two variable resistors and see what happen, it is working perfect. I guess should work fine also with my real sensors.

The behavior that I was mention before was obtained by doing a test using a function generator in one channel and nothing in the other one.

Still is strange for me why the voltage changing in one pin affects also the other one, do you know the answer?

Thanks clive and sung.chen_chung for the hints.

Pablo

frankmeyer9
Associate II
Posted on January 10, 2014 at 12:40

Still is strange for me why the voltage changing in one pin affects also the other one, do you know the answer?

 

As suggested, read about SA-ADC, especially multiplexed one's.

If a floating ADC channel is converted directly after another one, the sampling capacitor's charge (and thus its voltage) is dependant of the previous channel's voltage, minus ''conversion losses'' for the previous channel, minus leakage currents.

If the phantom results annoy you, tie the floating ADC input to ground.

Posted on January 10, 2014 at 13:14

TC is significantly more latent, perhaps 20 bit times, but at least 10. Both the holding register is empty, and the LAST bit of it's prior content must hit the wire.

TXE indicates the HOLDING buffer is empty, and should signal as the FIRST bit of the prior content hits the wire.

Thus TC is the MOST inefficient way to send data using the USART, resulting in larger inter-symbol gaps.

I would not spin on a USART in an interrupt, better to buffer output data, and service byte-wise on a TXE interrupt.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jpablo
Associate II
Posted on January 10, 2014 at 19:32

Thanks Clive I will consider you suggestion. 

fm, thank you now makes sense. 

Pablo