Hello everyone , I'm new to the whole free-run mode concept and have hit a problem.
I'm trying to take a periodic analogic signal with a frequency of 100Hz from the pin A0, and i need many measures for my signal so my Arduino UNO must work in a free-run mode.
1/First,How May integrate this mode in my program ?
2/Second, How may I print the value mesured in the serial monitor at the same time ?
You can read about it in the processor datasheet. You generally don't get a lot of choice in how fast the free-running mode generates samples. The clock dividers available are 2,4,8,16,32,64, and 128. If the clock is faster than 200 kHz you can't get full resolution (10 bits) so on a 16 MHz processor you need a prescale of at least 80 to get full resolution so your only choice is a prescale of 128 or 125 kHz. Each conversion takes 13 cycles so that gives you about 9.6 kHz . There are no higher prescale values so you can't make the free-running mode any slower. If you only want 100 Hz I would have the free-running interrupt calculate a 10-sample average and then use a timer to grab the average 100 times a second.
Thanks Sir @johnwasser and @CrossRoads @johnwasser
I am a Begginer with Arduino so could you explain for me more ? @CrossRoads
If we use 400 Hz sample rate it will take just 8 samples in T=0,02s(50Hz) but i need more samples (200 samples or more) so ther is a way to do it without Free-Run Mode ?