When counters are in Duty cycle mode... Solved - Fun solution attached!
Kye
Posts: 2,200
I'm just trying to wrap my head arround this.
I want to use the counters in duty cycle mode to output a frequency from 0 to 22050 HZ. However, the more I look at how they work. The more it comes to life that unless the carry bit is set in the current adding operation at each clock cycle the carry bit goes to zero. Which is expected.
But that also means that its very hard to make any low frequency output.... So,·Can the duty cycle mode be used for making low frequency outputs then?
I wanted to make a simple piece of code that let you change the frequency of an output and the duty cycle so that you could change the volume of an output and the tone of that output for lets say a speaker.
The goal is not to use a cog however and to only ust the counters... I could not find an example of this in the counter appnote. Only a duty cycle and synth example that each required a cog.
I belive I may be asking to much of a cog's counter's however...
Thanks for any help.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
Post Edited (Kye) : 8/17/2009 3:44:24 AM GMT
I want to use the counters in duty cycle mode to output a frequency from 0 to 22050 HZ. However, the more I look at how they work. The more it comes to life that unless the carry bit is set in the current adding operation at each clock cycle the carry bit goes to zero. Which is expected.
But that also means that its very hard to make any low frequency output.... So,·Can the duty cycle mode be used for making low frequency outputs then?
I wanted to make a simple piece of code that let you change the frequency of an output and the duty cycle so that you could change the volume of an output and the tone of that output for lets say a speaker.
The goal is not to use a cog however and to only ust the counters... I could not find an example of this in the counter appnote. Only a duty cycle and synth example that each required a cog.
I belive I may be asking to much of a cog's counter's however...
Thanks for any help.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
Post Edited (Kye) : 8/17/2009 3:44:24 AM GMT
Comments
If what you're looking for is a PWM, your best bet is to consider one of the PWM objects in the OBEX.
-Phil
The trick is that the NCO·counter controls the frequency but the Duty counter controls the high masking time vs low time. Since a speaker for example needs an AC signal then·when the duty cycle cog is masking the NCO output the volume is changed because the speaker is spending to much time with a stable voltage that is not changing.
Pretty nice effect for the prop to be able to generate so easily.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
Jon, what you've suggested is definitely needed.
-Phil
And, yes the speaker is needed to filter the square wave output.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,