Dec182010

Kit building: vacuum fluorescent display clock

Published by paul at 2:51 PM under Kit Building | VFD

I've always been intrigued by vacuum fluorescent displays (VFDs) so I picked up the Ice Tube Clock Kit from AdaFruit Industries that uses a Russian VFD tube.

(Click any photo for a 1024x768 image.)

Here's what came in the kit:

 

And here are a couple of shots of the VFD tube. It has 8 x 7-segment digits, with decimal points and a minus sign.

 

There's a great page on AdaFruit's website that describes the circuit and the calculations that went into designing it - check it out!

The building instructions are very thorough, as always, and this time includes test points as building progresses. On the left is a shot of testing the 7805 regulator, and on the right is testing the voltage booster circuit for the VFD.

 

Once I had the main board made, it was time to thread the VFD into it's PCB. This was a finnicky task but with patience it only took 15 minutes. The leads from the VFD bend very easily, which is a blessing and a curse. On the left you can see what I mean, and on the right I've got it ready to solder.

 

And here's it soldered and nicely clipped.

 

Did a quick test and it worked! Then I put in the final few components on the main board and assembled the laser-cut perspex case.

Here are a couple of shots of the completed main PCB:

 

 

And the clock itself... and in it's final resting place.

 

Hope you enjoyed the photos - let me know if these kinds of posts are interesting!



[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Currently rated 1.7 by 303 people

  • Currently 1.660065/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

E-mail | Permalink | Trackback | Post RSSRSS comment feed 0 Responses

Dec182010

More Arduino shields to play with...

Published by paul at 12:14 PM under Arduino

It's been quite a while since I've had bandwidth to sit down and get stuck into electronics again, but now I'm home for almost two months, so I'll be blogging more on here.

Over the last few months I've discovered some new Arduino shields to play with and ordered them up. Here's what I got:

1) The Wingshield Screwshield kit from Adafruit Industries. Took me about 5 minutes to solder together.

 

2) The Motor/Stepper/Servo Shield kit from Adafruit Industries. Took me about 1/2 hour to solder together.

 

3) The Arduino Ethernet Shield with micro SD connector. This comes assembled and I got it from SparkFun Electronics.

 

4) The WiShield from async_labs that provides 802.11b wireless. This also comes assembled.

 

5) The Joystick Shield Kit from SparkFun Electronics. Took about 15 minutes to solder together.

 

6) The Color LCD Shield from SparkFun Electronics. This just needed the headers soldered on.

Lots of potential for tinkering and cool stuff here!



[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Currently rated 1.8 by 65 people

  • Currently 1.830768/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

E-mail | Permalink | Trackback | Post RSSRSS comment feed 0 Responses

Oct022010

Kit building: Four interactive light panels connected together

Published by paul at 7:24 AM under Kit Building | LED Projects

Well, summer's over and that means I can justify being indoors playing with (and blogging about) electronics again. Expect this blog to get busy again!

Back in March I blogged about building an interactive light panel from Evil Mad Science Laboratories. Over the summer I built the other three light panel kits I'd ordered and finally got around to hooking them together and testing them out.

They fit together using 8-pin connectors in any configuration imaginable. Below are two photos of the connectors (borrowed from their website):

 

Below are three photos showing my four panels in a variety of configurations (click for larger versions):

 

 

Finally, I shot some short videos showing the 1 x 4 configuration in action:

Next up will be some more Arduino stuff...



[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Currently rated 1.7 by 72 people

  • Currently 1.666667/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

E-mail | Permalink | Trackback | Post RSSRSS comment feed 1 Responses

Mar122010

Kit building: Evil Mad Science interactive light board

Published by paul at 12:53 PM under Kit Building | LED Projects

It's been another few weeks of traveling and client work so I haven't had any chance to tinker. Apologies to those subscribers expecting the frenetic pace of my SQL blog - ain't gonna happen. I'm at home for a few weeks now though, so should have spare cycles to get back to the Arduino.

This week I decided to build a kit, as I didn't have time to get stuck into something more intellectually challenging. A while ago I'd ordered a set of 4 interactive light panel kits from Evil Mad Science so I chose to make one of those (I've also got an RGB Peggy 2 board that I'm itching to make!).

I'm very impressed with the kit - the instructions are *excellent* - totally suitable for a novice, but easily digestable by someone more advanced without being annoyingly simple. The packaging is great too - with all components packed and labeled separately - not something I expect, but a nice time saver.

The kit took me about 4 hours of soldering and neat lead-snipping to put together. I powered it on and it worked first time. However, it's supposed to work in the dark and I couldn't get anything out of it. The board looked perfectly put together so I contacted Evil Mad Science. Windell replied within 90 minutes with some suggestions. I replied that I've got a degree in electronics so talk techie - smileys ensued and we troubleshooted (troubleshot?). I'd hooked up a spare IR LED and shown that the phototransistors were working, but obviously the IR LEDs on the board weren't - with only about 10mV foward voltage across each. The whole IR LED circuit has 24V through it, so something was sucking down the power. I traced it to a broken IR LED with very high resistance both ways, and taking 18V - no wonder it wasn't working. I swapped out the broken LED and put in another, and hey presto! Great technical support!

Great kit to put together and I'm going to build a wall tile to hang in the house somewhere!

Here's a link to a 25sec video I shot on YouTube: http://www.youtube.com/watch?v=51dUYjEgTi8

Here are some photos (click for larger images):

Left: kit contents for one board. Right: PCB (*really* well produced).

 

Left: ready to start soldering. Right: Completed board ready for testing.

 



[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Currently rated 3.1 by 13 people

  • Currently 3.076923/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

E-mail | Permalink | Trackback | Post RSSRSS comment feed 1 Responses

Feb172010

Arduino: Windows simulator of driving matrices of 8x8 LED arrays

Published by paul at 8:32 AM under Arduino | Example Code | LED matrix | LED Projects

It's been a couple of weeks since I've been able to play hands-on with electronics because I've been busy with client work and out-of-town traveling.

To continue satisfying my must-be-tinkering-with-something urges, I hit upon the idea of using some old Windows code I had lying around to allow me to program LED matrices, without the LED matrices or an Arduino. This means I can effectively be developing code for the Arduino while on the road (we travel around 50% of the year seeing our clients around the world). The old code was for a life simulator (creatures running around fighting, breeding, etc) but it had all the code to display a bitmap on screen and update it already worked out. I figured that I could use it to simulate an 8x8 LED matrix - so off I went.

What it turned into is a couple of classes that simulate a maze and an 8x8, 16x16, or 32x32 LED display. I thought the code would be useful to a bunch of you so I've zipped it up for you to download and play with. The cool thing is that I can work on the maze processing code while on the road and then come home and drop it into the Arduino environment to compile and use. As long as I have LED matrix driving code on the Arduino, it should work like a charm.

Here's a screenshot of the simulator running:

 

Black 'dots' are on LEDs, spaces are off LEDs, the lighter colored dot is supposed to be a different color LED to represent a person. The simulator can switch between 8x8, 16x16, and 32x32 displays by pressing the Page Up and Page Down keys. Movement is through the arrow keys. The display mode can either be static with screen changes when the person crosses a window border (i.e. the person moves around on the screen) or scrolling, where the person stays still and the maze moves around. Pressing S switches between the two modes.

The code is in a zip file: Maze021710.zip (12.1k) and I've been using VS 2005 Professional to develop and debug.

There are plenty of comments in the code and I'm happy to answer questions about it.

Enjoy!



[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Currently rated 1.7 by 123 people

  • Currently 1.731706/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

E-mail | Permalink | Trackback | Post RSSRSS comment feed 0 Responses

Jan312010

Arduino: cascading shift registers to drive 7-segment displays with PC input

Published by paul at 3:33 PM under Arduino | Example Code | Example Movies | LED Projects | Shift Registers

In the last post I figured out how to drive a 74HC595 shift register to control 8 LEDs from only 3 digital outputs of the Arduino. Now I've taken that a step further and cascaded (sometimes called daisy-chained) four 595s together to drive 7-segment displays and also added code to accept input from the PC.

Instead of using 10-LED bar graphs like I did last time, I've moved on to 7-segment displays - which are more challenging and provide a more meaningful output. The 7-segment displays I have are common-cathode, wired as shown below:

    a           a - pin 14       dp (decimal point) - pin 9
   ---          b - pin 13       common cathode - pins 12 and 4
f |   | b       c - pin 8
   --- g        d - pin 7
e |   | c       e - pin 6
   --- . dp     f - pin 2
    d           g - pin 1
               

The code to illuminate decimal digits on a 7-segment display is pretty straightforward. I assigned each of the 7 segment-pins on the display to an output on the 595, from QA through QG (see the circuit diagram below). Each pin from QA to QG is assigned a binary value of 2 ^ pin#, so figuring out which pins to make high to produce each decimal digit is just a matter of adding together the binary values representing each pin necessary to light up the right segments. You can see this array being initialized in the setup() function.

I've also moved to a proper coding style, with g_ prefixing each global variable to distinguish them from local variables inside functions and methods. It's a good practice to define unchanging variables as const to allow the compiler to optimize the code around them - this also prevents mistakes where the code accidentally tries to change the value - the compiler won't allow it as the variable is effectively read-only and a difficult-to-debug bug is avoided.

To daisy-chain 595s together is really simple - connect the serial output (pin 9) of the 'lowest' 595 to the serial input (pin 14) of the next one in the chain, and connect all the latch (pin 12) and clock (pin 11) inputs together. When the first 595 accepts a new bit, the highest bit in the register will be pushed out of it's serial line as input to the next 595 in the chain. Enough bits must be pushed to fill all the 595s with new data correctly. In the previous post I only had a single 595 so I only had to push 8 bits of data from the Arduino. With two 595s I need to push 16 bits, with the first 8 bits effectively flowing through the first 595 and into the second. And so on with more 595s in the chain.

Care must be taken to push the 8-bit values in the correct order - the 8 bits for the 595 furthest from the Arduino must be pushed first, and the 8 bits for the 595 nearest the Arduino in the chain must be pushed last. I do this in the code in the sendSerialData() function by passing in the number of registers in use, plus a pointer to an array of bytes. Each element in the array has the byte to be pushed to the corresponding register - with the highest register number the furthest away from the Arduino. The code then iterates backwards through the away, pushing each byte in succession.

Rather than doing the obvious count-from-0-to-9999 code, I decided to figure out how to read input from the PC. This is done in the readNumberFromPC() function. If it detects that something has been sent from the PC, it reads each character, with a 10ms delay between each character read to ensure that all characters are received from the PC. Without the delay, the Arduino executes so fast that it may read the first character from the input stream, try again, and the next character hasn't made it over the slow (compared to the Arduino!) link from the PC - resulting in the input being chopped into two parts. This delay doesn't cause a problem with the 595s as their outputs are latched, and so stay the way they were set until the next update - preventing any display flickering.

In the loop() function, the logic to put the correct digit-byte in the register array is hard-coded. In the next rev I'll make this register-count agnostic.

As far as the circuit is concerned, I've got one 220ohm resistor on each 7-segment common cathode going to ground, which produces a bright enough display. I've also added a 100nF decoupling capacitor on the Vcc pin of each 595 to forestall any noise problems.

The complete circuit diagram is as below (click for a larger version):

 

Here's the breadboard layout, with a close up of IC2 (click for larger versions):

  

Once I'd figured out the wiring for one of the displays, adding the other three was pretty easy. At this point I ran out of 595s so I couldn't take the experiment any further, but I do have a bunch more on the way from Jameco.

I took a short (40s) video of the board in action - check it out here on YouTube.

And all the code is below(to download as a text file click here). Drop me a comment if you find this stuff useful!

[Edit: 12/19/10 - here's a link to someone who built a clock based on my code below.]

Next up - replacing some of the shift registers with transistors to allow a bigger fan-out from the Arduino.

/*
  Driving multiple 7-seg displays with 74HC595 shift registers.
 
  Feel free to re-use.
 
   01/30/2010
*/

// This pin gets sets low when I want the 595s to listen
const int  g_pinCommLatch = 6;

// This pin is used by ShiftOut to toggle to say there's another bit to shift
const int  g_pinClock     = 7;

// This pin is used to pass the next bit
const int  g_pinData    = 4;

// Definitions of the 7-bit values for displaying digits
byte g_digits [10];

// Current number being displayed
int g_numberToDisplay = 0;

// Number of shift registers in use
const int g_registers = 4;

// Array of numbers to pass to shift registers
byte g_registerArray [g_registers];

void setup()
{
  pinMode (g_pinCommLatch, OUTPUT);
  pinMode (g_pinClock, OUTPUT);
  pinMode (g_pinData, OUTPUT);
 
  Serial.begin (56600);
 
  // Setup the digits array
  // a = 8 b = 4 c = 2 d = 64 e = 32 f = 1 g = 16
  g_digits [0] = 8 + 4 + 2 + 64 + 32 + 1;
  g_digits [1] = 4 + 2;
  g_digits [2] = 8 + 4 + 16 + 32 + 64;
  g_digits [3] = 8 + 4 + 16 + 2 + 64;
  g_digits [4] = 1 + 16 + 4 + 2;
  g_digits [5] = 8 + 1 + 16 + 2 + 64;
  g_digits [6] = 8 + 1 + 16 + 2 + 64 + 32;
  g_digits [7] = 8 + 4 + 2;
  g_digits [8] = 8 + 4 + 2 + 64 + 32 + 1 + 16;
  g_digits [9] = 8 + 4 + 2 + 1 + 16 + 64;
} // setup

// Simple function to send serial data to one or more shift registers by iterating backwards through an array.
// Although g_registers exists, they may not all be being used, hence the input parameter.
void sendSerialData (
  byte registerCount,  // How many shift registers?
  byte *pValueArray)   // Array of bytes with LSByte in array [0]
{
  // Signal to the 595s to listen for data
  digitalWrite (g_pinCommLatch, LOW);
 
  for (byte reg = registerCount; reg > 0; reg--)
  {
    byte value = pValueArray [reg - 1];
   
    for (byte bitMask = 128; bitMask > 0; bitMask >>= 1)
    {
      digitalWrite (g_pinClock, LOW);
   
      digitalWrite (g_pinData, value & bitMask ? HIGH : LOW);
       
      digitalWrite (g_pinClock, HIGH);
    }
  }
  // Signal to the 595s that I'm done sending
  digitalWrite (g_pinCommLatch, HIGH);
}  // sendSerialData

// Print a message specifying valid inputs, given the number of registers defined and then consume all current input.
void badNumber ()
{
  int dummy;
 
  Serial.print ("Please enter a number from 0 to ");
  for (int loop = 0; loop < g_registers; loop++)
  {
    Serial.print ("9");
  }
  Serial.println (" inclusive.");
 
  while (Serial.available () > 0)
  {
    dummy = Serial.read ();
   
    // Necessary to get all input in one go.
    delay (10);
  }
} //badNumber

// Read a number from the PC with no more digits than the defined number of registers.
// Returns: number to display. If an invalid number was read, the number returned is the current number being displayed
//
int readNumberFromPC ()
{
  byte incomingByte;
  int  numberRead;
  byte incomingCount;
 
  if (Serial.available () > 0)
  {
    numberRead = 0;
    incomingCount = 0;
     
    while (Serial.available () > 0)
    {
      incomingByte = Serial.read () - 48;
      incomingCount++;
     
      if (incomingByte < 0 || incomingByte > 9 || incomingCount > g_registers)
      {
        badNumber ();
        return g_numberToDisplay;
      }
     
      numberRead = 10 * numberRead + incomingByte;
     
      // Necessary to get all input in one go.
      delay (10);
    }

    Serial.print ("Now displaying: ");
    Serial.println (numberRead, DEC);
   
    return numberRead;
  }
 
  return g_numberToDisplay;
} // readNumberFromPC


void loop()
{
  g_numberToDisplay = readNumberFromPC ();
 
  if (g_numberToDisplay < 10)
  {
    g_registerArray [3] = g_digits [0];
    g_registerArray [2] = g_digits [0];
    g_registerArray [1] = g_digits [0];
    g_registerArray [0] = g_digits [g_numberToDisplay];
  }
  else if (g_numberToDisplay < 100)
  {
    g_registerArray [3] = g_digits [0];
    g_registerArray [2] = g_digits [0];
    g_registerArray [1] = g_digits [g_numberToDisplay / 10];
    g_registerArray [0] = g_digits [g_numberToDisplay % 10];
  }
  else if (g_numberToDisplay < 1000)
  {
    g_registerArray [3] = g_digits [0];
    g_registerArray [2] = g_digits [g_numberToDisplay / 100];
    g_registerArray [1] = g_digits [(g_numberToDisplay % 100) / 10];
    g_registerArray [0] = g_digits [g_numberToDisplay % 10];
  }
  else
  {
    g_registerArray [3] = g_digits [g_numberToDisplay / 1000];
    g_registerArray [2] = g_digits [(g_numberToDisplay % 1000) / 100];
    g_registerArray [1] = g_digits [(g_numberToDisplay % 100) / 10];
    g_registerArray [0] = g_digits [g_numberToDisplay % 10];
  }

  sendSerialData (g_registers, g_registerArray);
} // loop



[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Currently rated 2.2 by 110 people

  • Currently 2.2/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

E-mail | Permalink | Trackback | Post RSSRSS comment feed 5 Responses

Jan282010

Arduino: figuring out shift registers

Published by paul at 10:35 AM under Arduino | LED Projects | Shift Registers

One of the parts that makes possible the scrolling message kit I built over the weekend (see Kit building: Hansen Hobbies mini-scrolling LED sign kit) is a shift register. This is a very neat device that uses at least 2 inputs to load 8 parallel outputs. The idea is to pulse a clock input for each bit of data in the 8-bit register, loading each bit in succession until all 8 bits have been loaded. The shift registers in the kit I made are 74HC164s, which means that the outputs immediately go high or low to relfect the bits as they're loaded into the shift register and shifted along into their desired positions. Many people prefer a latched shift register, where the outputs reflect a steady-state of the register until all 8 new bits have been loaded, and then the outputs change to the new bits in the register (i.e the latched register has two registers - a true shift register and a storage register).

The simple algorithm to load a latched shift-register is:

pull the latch pin low

pull the clock pin low
pull the data pin high or low to reflect bit 1
pull the clock pin high

<repeat for bits 2 through 8>

pull the latch pin high

It's up to you whether you load the 8-bit value as MSB (most-significant-bit) first or LSB (least-significant-bit) first - you'll soon work out if you've got it the wrong way around!

I'm going to use a 74HC595 shift register that can source 35mA per output - perfect for driving the LEDs in my 10-bar LED arrays.

There are two ways to implement the logic above - using the Arduino shiftOut function or writing one yourself. I played around with both to make sure I fully understood what's going on - and I like bit-twiddling in C/C++. The Arduino site has a good language reference on shiftOut (see here) and also a tutorial on using the 74HC595 (see here). I decided to figure out how to use the chip myself so I internalized how to do it in future - but I'm not trying to be a purist and re-inventing the wheel.

The circuit is pretty simple - remember to pull the OutputEnable (active low) pin low and the MemoryClear (active low) pin high.

 

And a photo (click for larger image):

 

The code I used is below, with the two different functions to push data out to the shift register. I had a problem with the code where I originally had the counter variable in the loop() function as a byte and the LEDs counted to the end and then stopped. I put in the serial output to do some testing and connected up with Windows HyperTerminal - so much easier to do it with this than when trying to debug code I'd written in the storage engine of SQL Server :-) Of course as soon as the counter value reached 256, it overflowed and was stored as 0, so no more LEDs being lit up. If you do this, don't forget to hangup before trying to upload a sketch to the Arduino otherwise it won't be able to grab the COM port.

Here's the code:

/*
  Driving a 74HC595 shift register
 
   01/27/2010
*/

// This pin gets sets low when I want the 595 to listen
const int  pinCommLatch = 2;

// This pin is used by ShiftOut to toggle to say there's another bit to shift
const int  pinClock     = 3;

// This pin is used to pass the next bit
const int  pinData    = 4;

void setup()
{
  pinMode (pinCommLatch, OUTPUT);
  pinMode (pinClock, OUTPUT);
  pinMode (pinData, OUTPUT);
 
  //Serial.begin (56600);
} // setup

// Using the builtin shiftOut function
void sendSerialData1 (
  byte  value)
{
  // Signal to the 595 to listen for data
  digitalWrite (pinCommLatch, LOW);
 
  shiftOut (pinData, pinClock, MSBFIRST, value);
 
  // Signal to the 595 that I'm done sending
  digitalWrite (pinCommLatch, HIGH);
}  // sendSerialData1

// Using my own method with as few instructions as possible
// Gotta love C/C++ for bit-twiddling!
void sendSerialData2 (
  byte  value)
{
  // Signal to the 595 to listen for data
  digitalWrite (pinCommLatch, LOW);

  for (byte bitMask = 128; bitMask > 0; bitMask >>= 1)
  {
    digitalWrite (pinClock, LOW);
 
    digitalWrite (pinData, value & bitMask ? HIGH : LOW);
     
    digitalWrite (pinClock, HIGH);
  }
 
  // Signal to the 595 that I'm done sending
  digitalWrite (pinCommLatch, HIGH);
}  // sendSerialData2
 
void loop()
{
  for (int counter = 1; counter < 256; counter++)
  {
    sendSerialData2 (counter);

    delay (75);
  }
} // loop

I recorded a quick video of the code above driving the 595 to get the LEDs to count from 1 to 255 in binary - checkout it on YouTube here.

Next up - daisy-chaining multiple shift-registers.



[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Currently rated 3.3 by 29 people

  • Currently 3.275862/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

E-mail | Permalink | Trackback | Post RSSRSS comment feed 1 Responses

Jan262010

Arduino: figuring out transistors and associated resistors

Published by paul at 8:36 PM under Arduino | Example Code | LED Projects

My aim while building all these cool circuits is to re-learn all the electronics theory I knew when I got my electronics degree, but have forgotten in the intervening 15 years!

The kinds of circuits I'm most interested in right now are those that drive large arrays of LEDs from an Arduino. To do that, I'm going to have to create multiplexer circuits using transistors and shift registers, as the Arduino doesn't have enough IO pins to drive, say, 64 LEDs. The trouble is, I've forgotten how to do things like calculate the value of a base resistor and the algorithm for loading bits into a shift register.

First things first - refresh memory on Ohm's Law - Voltage = Current x Resistance. Now I can properly calculate the resistor required to put in series with an LED. The 10-bar red LED arrays I'm playing with have a 2.0V drop across the LED at 20mA current - so I need a resistor to take up the other 3.0V of my 5.0V supply and give me 20mA. R = V/I = 3V / 0.02A = 150ohms. This resistor is said to be limiting the current through the LED - without it the LED would burn out.

Now on to selecting a transistor that can switch the current. My electronics textbooks explain what to do, and I found various web pages that explained things in different ways, some of them contradictory! Kind of hard to find the right thing though - Googling for 'Arduino transistor LED' or 'transistor LED driver' and the like didn't turn up anything simple and useful - hence this post.

I want to switch on the current through the LED when the Arduino's output pin is high, so I'm going to use an NPN transistor in common-emitter mode. If I wanted to switch it on when the output from the Arduino is low, I'd use a PNP transistor.

I need a transistor that has:

1) a maximum collector current (IC) greater than my desired load current of 20mA

2) a minimum current gain (hFE) that allows me to comfortably source a base current IB from the Arduino pin that will give me the collector current I need. When the Arduino pin goes high, current flows into the transistor base, turning it on and allowing current to flow through the collector to the emitter - lighting up the LED. I don't want too much current flowing into the transistor base otherwise it will damage it.

I want an IC of 20mA, and the maximum output current from the Arduino pin is 40mA. The hFE should be at least IC/IB * a safety factor (e.g. 10). In this case, that works out to be (20mA/40mA)*10 = 5. This isn't really a concern here. If I was trying to drive 600mA from an IC that could only source 5mA through a transistor with a gain of 100, that would be a problem.

On hand I have some BC337 transistors with a minimum current gain of 100 @ 150mA - perfect!

Now I need to calculate the right base resistor value so the transistor will be fully on (saturated) and act as a switch rather than acting as an amplifier (where collector current is proportional to base current). The required base current  IB = IC/hFE = 20mA/100 = 0.2mA. This is way lower than I need to be careful of. If I go for a 4.7K resistor, this will give me IB = (5V-0.7V)/4.7K = ~1mA - plenty to make sure I get the load current I want. The 0.7V is the voltage drop across the base-emitter junction when the transistor is on.

Amazing how all the theory comes flooding back - now I don't feel like I'm groping in the dark picking resistor values!

Now I've figured out the circuit to use, I'm going to draw a circuit diagram. I found a freeware tool from ExpressPCB that allows you to draw circuit diagrams really simply (and if I ever want to get PCBs made, I won't need to learn another tool). I'd like to start making a habit of this so it's easier for others to understand my circuit, and for my future reference. The circuit is below, with a photo (click for larger image):

 

The Arduino code to test the circuit is very simple, using pin 5 to drive the transistor switch:

/*
  Driving a simple transistor-LED circuit
 
  01/26/2010
*/

const int driverPin = 5;

void setup()
{
    pinMode (driverPin, OUTPUT);
}

void loop()
{
    digitalWrite (driverPin, HIGH);
    delay (1000);
    digitalWrite (driverPin, LOW);
    delay (1000);
}

And there we have it. Now I have the basis for switching currents through multiple LEDs - which will be very useful for driving LED arrays.

Next up - using a shift register.



[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Currently rated 3.3 by 30 people

  • Currently 3.333333/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

E-mail | Permalink | Trackback | Post RSSRSS comment feed 7 Responses

Jan252010

Kit building: Hansen Hobbies mini-scrolling LED sign kit

Published by paul at 2:30 PM under Kit Building | LED matrix

Over the weekend I found some time to solder together a kit that I'd picked up before getting stuck into the Arduino. It's the mini-scrolling LED sign kit from Hansen Hobbies and seems to be the only non-RC kit they make. It's a really nice kit that's fun to put together and at $40 it's not too expensive.

The finished kit produces an 24x8 red-LED display, using three 8x8 LED matrices. The LEDs are driven from the PIC16F628A microcontroller through three 74AC164 shift registers and eight PN2222A NPN transistors, with the transistors switching power to the rows of the matrices and the shift registers controlling the columns. The kit comes with comprehensive instructions and explanations of the circuit operation. Nicely done overall.

Here are some photos of the build process (click the image for a larger version):

1) The kit contents (I'd already started soldering when I realized I'd forgotten to take the initial photo)

 

2) Finished with passive components. One of the resistors broke so I substituted one I had lying around - can you guess which one? :-)

  

3) Finished with everything except the LED matrices. The components are packed in tight and the solder pads are very small - making for a few tricky soldering moments.

  

4) Everything in place. The LED matrices required some jiggling to get in - quite a few tiny movements to the pins with needle-nose pliers to get them to slot into the tiny through-holes. The PCB is very well put together with the shift register ICs on the underside from everything else to save space.

  

Everything worked on the first test! The four micro-tact switches control the editing of the message (all ASCII characters are there) and the message scrolling speed (8 speeds from stopped to blur). You can also connect the board up to a PC using RS232 or directly to another microcontroller - pretty neat.

The PIC is programmed with a 'well done' message that displays until you put in your own. Below is a video of the first one I entered (click to play).

 

Next up - using transistors with the Arduino to multiplex LED 10-bar arrays - eventually working up to designing and building my own scrolling sign using the Arduino, and beyond!



[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Currently rated 3.3 by 12 people

  • Currently 3.333333/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

E-mail | Permalink | Trackback | Post RSSRSS comment feed 1 Responses

Jan202010

More Arduino stuff from SparkFun arrived

Published by paul at 1:43 PM under Arduino | Johnny-5 | CMOS camera | Arduino Mega

Oh man - more of the Arduino gear I ordered has arrived but I'm up to my ears in real work so can't play with this stuff yet. Here's a photo of what came (click for larger image):

 

In the box today:

Looking forward to playing with the camera. My dissertation at college was Rasterizing Scanned Maps - automatically picking out contour lines from digitized topology maps to feed into a flight-simulator, so we could fly around anywhere in the world. I got quite a lot of the way there, but I think it's really applicable to automatic object recognition and navigation for robotics. I've got a Johnny-5 kit from LynxMotion I'm going to hook this up to - should be fun!

Back to work...



[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Currently rated 3.0 by 10 people

  • Currently 3/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

E-mail | Permalink | Trackback | Post RSSRSS comment feed 1 Responses