Go Down

Topic: Should sample an analog input as often as possible (Read 121 times) previous topic - next topic

EmmaPurkaer

I have some problems understanding what commands I need for this task. If anyone can help I will be very thankful!
The Arduino sketch should sample an analog input as often as possible! It shall filter the analog input for high-frequency noise (using e.g. a running mean) :(  :o  :smiley-confuse: Every 10 seconds it should print a serial message with the current filtered input mapped to voltage. The filtered input to the full range of a PWM output shall be mapped!

Im crossing fingers
Thank you

PieterP

What is it you're actually trying to do? The (by default) 500 Hz PWM output is going to be much slower than the ADC.
Depending on your application, a running mean filter is probably not the best idea.

The datasheet of the ATmega328P has a good explanation of how the ADC works (different modes, speeds, triggers), and how the timers are configured for PWM output. I'd recommend you read those sections first if you want to get the most out of your microcontroller.

Pieter

blh64

You should also attempt to achieve your codes by yourself and when you get stuck, post *your* code and people will help.  It's a much better approach than crossing one's fingers.

GRuser

arduino uno has a default ADC conversion time about 100-120usec. in 10 sec you get more than 80000 conversions. Need more?

jremington

Quote
it shall filter the analog input for high-frequency noise
A sketch can't do that.

You MUST use external circuitry to make sure that no signals or noise with frequency higher than sampling frequency/2 are present in the input.

6v6gt

This sounds like school work.
If the output is to appear only every 10 seconds, then the input could be expected to be a PWM signal with a fairly constant duty cycle.
The "as often as possible" sample rate requirement could mean that you are expected to drive the ADC by a timer and not simply use analogRead() in a loop, but that is then programming at quite an advanced level. What processor are you using ?
The filtering could be simply ignoring short term transitions in the input signal, or if the input is expected to be clean PWM signal, ignoring those inputs which fall outside a certain voltage tolerance.

Go Up