Go Down

Topic: Tone() (Read 2697 times) previous topic - next topic

Noam

Hi.

Simple Q :)

What is the highest Hz the Arduino can give with the tone() function?

Thanks.

Noam

No buddy knows?

besteast

why not google it ?
;)

Since tone() only accepts a frequency value as an unsigned int, the maximum frequency you can ask for is 65535 Hz (technically, you'll get 65573.77 Hz) - well beyond what the human ear can perceive.

b

Noam

Are you sure about it?

the Arduino clock is much faster and it you can get higher frequency only buy writing HIGH, delaymicro, LOW, delay...

I tried it yesterday with X as frequency and a analogRead to control the X.

I gut up to over 100000Hz.

Then I tried 20Mhz, I wrote 20000000, witch is the Arduin Duemilanove clock.

It worked, but I am not sure at witch frequency...

The way I chekt it was plugging the output to antenna and trying to read volt that is crated on a diode witch is grounded from one side and connected to other antenna on the other side

Are you sure in what you are saying? , Or did I do some thing wrong?

Grumpy_Mike

Quote
The way I chekt it was plugging the output to antenna and trying to read volt that is crated on a diode witch is grounded from one side and connected to other antenna on the other side


That doesn't measure the output frequency only that something is being produced. With a 16MHz clock I would be surprised if you could get any signal greater than 1MHz out of it. However, tone is written for audio outputs so there is little point pushing it over the audio range.

Groove

Quote
Are you sure about it?


How much more sure than:
Code: [Select]
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
can you be?
Per Arduino ad Astra

Noam

Maybe we can just start a witch hunt...

So it is coz of the int the is in the tone(), witch define the Hz, that can go over 60000...

Ok thanks.

Grumpy_Mike

Quote
witch define the Hz, that can go over 60000.


which [size=16]can't[/size] go over 60000

Noam

Opss... that the "t" is MISSING!!!!

Sorry dude... having a bad day or some thing?

#10
Jun 08, 2010, 10:28 pm Last Edit: Jun 08, 2010, 10:29 pm by bhagman Reason: 1
That's Grumpy Mike... By definition, he's ALWAYS having a bad day!
*SMOOCHES for Grumpy Mike*

So, yes, the limitation on the maximum frequency is because of the variable's value range.

If you modified tone() to accept frequency as unsigned long, it could produce signals as high as 8 MHz (on a 16 MHz part).

b

FYI, I'm sure, because I wrote the Tone library.

Noam

Thanks, and sorry Grumpy Mike...

Can one do what you just said, modified tone()?

What do you need to do exactly?  There is probably a much easier solution.

b

Noam

I was thinking to use it to make some weak, easy to control, radio signal.

If I use the pin HIGH, delay, pin LOW, delay.

I get a problem, that what ever I write on the program will change the signal, that why I was thinking about using tone()

What do you think?  :-?

Grumpy_Mike

I think you better look up the law in your country about radio transmitters. I think you will find that what you want to do is illegal.

Go Up