Tone()

Hi.

Simple Q :slight_smile:

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

Thanks.

No buddy knows?

why not google it ?
:wink:

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

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?

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.

Are you sure about it?

How much more sure than:void tone(uint8_t _pin, unsigned int frequency, unsigned long duration)
can you be?

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.

witch define the Hz, that can go over 60000.

which can't go over 60000

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

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

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.

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

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? :-?

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.

Yes using radio signal just like that is "wrong" ::). But I am not getting to the frequency that is illegal.... And maybe I am from Alaska... where every thing is free... :wink:

But I am not getting to the frequency that is illegal.

All frequencies are illegal if you transmit them.

Using tone() is just not the way to go for this purpose. You need a stable oscillator. Having one based on simply the crystal of an arduino and some software is not going to be stable or high enough frequency for you. The maximum you could expect to get is around 1MHz and more likely you are going to be able to only get in the few hundreds of KHz. Be aware that these are the sort of frequencies that are used to communicate with nuclear submarines and any un-authorised transmissions tend to attract people with helicopters and lots of guns no matter where in the world you are.

Not all frequencies are illegal and it depend on how you transmit them... some yard a way for an experiment will not let you talk to some rushen submarine comerat commander...

But you do say that you think I can get to 1Mhz... how? can I just write tone(pin, 1000000) that will not work, right?

Not all frequencies are illegal

Yes they are. Deliberate radiation of RF energy what ever the frequency by a home made device is illegal. Even the licence free bands have to have type approved transmitters you just can't make your own. It matters not how far you can detect it.

But you do say that you think I can get to 1Mhz... how

By loading the hardware counter timer with the appropriate value and letting it get on with it. This involves accessing the processor's register.
Look at how to change the PWM frequency that uses the same counters.

Well, toke some thing like a week, but the machine is ready, the Hzometer! mamama! and ya the highest frequency tone() can come to is 60KHz... It is good to know that ppl here know what they are talking about. :slight_smile: