little pwm - adc quest

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Using formula on post #39 -> I would use freq. from 217.6 to 2972.72 for 32 s*o*u*n*d*s! as from 200 to 2972 its 33.

And what does that formula means!? I am not too goodwith Excel!

Thanks!
 

Markd77

Joined Sep 7, 2009
2,806
It's just an increase of 8.8% (1.088 = 108.8%) of the previous value for each note.
If you look at the formula, the $ signs make it always point to cell A1
=(A4 *$A$1)
if you copy it down the column, you will see that the formula changes to:
=(A5 *$A$1)
=(A6 *$A$1)
etc.

If you change the value in A1 to 1.091 you should get 32 s*o*u*n*d*s! :) from 200 to 2976

Spreadsheets may seem a bit dull, but they can save a lot of time, for example if you put:
="retlw d'"&C4&"'"
into D4 and copy that down the column, you get:
retlw d'260'
retlw d'283'
retlw d'309'
which is ready to paste into MPlab (assuming the right values).
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
they look nice! but then I would have to set my Fosc at 2Mhz to accomodate the *200* one, correct?

I tried that *retlw* but not working...you sure you typed it well

Also possible to have only one CCP1CON for all these frequencies at 2Mhz?

Sorry if I ask stuff that I can figure out myself...

my brain/system is shutting down!
 

Markd77

Joined Sep 7, 2009
2,806
they look nice! but then I would have to set my Fosc at 2Mhz to accomodate the *200* one, correct?
I think so, or start higher and use 4MHz, the values are up to you, play around until you get something you are happy with.

I tried that *retlw* but not working...you sure you typed it well
I think so, works for me, should work on Excel, but I'm using different spreadsheet software, so can't check.

Also possible to have only one CCP1CON for all these frequencies at 2Mhz?
I think so, the only thing in there that could change is the lowest two bits of duty cycle and they aren't going to make much difference to the sound.
 

MMcLaren

Joined Feb 14, 2010
861
Can you post the exact frequency of the thirty two tones you're trying to produce so that I can post an NCO (numerically controlled oscillator) example for you, please?

Cheerful regards, Mike
 

THE_RB

Joined Feb 11, 2008
5,438
Hi Mike, you can calc the note frequencies on your scientific calculator, they are the twelvth root of 2, and "standard A" is 440Hz.

Obviously the octave freq doubles after exactly 12 note "steps" so the next A up is exactly 880Hz and the A above that is 1760Hz etc.
 

Thread Starter

Eric007

Joined Aug 5, 2011
1,158
Can you post the exact frequency of the thirty two tones you're trying to produce so that I can post an NCO (numerically controlled oscillator) example for you, please?

Cheerful regards, Mike
Here's are the 32 freq Ima use! Now I don't care about musical notes but rather 32 different s*o*u*n*d*s and I don't care if they sound like music from planet *Mars* as long as they are different!

Note that your proposed NCO must be suitable for ADC TAD >1.6 us and for PWM calculation for required registers!

Thanks!
 

Attachments

Top