... Previous page
Tuesday, 31. July 2007
Driving LEDs
rsbohn
09:40h
So you want to drive a 30mA load, but your PIC will only give you 20mA? You can use a BJT as a driver. The math is quite simple. First consider the load: 3 super bright LED's, they want to run at 30mA and have a forward voltage drop of 3 volts. You have a +12V line you can use that will provide the current. This is a good start. The 2N3904 NPN transistor has a maximum current rating of 200mA, so it should work fine. The average gain (hFE) for the '3904 is 100, so with 20mA into the base we could drive 2000mA, which would fry the transistor. Better keep the base current under 2mA (2*100=200mA, the max current). To get 30mA load current we would need just 0.3mA base current. Let's aim for 1.5mA. This is five times the minimum required current, and will help keep the transistor saturated if the supply voltage dips. So for 1.5mA on 5V from the PIC we need (5V/1.5ma)=3.333Kohms. Put that between the PIC output and the transistor base and it should work just fine. Here is the math: Ic = (V/Rl) = (12V-3V*3)/100 ohms = 30mA We want the base current to saturate the transistor (5x minimum current), so we take Ib = Ic/hFE * 5 = 30mA/100 * 5 = 1.5mA Now to get the base resistor Rb = Vpic / Ib = 5V/1.5mA = 3.33Kohms If we use a 3.3Kohm resistor it gives about 1.52mA, way under the PIC output max of 20mA, so that works. (response to uC meets BJT) ... Link Wednesday, 11. July 2007
ATtiny2313 on the WOSP
rsbohn
10:32h
Added a microchip to the Way Old-School Programmer. I flashed the program to the 2313 using my Arduino and a custom program. I send lines from the Intel SRecord (hex) file to arduino, it writes the bytes over the SPI interface to the 2313. The first program ran the two LED banks on the same data (an incremented register). I had all kinds of noise on the board, lights that wouldn't light up, lights that were always on, and so on. Even the reset switch was faulty. It was all cold-soldier joints. Once I got that sorted out it started working like a charm. Did a few revs of the software, the current one counts up on the yellow LED bank and lights all the lights from right to left on the red bank. Fun to watch... My next step is to get serial comms working with the USB port (CP2021 breakout from Sparkfun.com). Then I can work on the input stages. ... Link Thursday, 28. June 2007
Bit Twiddle Stick
rsbohn
14:25h
Wondering what to do with that accelerometer? Build a twiddle stick. It has two buttons, 8 LEDs, and a wireless link. When it is up, the LSB is on. When it is down the LSB is off. Press the 'shift' button and it shifts the LSB up one. Get all 8 LEDs set the way you want, then press the 'send' button. Or forget the send button, add a second accelerometer and twist the stick to send. This makes entering data more like conducting music. Maybe there is a second idea here: put the accelerometer on a conductor's baton and see where that takes you. (LSB is least significant bit) ... Link ... Next page
|
8145 days of detection
mod: 12/3/08, 5:42 AM days of detection... PMOG owner
BiographyRandall Bohn lives in Orem, Utah, USA. He works as a Software Quality Engineer. He is a big fan of the AVR line of microcontrollers. He has been in the computer industry since 1989. Randall is married and has three children. rsbohn can be reached via gmail.com. status
Youre not logged in ... Login
Amazon.com DVD Shop
Amazon.com DVD Shopmenu
search
related
calendar
recent updates
Arduino Starter Kit
MAKE Blog How-to Tuesday posted a challenge: Optimize the sketch code for a pressure sensor bar graph. Here is my second attempt: int gate[] = {10, 20, 50, 100, 200, 32767}; void setup() {DDRB = 0b00111110;} void loop() { int dval = 0; int rval = analogRead(2); for (int x = 0; rval... 12/3/08, 5:42 AM Measuring Supply Voltage
I'm running my latest handheld computer on solar power. It starts up when the sun rises and runs all day. I started wondering how I could measure the voltage coming in from the solar panel. I came up with a way to use a diode and a resistor and the... 7/29/08, 9:53 AM Ten Pin ISP adapter
I've already built a six pin ISP adapter, but my Olmex cards use the ten pin ISP. I put a header on a scrap of perf board, added an LED for the heartbeat, and then connected the ten pin cable. Actually it is a fifteen pin cable, off a joystick... 7/16/08, 10:00 PM Hello 5x7 Style
Wrote a new firmware for the 5x7 display. Now it scrolls out 'hello' over and over again. I'm running it on a solar panel, so it wakes up with the sun and runs all day long. When I built the LED matrix I put resistors on the five columns. I'm starting... 6/17/08, 12:48 PM Provo, Utah
With a walkable downtown and access to two Universities, Provo Utah is a great location. I live next door in Orem. Kipplinger: Provo: Pristine Tech Mecca (Video) (Text) 6/2/08, 10:07 AM Another release of AVRISP sketch
There is a new release of the AVRISP emulation sketch for Arduino: avrisp.02.zip. This one should work with Mega8 and Mega168. mega-isp 5/28/08, 4:48 PM Sorting Out Page Sizes
There is a new release of AVRISP Emulation for Arduino. This is an Arduino firmware that allows you to program other AVR microcontrollers. The new zip file (avrisp.01.zip) should compile on the current Arduino IDE, and I changed the comments that put the wrong labels on the SPI pins. Go ahead... 5/27/08, 11:31 AM Flash Problems
I'm building a project using the AVR ATMega8 microcontroller. Once I got the thing wired up to where I could write firmware to it I found that it was always failing. I made a .hex file full of 0x10 values (256 bytes worth) and tried uploading that to the chip.... 5/16/08, 2:56 PM William's Arduino Board
I'm building an Arduino-compatible board for William. I'm building it on the Evil Mad Scientist MegaXX8 business card. It will have four built-in LEDs and a USB interface. It will also have connectors so he can use it with a breadboard. Perhaps we can connect it to some of his... 5/15/08, 7:26 AM Cybord Signal Detector
Some digital radio signals use Frequency Shift Keying (FSK). This often has one frequency for a Mark and one for a Space. I plan to build a cybord or other chip that will decode an FSK signal, producing three different values: NO_SIGNAL, MARK, and SPACE. The signals would then go... 5/15/08, 7:20 AM |