Ich verstehe nicht - warum ist so? I have soldered a very simple oscillograph based on Atmega8. ADC in the microcontroller measures voltage between +5 and the ground. This info is being sent periodically through the serial line to PC. All is ok. For example, if I use simple voltage divider (R1 and R2 in series) and measure voltage between them, it shows me really nice exact values. But, as soon as I have capacitor in a circuit, all goes wrong. I know how capacitors work and how they should work. But in my case, a capacitor makes measured values to swing around the real voltage. Up and down, up and down... What the hell is it ? Any good oscillograph doesn't show something similar ever. I suppose it is ADC issue inside Microcontroller. My question is following: How it is recommend to use ADC in the Atmega in order to measure any outer voltage? My ADC function looks so: void ReadChannelInBuf(uint8_t mux, uint16_t *buf, int len) { uint8_t i; //Frequenzvorteilersetzen auf 8 (1) und ADC aktivieren (1) ADCSRA = (1<<ADEN) | (1<<ADPS1) | (1<<ADPS0); // Kanal waehlen ADMUX = mux; // interne Referenzspannung nutzen ADMUX |= (1<<REFS1) | (1<<REFS0); for(i=0;i<len;i++){ ADCSRA |= (1<<ADSC); while ( ADCSRA & (1<<ADSC) ); buf[i] = ADCW; } // ADC deaktivieren (2) ADCSRA &= ~(1<<ADEN); } And I do measurements in the loop: int main(void){ usart_init(); uint8_t i; uint16_t result; uint16_t *results; results = (uint16_t *)malloc(sizeof(uint16_t)*LEN_BUF); while(1) { ReadChannelInBuf(0, results, LEN_BUF); for (i=0;i<LEN_BUF;i++){ result = results[i]; usart_putchar((uint8_t)result); usart_putchar((uint8_t)(result>>8)); } } return 1; } Please help me, Thank you in advance and I am very sorry for my German, but my English is a way faster for me.
What do you mean with "as soon as I have a capacitor in a circuit"? Where do you connect the cap?? Maybe you should post a schematic...
No matter, where. If any capacitance is presented in a circuit, my pseudo-Oscillograph shows wrong values. For example if C1 is between R1 and the ground. I've tried very simple RC-circuit and it doesn't work how it has to be.
I think you want to implement a "AC-Coupling". In this case you must set the input to Vref/2 by connecting one resistor (10k - 100kOhm) between AGnd an Ain and a second resistor between Ain and Vref.
from Wikipedia: Capacitive coupling is often unintended, such as the capacitance between two wires or traces that are next to each other. Often one signal can capacitively couple with another and cause what appears to be noise. To reduce coupling, wires or traces are often separated as much as possible, or ground lines or planes are run in between signals that might affect each other. Breadboards are particularly prone to these issues due to the long pieces of metal that line every row creating a several-picofarad capacitor between lines. To prototype high-frequency (10s of MHz) or high-gain analog circuits, often the circuits are built over a ground plane so that the signals couple to ground more than to each other. If a high-gain amplifier's output capacitively couples to its input it often becomes an oscillator. and in my case... hm... I use breadboard !!! (Steckplatine) Thus, it is probably has capacitive coupling of some pF, isn't it ? But it is very doubtfully that even a very simple circuit (+5-R1-C1-ground) will create a capacitive noise
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.