Pages: [1]   Go Down
Author Topic: Trying to optimise my analogRead for steadier Readings (7BIT)  (Read 481 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 26
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
I'm building a midi controller with a couple dozen 10k linear pots using 2 4067 multiplexers.

 I'm currently using:
Code:
map(analogRead(0),0,1023,0,127)

Although stability isn't not terrible, I'm still getting +/-1 oscillations when some of the pots are in mid travel. Unnoticeable during performance but I real pain when the knobs fight each-other when the computer is in "learn" mode.

Midi CC only requires 7BIT resolution so I'm wondering if there is a way to lower the ADC's resolution to 7BIT since I'm trashing the resolution anyway with the Map function.

Thanks in advance for any insight.

Logged

0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2857
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sure, just throw away the lower 3 bits of the 10-bit reading:

Code:
value = analogRead(0) >> 3;

You're kind of doing this anyways (inefficiently) using the map() function, so I doubt this will get rid of your +/-1 oscillation. Consider filtering, either median filtering or just averaging N readings.

--
Beat707: MIDI drum machine / sequencer / groove-box for Arduino
 
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 26
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks RG!

I will try some averaging and see how it goes.

Congrats on the 707, fantastic work I have to say!
Cheers!
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 217
Posts: 13705
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

check - http://arduino.cc/playground/Main/RunningAverage - or - http://arduino.cc/playground/Main/RunningMedian -
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Pages: [1]   Go Up
Jump to: