Arduino Forum

Forum 2005-2010 (read only) => Hardware => Interfacing => Topic started by: dep on Dec 21, 2009, 09:36 pm

Title: Analog input: PWM
Post by: dep on Dec 21, 2009, 09:36 pm
Hello everyone,
I have just received my first Arduino, and am very impressed with it. Hardware that's simple enough for a software guy like me! ;D

However, I've also run into my first problem. I'm trying to read an analog control voltage that I measured to be in the 0-5 V range. Couldn't be simpler as it is already in the perfect range for an Arduino, right? Well, what I discovered after trying it out was that the voltage is microprocessor controlled, and looks like this when I read it from the Arduino:
(http://ultraxs.com/thumb-94DB_4B2FD845.jpg) (http://ultraxs.com/share-94DB_4B2FD845.html)

So, I am assuming this is some kind of pulse-width modulation (http://en.wikipedia.org/wiki/Pulse-width_modulation)..?  :-?
For the record, reading the analog input as such works ok, with the connection in the AnalogInput tutorial (http://www.arduino.cc/en/Tutorial/AnalogInput). My connection is the same, except ground goes to ground and analog0 to the control voltage on the device.

So, my question is: how should I go about reading the voltage correctly (so that the value I get is unfluctuating, like the display on my voltmeter)?

Thanks in advance :)
Title: Re: Analog input: PWM
Post by: retrolefty on Dec 21, 2009, 10:04 pm
To convert a PWM signal to a true analog voltage it has to pass through a low pass filter. That can be as simple as a resistor/cap filter to a op-amp active filter. Search around the site you should fine something on using a low pass filter.

Lefty
Title: Re: Analog input: PWM
Post by: Grumpy_Mike on Dec 22, 2009, 01:21 am
This goes a little into filtering a PWM signal:-
http://www.thebox.myzen.co.uk/Tutorial/PWM.html
Title: Re: Analog input: PWM
Post by: dep on Dec 23, 2009, 02:05 pm
Alright, thanks for the tips! I will post about my progress as I make some ;)
Happy holidays!
Title: Re: Analog input: PWM
Post by: dep on Jan 19, 2010, 02:22 pm
Alright! I think I actually understood the PWM guide, to a degree, and managed to get the input working. Many thanks for the help! :)
You can have a look at my project here (http://matiaswilkman.blogspot.com/2010/01/thought-controlled-vvvvisuals.html).
Title: Re: Analog input: PWM
Post by: Grumpy_Mike on Jan 19, 2010, 03:02 pm
Glad you got it working, thanks for the link to the PWM page.
Cheers.
Title: Re: Analog input: PWM
Post by: andrew0 on Jan 19, 2010, 03:10 pm
Is it really measuring brain activity, or is it something else like electrical signals from muscle contractions in your forehead when you frown in concentration?

Andrew
Title: Re: Analog input: PWM
Post by: Grumpy_Mike on Jan 19, 2010, 11:51 pm
My guess is the latter.  ;)
Title: Re: Analog input: PWM
Post by: dep on Jan 20, 2010, 01:07 pm
Quote

Is it really measuring brain activity, or is it something else like electrical signals from muscle contractions in your forehead when you frown in concentration?


From Wikipedia: "EEG is the recording of electrical activity along the scalp"
So, it is measuring brain activity, and it is measuring electrical signals on your forehead :)
It's a science toy, so it is not to be taken too seriously, but the principle is the same as in medical EEG. The main differences are probably resolution, and the fact that a real EEG cap looks like this:

(http://upload.wikimedia.org/wikipedia/en/b/bf/EEG_cap.jpg) ;)
Title: Re: Analog input: PWM
Post by: Grumpy_Mike on Jan 20, 2010, 02:25 pm
Quote
So, it is measuring brain activity, and it is measuring electrical signals on your forehead


So you put an electrode on your head. How do you tell if the resulting signal is coming from the brain activity or from muscle activity?

Quoting a definition of what an EEG recording is does not mean that is what you have.