Arbitrary Frequency Generator (was SFO)
Anyone got any real code/want to take the challenge of writing real code for the following pseudo code?
Would be the basis of a nice piece of test equipment...
- autosweeping within limits
- set the frequency via serin
- set the frequency by a pot on an ADC
- etc
I've looked at the PWM wizard for the low end frequencies (min seems to be 230Hz with a 4MHz chip) but as you increase the Hz, PWMDIV comes in and out and I can't see (aka don't have the time to derive) the algorithm being used so that you could code it into the loop
Anyone got any real code/want to take the challenge of writing real code for the following pseudo code?
Would be the basis of a nice piece of test equipment...
- autosweeping within limits
- set the frequency via serin
- set the frequency by a pot on an ADC
- etc
Code:
PICAXE xx
SETFREQ xx
FOR x = 1 TO 100,000 STEP 1
Produce a square wave at x hertz using any technique, including but not limited to:
- PWM with and without PWMDIVxx
- changing SETFREQ
- hardcoded pause loops etc
...but not taking "too long" to switch to the new frequency
Pause <<some duration>> - 1ms to 1 second to 1ms resolution?
NEXT
Last edited: