Pittsburgh, PA, USA
Offline
Faraday Member
Karma: 29
Posts: 2888
I only know some basic electricity....
|
 |
« on: February 01, 2013, 11:48:53 am » |
PWM driven led coupled with a 'slow' photocell?
|
|
|
|
|
Logged
|
Examples can be found at Learning in the Main Site and at the Playground
|
|
|
|
Global Moderator
Boston area, metrowest
Offline
Brattain Member
Karma: 240
Posts: 16465
Available for Design & Build services
|
 |
« Reply #1 on: February 01, 2013, 11:50:24 am » |
Why not just PWM into an RC filter?
|
|
|
|
|
Logged
|
|
|
|
|
Pittsburgh, PA, USA
Offline
Faraday Member
Karma: 29
Posts: 2888
I only know some basic electricity....
|
 |
« Reply #2 on: February 01, 2013, 11:52:09 am » |
I'm not that good? Would it require much more than a cap or two and resistors?
|
|
|
|
|
Logged
|
Examples can be found at Learning in the Main Site and at the Playground
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15312
Measurement changes behavior
|
 |
« Reply #3 on: February 01, 2013, 11:55:32 am » |
I'm not that good? Would it require much more than a cap or two and resistors?
One cap, one resistor, but after that it depends on what you are wiring the then true analog voltage too. If it requires any significant current then you need to add a buffering amp or other method to supply the 'load current'. Lefty
|
|
|
|
|
Logged
|
|
|
|
|
London, England
Offline
Newbie
Karma: 1
Posts: 46
Arduino rocks
|
 |
« Reply #4 on: February 01, 2013, 12:03:52 pm » |
Depending what you are driving, a cap to gnd can be enough to turn pwm into analog.
If you want a true analog though, use a cap and resistor into an op-amp set up for voltage following, this will avoid all feedback errors from the load.
|
|
|
|
|
Logged
|
|
|
|
|
Pittsburgh, PA, USA
Offline
Faraday Member
Karma: 29
Posts: 2888
I only know some basic electricity....
|
 |
« Reply #5 on: February 01, 2013, 12:07:18 pm » |
Thanks guys. This is partly an in-general thing and partly there's sound oscillator circuits in an old electronics kit cookbook and I'm thinking of ways to control a resistor (besides a manual pot which is what the old cookbook has) to change the tone. After that I might want to futz with the cap to see what that effect that might have.
I don't always like square-wave sound. And yeah, for you I'm still taking the wrong train, right?
|
|
|
|
|
Logged
|
Examples can be found at Learning in the Main Site and at the Playground
|
|
|
|
Manchester (England England)
Online
Brattain Member
Karma: 271
Posts: 25430
Solder is electric glue
|
 |
« Reply #6 on: February 01, 2013, 12:36:40 pm » |
You are not going to get much audio through a slow photo cell. By that I assume you mean a light dependent resistor. See this for discussion of filtering a PWM signal:- http://www.thebox.myzen.co.uk/Tutorial/PWM.html
|
|
|
|
|
Logged
|
|
|
|
|
Pittsburgh, PA, USA
Offline
Faraday Member
Karma: 29
Posts: 2888
I only know some basic electricity....
|
 |
« Reply #7 on: February 01, 2013, 05:09:20 pm » |
If I can change a resistor then I control the tone of an independently operating sound oscillator circuit.
I was thinking of replacing a resistor with a cadmium cell or like then PWM a led on that. But as you guru's point out, a simple to less simple filter will flatten PWM output better for less.
|
|
|
|
|
Logged
|
Examples can be found at Learning in the Main Site and at the Playground
|
|
|
|
|
|
Pittsburgh, PA, USA
Offline
Faraday Member
Karma: 29
Posts: 2888
I only know some basic electricity....
|
 |
« Reply #9 on: February 01, 2013, 05:49:16 pm » |
IIRC vanilla PWM is 490 Hz variable width pulse, or is it closer to 500 Hz? Couldn't the same low-pass filter work for 0-100 PWM?
|
|
|
|
|
Logged
|
Examples can be found at Learning in the Main Site and at the Playground
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15312
Measurement changes behavior
|
 |
« Reply #10 on: February 01, 2013, 05:53:58 pm » |
IIRC vanilla PWM is 490 Hz variable width pulse, or is it closer to 500 Hz? Couldn't the same low-pass filter work for 0-100 PWM?
Depends on the -3db corner frequency of the specific R/C filter used. Lowering the switching frequency would normally call for lowering the cornering frequency of the filter. A given low pass filter will contiune to perform as designed as you raise the pwm switching frequency, but might require adjustment as you lower the switching frequency. Lefty
|
|
|
|
|
Logged
|
|
|
|
|
Pittsburgh, PA, USA
Offline
Faraday Member
Karma: 29
Posts: 2888
I only know some basic electricity....
|
 |
« Reply #11 on: February 01, 2013, 06:32:49 pm » |
Yes but vanilla Arduino PWM has a default full cycle that doesn't change the clocks. It should be fast enough. But as I read, how fast I want to change the PWM -level- (assuming like 10% duty cycle to 90%) is more the deal? RC = 1/2piF F = 1/2piRC Does this frequency limit how smoothly DC output will change as PWM level changes? If so, that would be the smoothness the audio circuit the filtered PWM could change frequency as well as how fast I could jump from one note to another.
|
|
|
|
|
Logged
|
Examples can be found at Learning in the Main Site and at the Playground
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15312
Measurement changes behavior
|
 |
« Reply #12 on: February 01, 2013, 06:42:00 pm » |
Yes but vanilla Arduino PWM has a default full cycle that doesn't change the clocks. It should be fast enough. But as I read, how fast I want to change the PWM -level- (assuming like 10% duty cycle to 90%) is more the deal? RC = 1/2piF F = 1/2piRC Does this frequency limit how smoothly DC output will change as PWM level changes? If so, that would be the smoothness the audio circuit the filtered PWM could change frequency as well as how fast I could jump from one note to another. Filtering of a pwm output to generate a variable true analog DC voltage level is certainly a viable solution for some applications. But trying to generate variable audio frequencies via PWM output is just not a very practical solution in my mind. And it's not about the ability of filtering out the basic PWM switching frequency, but rather how to encode the audio frequency into PWM duty cycle values that have to change constantly with time even at a fixed audio frequency, it makes my head hurt trying to visualize that coding task. A 8 bit AVR chip is not the best candidate for want of a sine wave DDS generator. Lefty
|
|
|
|
« Last Edit: February 01, 2013, 06:48:44 pm by retrolefty »
|
Logged
|
|
|
|
|
Pittsburgh, PA, USA
Offline
Faraday Member
Karma: 29
Posts: 2888
I only know some basic electricity....
|
 |
« Reply #13 on: February 01, 2013, 10:09:55 pm » |
But trying to generate variable audio frequencies via PWM output is just not a very practical solution in my mind.
I don't want to generate the frequencies. I want to influence what frequency an audio generator creates and I'd like to be able to slide the tone up and down quickly, dig? I'd like to control volume too, ADSR kind of thing.
|
|
|
|
« Last Edit: February 01, 2013, 10:11:37 pm by GoForSmoke »
|
Logged
|
Examples can be found at Learning in the Main Site and at the Playground
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 92
Arduino rocks
|
 |
« Reply #14 on: February 01, 2013, 10:33:24 pm » |
I play guitar so that helps me understand what you are getting at. You've got some sort of voltage-controlled analog effect box circuit that you'd like to put under digital Arduino control by using PWM and an R/C filter to generate the control voltage for the effect. I've thought of that before, and it would seem to be fine in theory (if your circuit is happy with 0-5V for your analog control, and doesn't take too much current); otherwise as mentioned you'll want an op amp to get a different range.
|
|
|
|
|
Logged
|
|
|
|
|
|