The new code from my previous post does away with the constant flicker between adjacent frequencies due to noise in the ADC when the knob is not being rotated, but otherwise leaves functionality and feel exactly as Ashhar had coded it. ?Works on my Nano, I monitored the frequency value through the Arduino serial port. ?Remove the extraneous final 3 lines about the tone and replace them with a closing "}". ?(It was getting late.) ? The new code replaces this part of Ashhar's original code: // the tuning knob is at neither extremities, tune the signals as usual else if (knob != old_knob){ frequency = baseTune + (50l * knob); old_knob = knob; setFrequency(frequency); updateDisplay(); } It works by inhibiting a reverse in direction of the tuning pot until that reversal has traveled through what would normally be 5 steps in frequency of 50hz each. ?For example, assume we have been tuning up in frequency and stop the knob at 7200.000 khz. ?A bit of noise comes in from the ADC, and the frequency pops up to 7200.050 khz. ?Another bit of noise comes in that would normally bring it back down to 7200.000 khz, but this is ignored because it does not reach the 5 tick threshold. ?A light touch on the knob might bring it a bit further up to 7200.100 khz. ?Reversing the direction of the knob, it travels through 5 steps before any change in frequency occurs, on the 6'th step the frequency goes back down to 7200.050 khz. ?If we leave the knob in that position, a bit of ADC noise might lower it further to 7200.000 khz, but noise will not raise the frequency. ? I recommend operating with the original code at first until the noise at the pot has been evaluated and minimized with bypass caps and perhaps short shielded wiring. ?Then enable this new code by recompiling the sketch. The frequency will still move a little bit after taking your hand off the knob, but can only move in one direction. ?If that is unacceptable but you otherwise like the current method of tuning, then perhaps reduce the tuning rate by a factor of two by replacing this line: ? ? ??frequency = baseTune + (50l * knob); with this frequency = baseTune + (50l * (knob>>1)); Me, I'll likely go to Don Cantrell's shuttle tuning scheme as described at? But use an encoder instead of a pot so I can feel a click when it moves between positions. Jerry, KE7ER On Mon, Feb 20, 2017 at 11:04 pm, Jerry Gaffke wrote:
? |