Pages: [1]   Go Down
Author Topic: Delivering a Gradually Increasing Voltage to a Lamp  (Read 2743 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi! I'm a beginner with Arduino programming, and right now, I'm working on a project for my AS-level physics class. We're trying to devise an experiment to see if a lamp filament will behave as an ohmic conductor if voltage is increased quickly enough so as to not allow temperature to rise by any significant amount.

We tried this initially by using a rheostat acting as a potentiometer, and just increasing voltage really quickly, but this yielded unsatisfactory results. Thus, we were asked to devise a digital approach, which I am trying to do via Arduino. I also wanted to use this as a kind of opportunity to show that when functioning as a digital PWM, the Arduino is very effective, as I'd like to try make use of one in our robotics team and the same teacher is rather reluctant.

The way that I felt would be the best to try out is to use PWM programming to gradually increase the voltage supplied to the lamp, and then cut off this voltage entirely, with a delay before the next cycle. In this delay, I though it would be a good idea to have an LED blink once, to warn us to start the data logger.

So far, I have a basic code, but I'm not sure if it would work? I don't have the components to test it at home, nor the expertise to spot any problems. So it would be great if anyone could offer suggestions on how to make it better/if it would work at all. smiley-grin

Quote
// Intended to deliver 5V to a lamp over a time period
// Written using the 'Fade In' tutorial as a reference

int voltOut = 7;    // Lamp connected to digital pin 7
int ledPin = 13;    // LED to pin 13

void setup()  {
}

void loop()  {
 
    // fade in from min to max in increments of 1 point:
  for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=1) {
    // sets the value (range from 0(min) to 255(max)):
    analogWrite(voltOut, fadeValue);         
    // wait for 5 seconds to see the dimming effect   
    delay(5000);                           
  }

 digitalWrite(voltOut, LOW);
  delay(5000);
 
 digitalWrite(ledPin, HIGH);
  delay(1000);
 digitalWrite(ledPin, LOW);
  delay(5000);
}

Precisely what I want this program to do:
--> gradually supply voltage to a lamp, over 5 seconds
--> turn off the lamp for 5 seconds
--> blink a LED for 1 second
--> delay 5 seconds until next cycle

I would also really appreciate it if anyone could offer guidance with regards to setting up the circuitry on the board? I'm not quite sure how to explain this, but I mean, how would you go about connecting the lamp to the board? I'm working with an Arduino Uno, and I know that my circuit must run from Pin 7 to a resistor of around 220 Ohms to the lamp and back to the ground, but I'm sure how to physically attach this to the Arduino board? Or where on the board the ground pin is... My Arduino came without instructions, and I've had limited success with finding a solution for my exact board online. Any help here would be awesome.
A photo of the specific Arduino I'm using is attached.

Thanks so much. smiley I really appreciate any help anyone can offer!


* Arduino Board.jpg (2854.59 KB, 3562x2888 - viewed 8 times.)
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 611
Posts: 49092
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The analogWrite() function controls PWM - pulse with modulation. The pulses are 5V. The time that the pulse is HIGH is what varies. Unless the PWM is put through a low pass filter, the lamp will see a 5V voltage for a while, then a 0V voltage, then 5V again. It will not see 0V, then 0.1V, then 0.2V.

5 seconds between steps is a long time.
Logged

Malaysia
Offline Offline
Sr. Member
****
Karma: 7
Posts: 393
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hello cfish
there are a couple of question you need to answer first
A) Whats is the Voltage Rating for the lamp
B) Do you know the real meaning of PWM
C) Do you really need to have varying Voltage?

Depending on your application you may need an DAC or maybe A simple Resistor ladder DAC.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The analogWrite() function controls PWM - pulse with modulation. The pulses are 5V. The time that the pulse is HIGH is what varies. Unless the PWM is put through a low pass filter, the lamp will see a 5V voltage for a while, then a 0V voltage, then 5V again. It will not see 0V, then 0.1V, then 0.2V.

5 seconds between steps is a long time.

What I had thought was that as it pulsed between a low voltage and a high voltage, you would in essence end up with a lower average voltage, and then once the time spent at 5V rises, the average voltage would rise. This is at least how it was explained to me in the past, and how it seemed when working with PWMs to control motors for a ROV, although this seems to be wrong given your post? I'll do more research regarding this though to try and understand it better, in any case. Thank you! smiley

hello cfish
there are a couple of question you need to answer first
A) Whats is the Voltage Rating for the lamp
B) Do you know the real meaning of PWM
C) Do you really need to have varying Voltage?

Depending on your application you may need an DAC or maybe A simple Resistor ladder DAC.

a) 6V
b) Pulse Width Modulation, where an output alternating between a high and a low value contribute to an overall 'average' value depending on the lengths of time spent at each level of coltage
c) Yes, the point of the experiment is to steadily increase the voltage supplied to a lamp, and use a data logger to measure the current and voltage over time to produce a current-voltage characteristic for the lamp. I'm trying to do this digitally, over a short period of time (that is still long enough for the data logger to be able to record)

While a quick search has yielded me basic information on what a DAC is, I'm not quite sure how I would go about using one for this application. This website seems to be describing kind of what I originally intended:
Quote
Using the PWM as a DAC
Of course, you can also use the PWM outputs to get an analog output signal from the Arduino. Just put a low pass filter after the PWM output to get a nice & smooth output with a frequency range up to 16kHz, according to this Lab3 experiment.
http://embeddednewbie.blogspot.hk/2011/02/review-of-arduino-dac-solutions.html
I'm not sure how to relate this to my purpose and my code, though. Do you have any suggestions with regards to websites to look at, or any other directions you could steer me?
Thanks for your help! smiley
Logged

Malaysia
Offline Offline
Sr. Member
****
Karma: 7
Posts: 393
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hello cfish
there are a couple of question you need to answer first
A) Whats is the Voltage Rating for the lamp
B) Do you know the real meaning of PWM
C) Do you really need to have varying Voltage?

Depending on your application you may need an DAC or maybe A simple Resistor ladder DAC.

a) 6V
b) Pulse Width Modulation, where an output alternating between a high and a low value contribute to an overall 'average' value depending on the lengths of time spent at each level of coltage
c) Yes, the point of the experiment is to steadily increase the voltage supplied to a lamp, and use a data logger to measure the current and voltage over time to produce a current-voltage characteristic for the lamp. I'm trying to do this digitally, over a short period of time (that is still long enough for the data logger to be able to record)

While a quick search has yielded me basic information on what a DAC is, I'm not quite sure how I would go about using one for this application. This website seems to be describing kind of what I originally intended:
Quote
Using the PWM as a DAC
Of course, you can also use the PWM outputs to get an analog output signal from the Arduino. Just put a low pass filter after the PWM output to get a nice & smooth output with a frequency range up to 16kHz, according to this Lab3 experiment.
http://embeddednewbie.blogspot.hk/2011/02/review-of-arduino-dac-solutions.html
I'm not sure how to relate this to my purpose and my code, though. Do you have any suggestions with regards to websites to look at, or any other directions you could steer me?
Thanks for your help! smiley

good answer but you need to know that PWM will give you 5V and 0V only it just that it switch between 2 level so fast that the lamp/motor kinda get the average voltage only but the current it get is the full current that the 5V can supply. so your experiment you will kinda get varying voltage but constant current.
what you need is a DAC. what it does is convert a digital value to analog value. well simple way to say it is it convert a square wave(abrupt change from max to min or vise versa) to sine wave(gradual increase to max or gradual decrease to min).
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 611
Posts: 49092
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
What I had thought was that as it pulsed between a low voltage and a high voltage, you would in essence end up with a lower average voltage, and then once the time spent at 5V rises, the average voltage would rise. This is at least how it was explained to me in the past, and how it seemed when working with PWMs to control motors for a ROV, although this seems to be wrong given your post?
Motors have inertia. How much inertia does your lamp have? Motors can be fed a square wave, and the inertia acts like a low pass filter. Lamps, depending on the kind, may flicker if fed a PWM value. They certainly will NOT behave as though fed 3.8V, for instance.
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 98
Posts: 4803
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Could you just feed the highest voltage on a line with a big capacitor between VCC and GND and then a resistor before your filament? Or would that be too analog?
Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Pages: [1]   Go Up
Jump to: