Frequencies
Discovery
Posts: 606
in Propeller 1
Can the COGs in a propeller be used to generate frequencies such as 440 Hz, 623 Hz, 812 Hz, and 984 Hz?
Sincerely,
Discovery
Sincerely,
Discovery
Comments
Check this link out Propeller Counters
Mike
You might like to look at
AN001-P8X32ACounters-v2.0_prop.pdf
and that gives a NCO mode for the timers, which can output square waves with fine granularity, and there are 2 timers per COG.
fHz = SysCLK * FRQA/2^32
so for 440Hz you would derive FRQA = (440Hz*2^32)/80MHz = 0x5C46, and actual Hz is 439.994037
If you want Sine waves, then more code is needed eg a Direct Digital Synthesis and lookup table loop
I use Propbasic for programming...will this present a problem?
Sincerely,
Discovery
For ideas you could search these forums
One example thread is
https://forums.parallax.com/discussion/140784/sine-wave-generator
and in that thread is some working code
https://forums.parallax.com/discussion/comment/1112113/#Comment_1112113
You should really give Spin a try.
When I first saw Spin I found it intimidating compared to PBASIC but I also found that about 75-80% was the same.
Spin is a lot more powerful though than PBASIC ever was and all the different Objects make up for the fact that it doesn't have commands like FREQOUT.
There is a BS2 Object in OBEX that you start with but it doesn't use any PAsm (Propeller Assembly Language) so it's slow, especially serial.
http://obex.parallax.com/object/164
The Propeller Education Kit (PEK) Text is how I started learning Spin though it doesn't teach the uses of CONstants other than to set the Propeller clock frequency.
As the others have said, the Counters in each Cog have an NCO mode that will generate a Square Wave based on a 32-bit number or Long variable.
https://www.parallax.com/downloads/propeller-education-kit-labs-fundamentals-text
Chapter 7 teaches the different Counter modes and Page 143 uses the NCO mode to generate tones on a Piezospeaker.
This is the code that goes with the PEK text and it uses Propeller Tool.
https://www.parallax.com/downloads/propeller-education-kit-labs-fundamentals-example-code
https://www.parallax.com/downloads/propeller-tool-software-windows-spin-assembly
You should also have a copy of the Propeller Manual available for reference on commands and the Propeller chip hardware registers.
https://www.parallax.com/downloads/propeller-manual
This project is designed to produce a simulated diesel locomotive horn of four chimes. Four sine waves will be sent to a summing amplifier then sent to a power amplifier and speaker. Several years ago, I recorded the sound of a locomotive blowing for a crossing and the sound was washed through my spectrum analyzer to acquire the frequencies. That data was lost but I think that the four frequencies stated earlier are close enough that I can adjust them in the propeller program.
Sincerely,
Discovery
Page not found for Prop Tools (Index), Emulators (Index), and ZiCog.
What is SIDCOG?
Discovery
You might want to try Spin for a while; it was designed for the Propeller and will help you get close to the hardware. Once you have a really good understanding of the hardware, you'll be more effective with PropeBASIC. And if it's speed of the final code that concerns you, there is FastSpin that will compile to LMM code. FTR, I haven't used FastSpin, but many have.
Discussion topic - https://forums.parallax.com/discussion/118285/sidcog-the-sound-of-the-commodore-64-now-in-the-obex/p1
There are also examples aplenty here, of WAV file playback, for another way to solve this.
I did not know the SIDCog chip was used in the Commodore computers. I had two 64s and one 128. When I sold an earlier house the buyer said that they wanted to keep the Commodore 64 that ran the heating and cooling systems in the house.
Sincerely,
Discovery
That's using a simple low-pass RC filter.
Sincerely,
Discovery