Dear all,
I need some help to understand more about how ADC works in arduino.
I'm doing simulation of arduino uno using proteus for analog signal sampling. I put signal sine waveform 1Hz with amplitude 4V (p-p).
For programming, i'm using Arduino IDE to write the code, compile, and put the hex file to run it in proteus.
You can see the schematic on attached pic. analog signal were passed to voltage divider to capture whole sinusoidal wave,
then the sampled shown using serial monitoring. I took all the data and plot it in Excel to see how the sample data look like.
What makes me confuse is the output signal always has different frequency against input signal frequency.
In my project, i want to sample 1Hz sine signal at analog pin A1, then i got output signal with frequency ~5Hz.
I believe that ADC feature on arduino has way more faster sample rate rather than 1Hz (to prevent aliasing),
but still i got the incorrect output signal frequency.
I have tried with simple program following arduino IDE code template or doing more precise by using bit manipulation.
but still i couldn't get 1Hz signal output. Does anyone can help me to understand why & how to sample 1Hz signal.
(the amplitude was correct, but basically i want to simulate the simple analog sampling with output signal mimicking input signal)
I need some help to understand more about how ADC works in arduino.
I'm doing simulation of arduino uno using proteus for analog signal sampling. I put signal sine waveform 1Hz with amplitude 4V (p-p).
For programming, i'm using Arduino IDE to write the code, compile, and put the hex file to run it in proteus.
You can see the schematic on attached pic. analog signal were passed to voltage divider to capture whole sinusoidal wave,
then the sampled shown using serial monitoring. I took all the data and plot it in Excel to see how the sample data look like.
What makes me confuse is the output signal always has different frequency against input signal frequency.
In my project, i want to sample 1Hz sine signal at analog pin A1, then i got output signal with frequency ~5Hz.
I believe that ADC feature on arduino has way more faster sample rate rather than 1Hz (to prevent aliasing),
but still i got the incorrect output signal frequency.
I have tried with simple program following arduino IDE code template or doing more precise by using bit manipulation.
but still i couldn't get 1Hz signal output. Does anyone can help me to understand why & how to sample 1Hz signal.
(the amplitude was correct, but basically i want to simulate the simple analog sampling with output signal mimicking input signal)
Code:
int adc_value;
void setupADC()
{
ADMUX = (1 << REFS0) | (1 << MUX0);
ADCSRA = (1<<ADEN) | (0<<ADIE) | (1<<ADPS2) | (1<<ADPS1) | (1<<ADPS0);
}
void startConversion()
{
ADCSRA |= (1<<ADSC);
}
void setup() {
Serial.begin(9600);
setupADC();
}
void loop() {
startConversion();
adc_value = ADCW; //Store ADC value
Serial.println(adc_value);
}
Attachments
-
139.6 KB Views: 44