3dluvr
Member
Output two different sine waves with 16F88 in C?
Hello,
Here's what's been bothering me now for a week and perhaps someone could please help me out...
I saw this Brain Machine circuit (Make magazine #10, article here: https://www.electro-tech-online.com/custompdfs/2008/01/wp_brainmachine.pdf ) so I figured to build it. Since I'm a PIC and not an AVR guy I wanted to use what I have handy, a 16F88, thinking it's a fairly modern micro-controller.
In their circuit they use two AVR's built in timers that link to two oscillators (PWM) to generate different frequencies. Great, sounds pretty easy if only most PICs had more than one PWM (yes, I know there are some with two but they are in large packaging, and besides not handy).
My idea was, since there's only one PWM on most PICs to instead use two four bit sine wave ladders on port A or B or both, regardless (four bit sine wave example as seen here, towards bottom part of the page: **broken link removed** )
Well, the problem is that I can generate one just fine and the output is pretty decent going through and RC filter, but how do I generate two sine-waves at the same time, having two different frequencies, let's say 205Hz and 215Hz?
I have been trying all kinds of things with timers and interrupts, and to be honest I am no expert in writing for micro-controllers (presently using CCS C) so I'm stuck and hoping someone here could enlighten me?
Thank you in advance.
Hello,
Here's what's been bothering me now for a week and perhaps someone could please help me out...
I saw this Brain Machine circuit (Make magazine #10, article here: https://www.electro-tech-online.com/custompdfs/2008/01/wp_brainmachine.pdf ) so I figured to build it. Since I'm a PIC and not an AVR guy I wanted to use what I have handy, a 16F88, thinking it's a fairly modern micro-controller.
In their circuit they use two AVR's built in timers that link to two oscillators (PWM) to generate different frequencies. Great, sounds pretty easy if only most PICs had more than one PWM (yes, I know there are some with two but they are in large packaging, and besides not handy).
My idea was, since there's only one PWM on most PICs to instead use two four bit sine wave ladders on port A or B or both, regardless (four bit sine wave example as seen here, towards bottom part of the page: **broken link removed** )
Well, the problem is that I can generate one just fine and the output is pretty decent going through and RC filter, but how do I generate two sine-waves at the same time, having two different frequencies, let's say 205Hz and 215Hz?
I have been trying all kinds of things with timers and interrupts, and to be honest I am no expert in writing for micro-controllers (presently using CCS C) so I'm stuck and hoping someone here could enlighten me?
Thank you in advance.
Last edited: