Go Down

Topic: PWM with AtTiny85 (Read 6 times) previous topic - next topic

tylernt


At the very least that seems to mean the pin is being toggled 4x on the AtTiny for every 1 time its toggled on the Arduino.  How that translates into higher quality audio, I'm not sure.
I probably shouldn't be posting to this thread, already having shown my cluelessness, but my understanding is the greater the sample rate, the greater the "horizontal" resolution if you were to look at the wave form on an oscilloscope.

The vertical or Y (amplitude) is any one of 255 steps (8-bit resolution), which makes for a stair-step effect and the audio quality suffers compared to 10-, 12-, or 16-bit which allows more and smaller steps: more and smaller steps gets you get a "smoother" and closer-to-a-true-sine waveform. Increasing the sample rate in the horizontal or X (frequency) axis is another way to reduce stairsteps and increase quality.

The standard Arduino Atmega chips have a 16-bit PWM ability that the ATTiny lacks. Even if the Arduino's sample rate is slower, the increased vertical resolution may make up for it. I.e., whether it's better to have 8-bit + high sample rate, or 16-bit + low sample rate, is a question I leave to the audiophiles.

Of course, your source sample rate has to match what you output. If you simply output at four times the frequency, your sounds effects will play in 1/4th the time and be and be much higher pitched.

scswift

Sample rate is actually much more important than bit depth.  An 8 bit 22khz file doesn't sound bad compared to a 16bit one.  Mainly you notice the lack of bit depth when you get static in the quiet bits.  But you can definitely hear the difference between an 11khz 16bit sound file and a 22khz 16bit file.  And an 8 bit 22khzz file is still going to sound better than an 11khz 16bit file.  Lower bit depth adds noise, but lower sampling rate means you lose high frequencies and the sound gets muddy.  But that's only to a point.  Above 44khz, you're not going to notice a difference.

Also, the 16bit pwm is of little use, because to count up to 65536 between each sample at 44khz would require the processor to be running at 2.8ghz.

At 64mhz, 10bit is doable though.

tylernt


At 64mhz, 10bit is doable though.
I thought the ATTiny had 8-bit timers/PWM? Does the ATTiny have a 10-bit timer/PWM I missed?

scswift

Some of them do:
http://forum.arduino.cc/index.php?topic=187068.msg1387338#msg1387338

GoForSmoke

Tiny x61's apparently.

There's enough specialized Tiny's to put on a whole dog show.


Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

tanik1

excuse my stupidity.

the link provided http://elm-chan.org/works/sd8p/report.html

what software do you need to view the source codes?

and can this be done with the arduino?

or is there someway the arduino can view this code?

GoForSmoke


The standard Arduino Atmega chips have a 16-bit PWM ability


Which are those? 328P and 2560 have 8 bit PWM.
Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

tylernt



The standard Arduino Atmega chips have a 16-bit PWM ability

Which are those? 328P and 2560 have 8 bit PWM.
Unless I'm reading it wrong (a distinct possibility), http://arduino.cc/en/Tutorial/SecretsOfArduinoPWM mentions that the 16-bit Timer1 can be used for PWM on, I believe, pins 9 and 10.

GoForSmoke

#23
Sep 26, 2013, 09:06 pm Last Edit: Nov 30, 2013, 09:19 pm by GoForSmoke Reason: 1
No, you got it right. It's the analogWrite() that's limited to 8 bits.

Nope, I got that wrong, there is more bits PWM possible with different AVR's. 10 bit PWM is not a special case.
Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

GoForSmoke


excuse my stupidity.

the link provided http://elm-chan.org/works/sd8p/report.html

what software do you need to view the source codes?

and can this be done with the arduino?

or is there someway the arduino can view this code?


If you're comfortable with AVR code and Arduino then you can embed the asm into the c.
http://www.nongnu.org/avr-libc/user-manual/group__asmdemo.html

I have done zero AVR assembler. I am fascinated at the idea of having 32 CPU registers to work with but so far the compiler is tight, faster to write, and does the right thing if I'm careful plus I already know C/C++ well enough for my Arduino needs.

There was an audio project with a wavetable or two earlier this year.
Nick Gammon on multitasking Arduinos:
1) http://gammon.com.au/blink
2) http://gammon.com.au/serial
3) http://gammon.com.au/interrupts

Go Up