Cool LED Display

Monthly project competitions, chances to earn prizes, you decide project themes, your ideas, your projects, turn ideas into projects.

Back to The Project14 homepage

Project14 Home
Monthly Themes
Monthly Theme Poll

 

Cool LED displays. I don't have a lot of time at the moment, but wanted to do something [I did vote for it, after all] so I've

thrown together this - a simple bit of experimenting with an Arduino.

 

Rather than just light an LED, I thought I'd make it a little bit of a challenge and see if I could light a series string

of seven LEDs. The red LEDs I'm using have a forward voltage of around 2V, so that means I need something like 13V or 14V

to get them illuminated. I could have just used a bench supply to provide the LED voltage but that's not much fun and

wouldn't have made a very interesting blog so I'm going to generate the voltage from the Arduino's 5V with a very simple

and crude boost converter.

 

Here it is working (warning: world's worst video)

 

 

and here it is drawn as a circuit diagram

 

 

you can see how I just lashed the components together, without a breadbord or pcb, in this next photograph

 

 

How does it work? The MOSFET is switched by the Arduino. Let's consider a time where the output has been low for a while

and is just about to switch high - the gate voltage (relative to the source) is very low and the MOSFET is off. When the

Arduino pin goes high, the gate rises to something close to 5V and the MOSFET turns on. That happens fairly quickly. When

the MOSFET is on it behaves much as a small value resistor would (in this case, a few ohms), so at that point we have 5V

across the coil. The current through the coil can't change instantaneously, instead it starts to ramp up with the rate of

change dependent on the inductance - I chose the 10mH value so that it would ramp to about 20mA in a few tens of

microseconds, a time period which we could control quite accurately with the processor on the board. If you look at the

waveforms below, you can see the ramp up of the current [yellow trace is the output pin, blue trace is the coil current].

 

 

As it ramps, energy is being stored in the form of a magnetic field around the coil. After 60uS, the Arduino turns off

the MOSFET, and then the interesting bit happens; the magnetic field storing the energy can't remain there indefinitely,

so the coil needs to be rid of it. If it needs to, and in this case it does, it will do that by increasing the voltage at

the MOSFET end so as to maintain the current that was flowing at the time the switch turned off [as the energy stored is

used up, the current will fall until we are back to zero again]. Initially, the coil can charge the intrinsic capacitance

at the drain of the MOSFET and the capacitance of the LEDs, but those capacitances aren't all that large and it will

quickly attain a voltage where the LEDs turn on and then most of the energy will go to running the LEDs for a short

period. Repeating the process gives the illusion that the LEDs are on continuously. The next set of waveforms show the

voltage at the coil/MOSFET/LED node and the current that flows through the LEDs. As the current declines, the voltage

falls because the forward voltage of the LEDs depends on the current. When the energy stored by the coil is almost used

up, it no longer runs the LEDs but instead what's left of the energy moves back and forth from the coil to the

capacitance at that node [which of course includes the capacitance of the scope probe tip]. The ringing looks a bit

alarming but there's little energy there and it's not doing any real harm.

 

 

Sorry the current waveforms are a bit of a mess. The probe is a bit noisy and isn't that good with small currents.

 

A couple of points if you want to replicate this. Firstly, check the waveform timing produced by the Arduino before connecting the

circuit - there's no protection if the timing is wrong. Secondly, if the LED string is disconnected for any reason, the voltage

will increase until the current does flow, even if that means the coil has to avalanch the MOSFET to do it - so make sure

the LEDs are the right way round and connect properly - if you're a bit nervous, a 24V zener across the LED string would

provide an alternative path in the event of a fault.

 

Finally, here's the sketch I used.

 

int outPin = 9;   // output pin to use  
// the setup routine runs once when you press reset:
void setup() {
  // set output pin:
  pinMode(outPin, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
word onPeriod = 0;
  // LED on 
  for(onPeriod=0;onPeriod<5000;onPeriod++) {    // repeat for about half a second
    noInterrupts();
    digitalWrite(outPin, HIGH);   // pin is high
    delayMicroseconds(60);        // ...for 60 microseconds
    digitalWrite(outPin, LOW);    // then low
    interrupts();
    delayMicroseconds(60);        // ...for 60 microseconds
    }
  // LED off
  delay(500);   // off for half a second
}

 

If you want to try fading the LEDs, keep the high time constant and lengthen the low time.