0

Difference between analog and PWM
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Difference between analog and PWM

by magician13134 on Sat Feb 02, 2008 9:33 pm

What's the difference between analog and PWM? Isn't the analogOut() on the arduino the same as PWM? But is that the same as the PWM example I saw for the MiniPOV? Because I made a neat RGB mixer on the Arduino and I'd like to transfer it to work with a 2313 and no Arduino. It requires three pins that I could fade and one that would read a pot. Is this possible? Thanks
magician13134
 
Posts: 1119
Joined: Wed Jun 13, 2007 9:17 am
Location: Ann Arbor

by adafruit on Sat Feb 02, 2008 10:25 pm

for almost all microcontrollers, PWM == analog output
however, PWM is not == analog input
which is a bit confusing

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

by magician13134 on Sat Feb 02, 2008 10:30 pm

So I can't use a pot with the attiny2313? At all? Ever? Any other equal sized/priced/simple chips that I can? Will the product sheet say "Analog input on pins 4, 5, 6"?
magician13134
 
Posts: 1119
Joined: Wed Jun 13, 2007 9:17 am
Location: Ann Arbor

by adafruit on Sun Feb 03, 2008 1:57 am

yah from what i remember the attiny2313 dont got an ADC :( the attiny26 does i think.

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

by Entropy on Sun Feb 03, 2008 3:02 pm

Somewhere I recall seeing a description of using 1-2 digital input pins on a microcontroller combined with a little bit of external circuitry to implement a sigma-delta ADC.

I'll see if I can find a link...
Entropy
 
Posts: 472
Joined: Tue Jan 08, 2008 12:43 am
Location: Owego, NY USA

by CCarlson on Mon Feb 04, 2008 10:36 am

I'm an utter, abject newbie, so please forgive my ignorance...

The summary here says that the ATtiny2313 has 1 Analog Comparator--is this not the analog input you're looking for?
CCarlson
 
Posts: 35
Joined: Mon Sep 24, 2007 11:55 am
Location: Hewitt, TX

by Entropy on Mon Feb 04, 2008 11:49 am

A comparator only tells you whether the voltage on one input is greater or less than on another.

An ADC tells you what the voltage on a given pin is.
Entropy
 
Posts: 472
Joined: Tue Jan 08, 2008 12:43 am
Location: Owego, NY USA

by CCarlson on Mon Feb 04, 2008 1:19 pm

You know, if I'd spent even a moment thinking about it, that would have been totally apparent to me.

On the up-side, I've learned something new today. Now I'm off the hook for the rest of the day. Thanks!
CCarlson
 
Posts: 35
Joined: Mon Sep 24, 2007 11:55 am
Location: Hewitt, TX

by adafruit on Mon Feb 04, 2008 2:03 pm

Entropy wrote:Somewhere I recall seeing a description of using 1-2 digital input pins on a microcontroller combined with a little bit of external circuitry to implement a sigma-delta ADC.

I'll see if I can find a link...


IIRC, you can do that but only for measuring resistance, so good for photocells but not for like, IR distance sensors :(

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

by darus67 on Mon Feb 04, 2008 4:53 pm

Entropy wrote:Somewhere I recall seeing a description of using 1-2 digital input pins on a microcontroller combined with a little bit of external circuitry to implement a sigma-delta ADC.

I'll see if I can find a link...


Essentially you hang an R/C (resistance/capacitance, NOT Radio Control)
circuit out there and measure the rise time. Change the resistance and the rise time will change.

I know the Basic Stamp uses that sort of scheme to do analog input.
I disremember the exact details, unfortunately.


ladyada wrote:IIRC, you can do that but only for measuring resistance, so good for photocells but not for like, IR distance sensors :(


He wants to hook up a pot, so this should work fine.
"He's just this guy. You know?"
darus67
 
Posts: 246
Joined: Wed Sep 26, 2007 10:25 pm
Location: Minnesota, USA

by Søren on Sat May 03, 2008 11:58 am

Any µ-controller can do (voltage) A/D-C.

As long as it has 2 free I/O's at least - by adding 1 resistor, 1 cap for the timing and a comparator to compare the rising (or falling if you wanna be different :)) voltage to the analog voltage in question.

Measure the time from conversion start to comparator flags and you have a count proportional to the magnitude of the analog voltage (not linear though, but that can be solved with either a table or a function, or it can be lineariced with a CCG).
Søren
 
Posts: 14
Joined: Sat May 03, 2008 11:45 am
Location: Denmark

Please be positive and constructive with your questions and comments.