Old 01-10-2014, 05:59 AM #1
Sigurthr's Avatar
Class 3B Laser
 
Join Date: Dec 2011
Location: Michigan's U.P.
Posts: 4,382
Rep Power: 3121
Sigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond repute
Sigurthr Sigurthr is offline
Class 3B Laser
Sigurthr's Avatar
 
Join Date: Dec 2011
Location: Michigan's U.P.
Posts: 4,382
Rep Power: 3121
Sigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond repute
Default The Arduino Thread

Hey everyone! I thought there was an overall arduino thread but a few searches revealed that I must have been misremembering such, so here it is.

I'm new to Arduino, mostly because I held off for years after having to wade through electronics neophytes who wrote ten lines of code, can't identify a capacitor, yet call themselves electronics enthusiasts or the like. Also, I didn't (and mostly still don't) have need for a MCU, except in few rare circumstances.

That being said, only a few days in I've put together a few cool things like a SSTC Interrupter (I've since ported the Digispark code I wrote over to Arduino, so it isn't just ATTiny85 specific now).

My most recent arduino project is threefold; anyone can take analog input and send it to a digital PWM output, but the real trick is getting quality audio out! Out of the box the Uno has a 10KHz sampling rate on the ADC pins and a 1KHz PWM frequency on pin 5 and 6, with half that rate on the others. After doing a lot of digging, reading of obscenely long datasheets, and scouring the web for hours I've been able to piece together and modify several chunks of code to increase the input and output speeds to over 64KHz!

The PWM output on Pin 5 and 6 is set to 64KHz carrier.

The ADC Clock is set to 1MHz, which yields a 77KHz sampling rate (that's better than your PC's inputs!).

The result:


Arduino Hi Fi Audio PWM - YouTube

Here's the code and schematic for anyone who wants to try (that's the whole idea behind arduino isn't it? standardized platform and software for easy sharing!)



Code:
/* Arduino Uno Audio PWM Modulator
   by Matt "Sigurthr" Giordano. 1/9/2014.
Audio Input on Analog 0, PWM output on Digital 6.
I/O circuitry as follows:
Input: capacitor couple iPod audio through 4.7uF.
Bias Input pin to 2.5V with one 10k resistor to 5v,
and another 10k resistor to ground to form a voltage divider.
Output goes to a RC filter made of a series 560 ohm resistor
and a parallel 0.1uF capacitor.
Capacitor couple this node to amplifier of choice.
*/
int duty;
int raw;
int bias = 192;
void setup(){
  TCCR0B &= B11111000;
  TCCR0B |= B00000001;
  // PWM Boost pins 5 & 6 to 64KHz

// ADC Boost Start - sets ADC clock to 1MHz
// defines for setting and clearing register bits
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif

// set ADC prescaler to 16
  sbi(ADCSRA,ADPS2) ;
  cbi(ADCSRA,ADPS1) ;
  cbi(ADCSRA,ADPS0) ;
// ADC Boost End
}
void loop(){
  raw = analogRead (0);
  duty = bias + ((raw - 512)/4);
  analogWrite(6, duty);
}


__________________
Amateur Multispectral Photographer - [X-Ray, UV, Vis, IR]
Amateur Electrical Engineer
Autodidact
Tesla Coil Expert
Sigurthr is offline   Reply With Quote


















Old 01-10-2014, 09:04 AM #2
DashApple's Avatar
Class 3R Laser
 
Join Date: Jan 2009
Location: Someplace on earth
Posts: 1,394
Rep Power: 143433
DashApple has a reputation beyond reputeDashApple has a reputation beyond reputeDashApple has a reputation beyond reputeDashApple has a reputation beyond reputeDashApple has a reputation beyond reputeDashApple has a reputation beyond reputeDashApple has a reputation beyond reputeDashApple has a reputation beyond reputeDashApple has a reputation beyond reputeDashApple has a reputation beyond reputeDashApple has a reputation beyond repute
DashApple DashApple is online now
Class 3R Laser
DashApple's Avatar
 
Join Date: Jan 2009
Location: Someplace on earth
Posts: 1,394
Rep Power: 143433
DashApple has a reputation beyond reputeDashApple has a reputation beyond reputeDashApple has a reputation beyond reputeDashApple has a reputation beyond reputeDashApple has a reputation beyond reputeDashApple has a reputation beyond reputeDashApple has a reputation beyond reputeDashApple has a reputation beyond reputeDashApple has a reputation beyond reputeDashApple has a reputation beyond reputeDashApple has a reputation beyond repute
Default Re: The Arduino Thread

Nice ,
__________________
I don't know what you had in mind
But here we stand on opposing sides .

Last edited by DashApple; 01-10-2014 at 09:06 AM.
DashApple is online now   Reply With Quote
Old 01-10-2014, 12:12 PM #3
Tmack's Avatar
Class 3R Laser
 
Join Date: Oct 2013
Location: Baltimore MD
Posts: 2,478
Rep Power: 2310
Tmack has a reputation beyond reputeTmack has a reputation beyond reputeTmack has a reputation beyond reputeTmack has a reputation beyond reputeTmack has a reputation beyond reputeTmack has a reputation beyond reputeTmack has a reputation beyond reputeTmack has a reputation beyond reputeTmack has a reputation beyond reputeTmack has a reputation beyond reputeTmack has a reputation beyond repute
Tmack Tmack is offline
Class 3R Laser
Tmack's Avatar
 
Join Date: Oct 2013
Location: Baltimore MD
Posts: 2,478
Rep Power: 2310
Tmack has a reputation beyond reputeTmack has a reputation beyond reputeTmack has a reputation beyond reputeTmack has a reputation beyond reputeTmack has a reputation beyond reputeTmack has a reputation beyond reputeTmack has a reputation beyond reputeTmack has a reputation beyond reputeTmack has a reputation beyond reputeTmack has a reputation beyond reputeTmack has a reputation beyond repute
Default Re: The Arduino Thread

Was looking to learn more about these. This is a welcome thread. Thanks.
__________________

NOIR Lasershields OD7 DBY Filter Operator
405nmMarble Zaser 1060mw *
405nmFocus pen 80mw Pman
445nm Cypress 2750mw*
445nm MS-Envy 2645mw*
445nmMarble Zaser 2940mw*
445nmMag Light Mr crouse Heatsink 2790mw Jayrob & Speedy78*
445nmWicked Laser EVO E2 Custom M140 G2 1580mw*
520nm Sipik 125mw*
532nmHL532 505mw bloompyle
532nmCree B68 Pman Special 120mw, B&D 86mw,
638nmMarble Zaser 510mw *
650nmSFCR 280mw Joker
LK-3D Projector Hakzaw1 GB
Casa CTL-HM Projector Livinloud GB. -----((O))
Chauvet 40 DMX Controller Brucemir
Ophir 5w LPM*
R, G, B, V Marble Zaser set
Need a custom build? Send me a message

LED's - TK75vn killerthrow, BTU Shockervn, MX25L3vn, D40avn, TK61vn ( 622kcd!!) , D25Cvn ti, Mm15vn, V11rvn, V25cvn, C20cvn, S200c2vn, convoy m1 xml2 3a X2 , convoy c8, Tcr10vn, Tcr2vn VIP, X60vn V2, Hc90vn , Mh25, K40mvn (mtg2),Sd6vn, Pd35vn (xpl triple) Sinner titanium xml2

Last edited by Tmack; 01-10-2014 at 12:13 PM.
Tmack is offline   Reply With Quote
Old 01-10-2014, 02:31 PM #4
Seoul_lasers's Avatar
Class 3R Laser
 
Join Date: Jul 2008
Location: Victoria, British Columbia
Posts: 2,450
Rep Power: 193365
Seoul_lasers has a reputation beyond reputeSeoul_lasers has a reputation beyond reputeSeoul_lasers has a reputation beyond reputeSeoul_lasers has a reputation beyond reputeSeoul_lasers has a reputation beyond reputeSeoul_lasers has a reputation beyond reputeSeoul_lasers has a reputation beyond reputeSeoul_lasers has a reputation beyond reputeSeoul_lasers has a reputation beyond reputeSeoul_lasers has a reputation beyond reputeSeoul_lasers has a reputation beyond repute
Send a message via Skype™ to Seoul_lasers
Seoul_lasers Seoul_lasers is online now
Class 3R Laser
Seoul_lasers's Avatar
 
Join Date: Jul 2008
Location: Victoria, British Columbia
Posts: 2,450
Rep Power: 193365
Seoul_lasers has a reputation beyond reputeSeoul_lasers has a reputation beyond reputeSeoul_lasers has a reputation beyond reputeSeoul_lasers has a reputation beyond reputeSeoul_lasers has a reputation beyond reputeSeoul_lasers has a reputation beyond reputeSeoul_lasers has a reputation beyond reputeSeoul_lasers has a reputation beyond reputeSeoul_lasers has a reputation beyond reputeSeoul_lasers has a reputation beyond reputeSeoul_lasers has a reputation beyond repute
Send a message via Skype™ to Seoul_lasers
Default Re: The Arduino Thread

Hey good post there.
I find this very interesting that you can get this high a sample rate from something as
low powered as an Arduino UNO.
Great find.
I wonder if this code could be taken further and be used to decode Async USB digital audio as a DAC.

Well, guess what I found....
The ardunio uno can talk to the Wolfson Audio DAC natively.
Wow!! Have a look below!!

http://hifiduino.wordpress.com/intro...-to-hifiduino/
__________________
650nm ~350mW DVD 20x diode RyanSoh3 Class IIIb
650nm ~350mW DVD 22x 3.5mm labby build 2010 Class IIIb
532nm 10mW-15mW DPSS Module IR filtered(S.Korea)RyanSoh3 Class IIIb
450nm CarbonFiber ElectricPlasma build 9mm +6W Class IV
445nm 3.49W pk ~3.15W av. Sinner Cypreus II +DTR 9mm 445nm Class IV
445nm RHD Saber Twins 2.7W ~2.35W pk Class IV
445nm A140 module x2 Maxsink Class IV
405nm Daguin Kryton Groove SO6J 700mW build. Class IV
405nm Olike 560mW-600mW pen sold Scopeguy20
Class IV
337.1nm TEA Nitrogen laser project 2011 Class IIIb
---------------------------------------------------
Die4Drivers 1.3v lab laser/projector driver

Laserbee 3.2W Deluxe LPM
ARGMeter 1.1v
Ophir 20C-A sensor

Peregrine 1.5.0 is working now on MacOSX Yay!!

Last edited by Seoul_lasers; 01-10-2014 at 03:32 PM.
Seoul_lasers is online now   Reply With Quote
Old 01-11-2014, 12:53 AM #5
Sigurthr's Avatar
Class 3B Laser
 
Join Date: Dec 2011
Location: Michigan's U.P.
Posts: 4,382
Rep Power: 3121
Sigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond repute
Sigurthr Sigurthr is offline
Class 3B Laser
Sigurthr's Avatar
 
Join Date: Dec 2011
Location: Michigan's U.P.
Posts: 4,382
Rep Power: 3121
Sigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond reputeSigurthr has a reputation beyond repute
Default Re: The Arduino Thread

Ooh nice find on that blog! There's a video on there about an audio engineer prototyping as well.
__________________
Amateur Multispectral Photographer - [X-Ray, UV, Vis, IR]
Amateur Electrical Engineer
Autodidact
Tesla Coil Expert
Sigurthr is offline   Reply With Quote
Reply





Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

























Privacy Policy | Advertising Disclaimer | Terms of Use


 


All times are GMT. The time now is 12:17 PM.


Powered by: vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO
Privacy Policy | Advertising Disclaimer | Terms of Use
Copyright (C) 2017 Laser Pointer Forums, LLC