Sound command vs pwmout

ccdubs

Member
Hi,

I have been using the sound command to generate a tone at 1kHz to drive a speaker via an amp. The command is: sound 3, (116 ,250).

If you refer to my previous post yesterday I now want to try and get a 1kHz continuous tone so have used the pwmout command with a de-clocked processor at 1MHz. The command is: pwmout 3 , 249,500.

When I compare the result between the two the sounds are definitely at different pitch. I have proved to myself that the clock is running at 1MHz by writing a quick timer in my test code.

Can anyone verify that the inputs I am using in the sound command are correct? Without a scope it is difficult for me to determine what the frequencies are.

The note value of 116 was obtained from this post: http://www.picaxeforum.co.uk/showthread.php?t=7634&highlight=sound+frequency

Many thanks.
 

eclectic

Moderator
Calibfreq?

ccdubs.
I've just tried this, using an un-calibrated 'scope and three different Picaxe chips.

Sound 1,(116,250) = ~997 Hz (One sample 08M)

Then, I tried
poke $8F,%01000000 : pause 10
pwmout 2 , 249,500 ' 08M ( pwmout 3 , 249,500 ' 18X)
stop

Results.
08M (1) = ~ 994 Hz
08M (2) = ~1010 Hz
18X = ~993 Hz

All four results are within 1% of nominal.
But, the differences are audible.

One possibility is to look at Manual 2, page 31 “calibfreq”
and then, very carefully, try it with your particular chip.

e.
 

ccdubs

Member
Thanks for the assistance.

I have decided to use the pwmout command all throughout my code as I couldn't get the frequency close enough to what I want with the coarse options available.

I will have to live with freq "drift" between different chips.
 
Top