Frequency generator
JTC
Posts: 60
· What is the best way to generate a frequency from 0 to 4.5khz
and ramp it up over about 20 to 30 seconds, needs to be a linear ramp.
Then run at that frequecy.
I think there has to be an easy way to do this.
Thanks for an hints you can give.
Jim
and ramp it up over about 20 to 30 seconds, needs to be a linear ramp.
Then run at that frequecy.
I think there has to be an easy way to do this.
Thanks for an hints you can give.
Jim
Comments
One of my very early SPIN files .. needs a little cleaning up but it is close
Play with the M values right down the bottom and even delete one of the case statements totally
It ramps up·. ramps slower...· + runs at a speed forever until reset.
Cheers· Ronald Nollet Australia
{{ This code ramps pulses to pin4
Once ramped up the motor runs forever.
}}
CON
· _clkmode = xtal1 + pll16x
· _xinfreq = 5_000_000
· Pulse_width = 2000······ 'Delay, in clock cycles for on/off time
· Minimum···· = 1500
Var
long··· M
PUB Flashes
· M := 400_000
· dira[noparse][[/noparse]4]~~···················· 'Set I/O Pins to output direction··········································
· dira[noparse][[/noparse]19..23]~~
·· repeat
····· !outa[noparse][[/noparse]4]
····· waitcnt(Pulse_width + cnt )
····· !outa[noparse][[/noparse]4]
····· waitcnt(M + cnt)
····· case M
······· 50_000..400_000····· : M := M - 1000·····
······· 3999..49999········· : M := M - 5
······· 50..3999············ : M :=1400 + Minimum
································
··· I will give this a try this morning and let you know how it worked.
·· My attempt would ramp very slowly a first but as it got faster the change was faster
··· due to changes in the speed caused the changes to happen sooner.
··· Thanks
··· Jim
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
· Jim
··· I noticed there is a CTR.spin in the lib that is a very good place to start learning to use counters.
Thanks for the heads up.
Jim
·