Rotary encoder as frequency selector with AD9833

Hi, im trying to build a function generator, using ad9833, the range is 1Hz - 1MHz (ad9833 should rise until 12,5MHz but increase over 1MHz gives me a distorted signal.

Then, i want to increase/decrease frequency using a rotary encoder (using a potentiometer its not posible, because is I map an analog pin from 0-1023 to 0-1000000 the value will fluctuate a lot (ever point from the initial range will be 1000 values in the second range, so the final result is an ustable value)

Thats easy, i got it working as i want, with a bit of bounce.. but working.

But, i want to modify the frequency, and if i rotate with a determinated speed, change a multiplier, and instead of increase by 1, do it by 10, 100, 1000, 10000 and 100000 (trying to reach 1000000 increasing freq by 1 could be... a pain xD)

Its there any way to achieve that without messing with bounces? I mean, i know that if i rotate the encoder a lot... it will miss some clicks, because bounce library will mix real clicks with bounces.

So the question is... its possible, or maybe I need to throw that idea, and think another?

Thanks.

This thread may help.

Hi

Yeah, thats the point, I though about it also.

My problem is, yes, i can calculate the speed of the previos X clicks, and that gives me a number, 0 1 2 3 4 5 (used in a pow(10,number)) but, after calculate, if i stop rotating, it will recalculate, how could i tell to the arduino that "i want to move at X speed, you will count some many clicks, and based on that, set a multiplier for the next clicks" but avoid that, for example, i move 10 clicks, that increases the freq to 10Hz from 0, ok, then i rotate at a higher speed (freq will still increase by 1) and then, it detects and changes the multiplier, for example, to 100000.

Then with that multiplier, i must move slowly, asi my max freq will be reached in 10 clicks (10*100000) but, if i move slowly, it will recalculate again and probably, set a 1 by 1 step :slight_smile: :joy:

Maybe adding some delay (like 2 seconds) where if the rotary isnt moved, the multiplier resets, but if moved, uses the multiplier obtained?

But that introduces a new problem, I might want increase to 100000 and later go 10000 by 10000 and then 1000 by 1000 to get 256000.

Maybe the rotary isnt the best solution for that problem.

thanks for your time and the info!

PD: maybe get a adc with more resolution (like ads1220) to get a good precisión with the potentiometer could make my life easier xD

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.