Welcome to Pete Brown's 10rem.net

First time here? If you are a developer or are interested in Microsoft tools and technology, please consider subscribing to the latest posts.

You may also be interested in my blog archives, the articles section, or some of my lab projects such as the C64 emulator written in Silverlight.

(hide this)

Update to .NET Gadgeteer Larson Scanner

Pete Brown - 11 November 2011

So, I got to thinking (with the help of some friends) about the current sourcing capabilities of the pins on the Gadgeteer main board. Modern microprocessors generally aren't set up to be able to provide much current to things like LEDs. I  saw a fair bit of that with the results I was getting with the scanner.

So, what about wiring in reverse?

LEDs can be wired in two different directions. The first, which I used yesterday is to use the microcontroller as a current source. There's going to be a fair bit of variation here, and the MCU really can't source much current to begin with.

image

The other approach is to use the MCU as a current sink.

image

You can see that in this version, the LED is reversed. Rather than current flowing from the MCU, through the LEDs and to ground, it flows from the power supply through the resistors and LEDs and then to the MCU pins.

To light the digital pins then, you have to make the pins low (ground) at this point, rather than high. The program change is a simple reversal of the logic in the OnTimerTick method.

private void OnTimerTick(GT.Timer timer)
{
// turn off old LED
//_scannerOutput[_currentOutput].Write(false);
_scannerOutput[_currentOutput].Write(true);

if (_movingLowToHigh)
{
_currentOutput += 1;
if (_currentOutput > _scannerOutput.Length - 1)
{
// we were at the end, switch direction
_currentOutput = _scannerOutput.Length - 1;
_movingLowToHigh = false;
}
}
else
{
_currentOutput -= 1;
if (_currentOutput < 0)
{
// we were at the end, switch direction
_currentOutput = 0;
_movingLowToHigh = true;
}
}

// turn on new LED
//_scannerOutput[_currentOutput].Write(true);
_scannerOutput[_currentOutput].Write(false);

timer.Interval = new TimeSpan(0, 0, 0, 0, GetAdjustedSpeed());
}

Remember to also set the initial state of all pins to High in the constructor as well.

This won't really even out the LED brightness, but will somewhat. It will also put less stress on the board as it doesn't need to provide all that current to the LEDs.

image

         
posted by Pete Brown on Friday, November 11, 2011
filed under:          

2 comments for “Update to .NET Gadgeteer Larson Scanner”

  1. Graham Bloicesays:
    You'll still need to be careful about driving the LED's whether sinking or sourcing current. The normal drive current for the LPC2478 I/O is only 4mA.

    Unless the LED's are low current types, you'll need to provide a driver, either a transistor or a driver IC. This site has simple plain explanations on interfacing MCU's: http://www.w9xt.com/page_microdesign_toc.html

Comment on this Post

Remember me