Quote Originally Posted by skimask View Post
So what you're saying is...
So I did a bit of thinking...and this might be the hard way to go about it...if my earlier post was correct in the way I was thinking about the issue at hand......

Build up 2 tables, one table contains values for a 4 bit sine wave at 1200 hz, one table contains value for a 4 bit sine wave at 2200 hz. Should be easy enough in Excel or whatever. And these tables only have to be long enough to produce a complete sine wave (or a half or a quarter sine wave, depending on how math savvy you are).

Sounds simple enough...But these tables would have to be synchronized to produce those frequencies at a known sample rate, in this case, 19531.25hz, which just happens to be 20Mhz (oscillator) / 4 (instruction rate) / 256 ( timer 0 overflow interrupt). I.E. 16.276 samples would be one complete sine wave at 1200hz, 8.8778 samples for one complete sine wave at 2200hz. So you can see that you'd need a table long enough to get something where the table would end at a nice 'stopping point' for each sine wave before starting over again.

On each Timer 0 overflow interrupt...
-If the serial input line is low, you step thru table 1 (1200hz) lookup values and output those on your R2R ladder port bits...
-If the serial input line is high, you step thru table 2 (2200 hz) lookup values and output those on your R2R ladder port bits...

One problem I see is the transition between the 2 frequencies when the serial input line changes. You could possibly go from the top of one phase of one freq to the bottom of another phase of the other freq...thereby generating crazy harmonics that the detectors at the other end might not like, or then again, they may not care and filter them out (likely the case).

I suppose if you had a good enough filter on the PIC pin output, you could just shift out 1's and 0's to approximate the freq's, or just use the FREQOUT command in a really tight loop. Maybe define'ing the OSC to a different value than what you're actually using to get faster ONMS times and changing the frequency depending on the ratio of Fosc vs. what you're actually running the PIC at. For example...
DEFINE OSC 4 (while running the PIC at 4Mhz)
FREQOUT pin, 1, 1200 would give you 1ms of 1200hz

but...
DEFINE OSC 4 (while actually running the PIC at 20Mhz)
FREQOUT pin, 1, 6000 would actually give you .2ms of 1200hz
This way you could sample the serial line every .2ms (or just a hair over that). As long as you weren't running over 4800 baud, this method MIGHT work.

I doubt it, but it's an idea I had running thru my head...