Problems with tone on Uno. Hardware issue?


i think uno hardware issue, not programming issue, posted in forum.

my understanding tone(x, y) generate square wave tone @ y hz on line x

what find tone isn't y hz , doesn't shift in 1hz steps:

examples:

tone (10, 1500) puts tone of 1504.9 hz out on line 10
tone (10, 1498) generates 1054.9 hz tone
tone (10, 1497) generates 1495.9 hz tone
values 1497 1488 generate same 1495.6 hz tone
then @ tone(10,1487) 1487.0 tone generated.

i'm not worried actual frequency that's being generated being off fact tone doesn't change in ~1hz steps when value in tone function changes 1. seems need changed 10, @ least on short span i'm looking at, , shifts frequency 10 hz, not 1hz.

this isn't manual says (or @ least implies).

this entire program:

void setup() {
}
void loop() {
   tone (10, 1482); // 1482 hz?
}

is hardware limitation of arduino? presume tone uses sort of internal counter. misreading manual? need generate tones @ 1hz intervals (1500, 1499, 1498 etc.) apparently can't "tone". in software loops, delays, counters etc., manual suggests can done tone.

tone() creating audible tones on cheap piezo elements , speakers. kind hz of precision nor frequency accuracy matter. it's why called tone() , not frequency().

this isn't "hardware issue." it's how software implemented use hardware.

the way frequency generated scaling clock driving 8-bit counter. there's finite resolution available results in amount of error.

if need precision frequency generation, want @ clock generator or frequency synthesizer, controlled microcontroller.

for record, mine inaccurate (but functioning correctly) yours.


Arduino Forum > Using Arduino > Project Guidance > Problems with tone on Uno. Hardware issue?


arduino

Comments

Popular posts from this blog

Flip address is out of range arduino uno r3

Arduino Uno not uploading

Indesign and MathType fonts