Pages: [1] 2   Go Down
Author Topic: Tone()  (Read 2279 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi.

Simple Q smiley

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

Thanks.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No buddy knows?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

why not google it ?
 smiley-wink
Logged

Toronto, ON
Offline Offline
Full Member
***
Karma: 10
Posts: 233
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 634
Posts: 34528
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

UK
Offline Offline
Faraday Member
**
Karma: 17
Posts: 2884
Gorm deficient
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Are you sure about it?

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

Per Arduino ad Astra

0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 634
Posts: 34528
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Toronto, ON
Offline Offline
Full Member
***
Karma: 10
Posts: 233
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: June 08, 2010, 03:29:27 pm by bhagman » Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, and sorry Grumpy Mike...

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

Toronto, ON
Offline Offline
Full Member
***
Karma: 10
Posts: 233
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

b
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 634
Posts: 34528
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1] 2   Go Up
Jump to: