Adruino and Shields

Ask and answer questions, share tips and resources for installing lighting and other electronics in your models.

Moderators: Sparky, Moderators

Post Reply
summ
Posts: 43
Joined: Thu Dec 06, 2012 6:51 am

Adruino and Shields

Post by summ »

Hi everyone,

I had my affection for Star Trek revived just recently by watching some old episodes on Syfy. Then I found this Polar Lights 1/350 Refit kit and well ... I had to go for it. Now I hope that the kit will arrive any time soon ;)
I have sworn to myself that bulding this kit will not only be a lesson in craftsmanship, but also in patience! So I am still on a research mission while waiting for the kit ... and that is why I´m here now;)
Of course I want to light it and I have overlooked many many sites and vids and by my ever existing impatience I ordered the DIY light kit from trekmodeler. By now he has not responded, which is normal as I´ve read. I ordered this kit mainly because of my lack of expierence with LED and circuits, although I know how to handle a soldering iron.
What I somehow don´t like about the light kit is simply the fact that once it´s in there there is no easy way of modifying it later on (e.g. adjust brightness). As some users on this forum already expressed, I also wish to have the lights go into different stages of operation. Especially a "docking"-mode came to my mind, where I will even try to get some little lights next to the travel pods docking bays as seen in the first ST movie. By now I don´t know if it is even possible to have those tiny little holes where I want them and even get some fiber optics through. If ... then I´d like to have them lit only when "docked", which would go together with interior light and hangar bay and everything else off. Any other mode (Impuls, Warp) would turn off the hangar bay and pod docks.

And all with a push of a button! ;)

So I ran accross Arduino once again (did some research on that a while ago for another project) and figured that the basic Arduino board, as statet somewhere else on this forum) won´t be able to drive all the LEDs that will be in the good old enterprise. Has anyone ever heard of the Lightuino Shield or any similar shield for the Arduino that could drive all the LEDS in the model? Will that fit into it?
Or did anyone came up with another solution that is "somehow" reproduceable for a electronics novice?

Cheers

Christian
bradb667
Posts: 29
Joined: Sun Jun 29, 2003 1:44 am
Location: Salem, Oregon

Post by bradb667 »

Christian-

The problem with the Arduino by itself is that it's limited to supplying about 200mA on all the pins at any one time. Assume that's 10 LEDs each drawing 20mA.

There are two typical solutions: One is to use charlieplexing (something like http://uzimonkey.blogspot.com/2009/01/c ... duino.html). I'm not sure if there are any pre-made shields you can buy that do this, but I imagine there are.

The other typical solution is to use a LED driver such as the TLC5940 (https://www.sparkfun.com/products/10615 for a shield version). This is a much higher-end solution than charlieplexing as it gives you a large number of pins that can do PWM (pulse width modulation, used for effects like strobe lights).

I'm sure there are other methods but those are a few off the top of my head.

Regards,

Brad.

PS if you're interested in low-cost Arduino alternatives for lighting, drop me a PM. I've got a couple of boards I'm working on that might interest you.
bradb667
Posts: 29
Joined: Sun Jun 29, 2003 1:44 am
Location: Salem, Oregon

Re: Adruino and Shields

Post by bradb667 »

summ wrote:Will that fit into it?
I forgot to add... you won't be fitting an Arduino with a shield mounted into very many models. That's a pretty large platform.

Standard size of something like an Arduino Uno is 2"x3"x.5". Add a shield and you're talking 2"x3"x1.5" or so.

There are alternatives that are smaller but not really beginner friendly in general (and by beginner friendly I mean shield compatible).

One of my favorites is the Teensy (http://www.pjrc.com/teensy/) but expanding it isn't very beginner friendly.

Regards,

Brad.
summ
Posts: 43
Joined: Thu Dec 06, 2012 6:51 am

Post by summ »

As I said ... patience is part of the project;)

I guess a board could go into the stand. Yesterday I read nearly all about resistors, transistors and how to drive externaly powered boards with the Ardiuno.
I'd love to keep the light flexible and, maybe, remote controlled.

I'll come back to you after a full day of work ...
User avatar
tetsujin
Posts: 2350
Joined: Mon Feb 28, 2005 6:08 pm
Contact:

Post by tetsujin »

bradb667 wrote:Christian-

The problem with the Arduino by itself is that it's limited to supplying about 200mA on all the pins at any one time. Assume that's 10 LEDs each drawing 20mA.

There are two typical solutions: One is to use charlieplexing (something like http://uzimonkey.blogspot.com/2009/01/c ... duino.html). I'm not sure if there are any pre-made shields you can buy that do this, but I imagine there are.
Charlieplexing doesn't get you around the current limitation. All Charlieplexing does is allow you to control a larger number of LEDs with the same number of I/O lines.

For instance, suppose you have 8 I/O lines. How many LEDs can you independently with that?

A naive answer would be 8 - one independently-controlled LED per I/O line.
A somewhat more sophisticated answer might be to arrange the LEDs into a 4x4 matrix, scan through the matrix to make all the LEDs appear constantly illuminated, and take advantage of the one-way nature of diodes to prevent any LEDs from turning on when you don't want them to...
But Charlieplexing goes a step further. With it you can take those 8 I/O lines and create a 7x8 matrix of independent LEDs. For any two I/O pins (x,y), there are two LEDs, LED(x,y) and LED(y,x) with opposite orientation
To turn a LED on, you put its anode pin high and its cathode pin low. To turn a LED off when its anode pin is high, you set its cathode pin as an input so the I/O pin won't pass current.

It's a neat trick but it's got all kinds of problems. Because the matrix is wired so densely, it can be challenging to build a Charlieplex matrix. Because the cathode pin of each LED connects to the anode pin of 7 other LEDs, a wiring fault or programming error can make the display light up in weird ways that are hard to diagnose. You can't easily mix and match LED types in a Charlieplex, either: If LED(A,B) takes 3V, and LED(A,C) and LED(C,B) can run on 1.5V, then lighting LED(A,B) (and not LED(A,C)) will also light those other two.

You can't share resistors over whole columns of the matrix like you can with a normal rectangular LED matrix, and with the process of scanning through the matrix it can be hard to get adequate brightness out of it. Mostly it's just not worth it.
The other typical solution is to use a LED driver such as the TLC5940 (https://www.sparkfun.com/products/10615 for a shield version). This is a much higher-end solution than charlieplexing as it gives you a large number of pins that can do PWM (pulse width modulation, used for effects like strobe lights).
PWM wouldn't really be used for strobes. Strobes are just an on/off thing based on (coarse) timing. PWM is used to blink LEDs on and off... but normally it does this very fast, to provide a dimming effect.

This is probably the best way to go. The LED driver incorporates a constant current sink driver (which stabilizes the performance of the LEDs much better than a resistor, and allows you to use a high DC supply voltage (unregulated, even) to power the LEDs in series...

So a good way to approach this, if you are wiring up a whole lot of lights in a ship model and want them to be independently controllable, would be a setup like this:
1: Power the whole project on some high voltage, maybe 18V. Unregulated should be fine... Also set up a voltage regulator to supply a second, lower voltage (3.3V or 5V) to power the logic circuits, like the microcontroller and the LED driver boards. (The Arduino has an onboard voltage regulator that can accept that 18V supply and provide a robust 5V source...)
2: To anywhere you're going to have lights, run wires for the high and low voltage sources, and ground.
3: Install multiple LED controller circuits (to keep wiring of LEDs relatively simple and "local" to the controller driving them) and connect all of these to the Arduino's serial bus.
4: Mount the Arduino in the base if you like, so it doesn't take space in the model and can be local to pushbutton controls mounted in the base, if any...

With a setup like this, you'd be running five wires from the base into the model - high voltage, low (regulated) voltage, ground, serial clock, and serial data. For the multiple LED drivers, you could use something like this - which is basically the same as the PWM shield but smaller.

One thing that kind of bugs me about this particular controller, however, is the way multiple controllers are linked. Basically, you have to daisy-chain them. So if you had a controller in each nacelle, you'd need to run serial data up one nacelle, then back down again to daisy chain to the next controller... Normally with these kinds of serial connections, there's a "slave select" pin you can use to select which device you're talking to. It's another wire to each device either way, but with "slave select" you're at least not having to linearize something that's not really linear...
---GEC (三面図流の初段)
There are no rats.
The skulls eat them.
bradb667
Posts: 29
Joined: Sun Jun 29, 2003 1:44 am
Location: Salem, Oregon

Post by bradb667 »

tetsujin wrote:Charlieplexing doesn't get you around the current limitation. All Charlieplexing does is allow you to control a larger number of LEDs with the same number of I/O lines.
You're correct of course. I should have added that, thanks for the clarification.

If you really want to control a larger number of LEDs at one time (and not individually) you'll want to connect a transistor or MOSFET to the I/O line, which allows you to get past the power limitations (and to switch a "bank" of LEDs off and on).

In general you don't want to drive all the LEDs from your microcontroller, just the same power supply (as tetsujin suggests).
PWM wouldn't really be used for strobes. Strobes are just an on/off thing based on (coarse) timing. PWM is used to blink LEDs on and off... but normally it does this very fast, to provide a dimming effect.
I haven't actually done a strobe with PWM but I disagree here. I'd think you _might_ be able to better simulate the strobe effect by quickly dropping off vs an immediate off. But this is something I still have yet to play with so you may be correct.
[regarding the TLC5940 LED driver...]

This is probably the best way to go. The LED driver incorporates a constant current sink driver (which stabilizes the performance of the LEDs much better than a resistor, and allows you to use a high DC supply voltage (unregulated, even) to power the LEDs in series...
The TLC5940 is my personal favorite. I've even done a board or two that used a few of them (http://www.youtube.com/watch?v=Wky5jPbJ ... e=g-crec-u).
So a good way to approach this, if you are wiring up a whole lot of lights in a ship model and want them to be independently controllable, would be a setup like this:
1: Power the whole project on some high voltage, maybe 18V.
Ugh. You really need that high a voltage? I'd agree with your approach overall but I'd rather stuck with 6v for the entire build if at all possible.

I guess it depends on how many LEDs you really need lit constantly.
One thing that kind of bugs me about this particular controller, however, is the way multiple controllers are linked. Basically, you have to daisy-chain them.
It isn't too bad if you can keep the TLC5940's in close proximity, but I'd agree... it's a poor solution for something like the TOS Enterprise.

Finally thanks for the great advice but I did want to add... get an Arduino but don't use it to light any kits. Too expensive. Use it for testing but use a bit of that patience and learn how to build your own Arduino clone for $5 or so. It will be much smaller and cheaper plus you can learn quite a bit in the process.

Regards,

Brad.
User avatar
Mr. Engineer
Posts: 440
Joined: Mon Dec 10, 2007 6:01 am
Location: Malaysia
Contact:

Post by Mr. Engineer »

Arduinos and especially any microcontrollers are a good way to achieve you goal. Personally, for me, I am using PICs. There are others such as from Atmel and so on.

Call me stubborn but I have used PICs on so many projects, and also because of the shops that sells them, I am not willing to switch directions mid-way. Each chip offers pros and cons plus pricing. Plus, I have invested quite a bit on the software since I hate programming machine codes.

For the the 1/350 Enterprise, I have designed a lighting module based on an 8-pin PIC in 2009 and to be honest, since it was my 'first' design on a PCB, I only used two outputs which uses transistors to control the RED/GREEN/WHITE and the strobe LEDs. Because it has enough memory, and by just playing with the jumpers, I am able to use the board for four ships:

1. NCC-1701A Motion Picture
2. NCC-1701A Star Trek VI
3. NX-01
4. 2009 JJPrise

But I might remove the JJPrise option and reprogram it with the TOS 1701 timing instead and sell them. That is, once I have the time to solder all the LEDs and re-write the Instruction manual. And its severely limited edition with friends already waiting in-line since 2009 :?

https://fbcdn-sphotos-c-a.akamaihd.net/ ... 6110_n.jpg
What can I take apart today?

https://www.facebook.com/PisceanWorks
bradb667
Posts: 29
Joined: Sun Jun 29, 2003 1:44 am
Location: Salem, Oregon

Post by bradb667 »

Mr. Engineer wrote:Arduinos and especially any microcontrollers are a good way to achieve you goal. Personally, for me, I am using PICs. There are others such as from Atmel and so on.
PICs work just as fine, who cares what you use?

I learned Atmels (and the Arduino) first because of the low price-point and the fact that the tools are cross-platform and open source.
Most of the people I know who use PICs do so because they've used them before - and that's fair enough. You use what you know because either should work just fine.

Heck you can call me stubborn... I've been spending most of my time working on ham radio projects (such as https://dl.dropbox.com/u/8240668/images/ProjectSB.JPG), which is almost all PIC-based. Sorry to post that board here, I'm just over-proud of it right now :-)

Nice module you've got there BTW.

Me, I got excited by this post because... well, somebody mentioned the Arduino :-)

I ran a couple of sets of PCBs of a design I did for kicks. This is a small (1"x1.25") board that has an ATmega328 and a 150mA 3.3v voltage regulator. The idea was it could drive 8x LEDs for various effects (up to 2 LEDs per I/O pin), be re-programmable by the end user, and unless more than 2 LEDs were connected to a pin it's can't easily be killed.

The board actually exposes 13 of the ATmega328's 14 digital I/O pins but some are harder to find than others :-)

Take a look at https://dl.dropbox.com/u/8240668/images/FlashR.JPG

My thought was this could drive the navigation lights on a TOS Enterprise as well as provide random on/off effects for 5-6 windows on each side (just to add something different and apparently be per the protoype).

For the Refit, one board should be able to drive the navigation lights, one board the deflector/photon torpodoes (w/ push-buttons), and one board the hanger deck landing lights.

Also it could do a cool cylon eye effect on 10 LEDs too (using PWM) as well as have two left over for a gun (engine?) effect (and one last pin for a pushbutton?).

Not bad for $8 worth of parts each (including the PCB), eh?

Anyways I've got a couple of prototypes I thought maybe if anybody was interested I could let go for cheap. Drop me a PM if you want one, otherwise I'll toss them in the "box of shame" (It's high, deep, AND cold).

Regards,

Brad
KF7FER
summ
Posts: 43
Joined: Thu Dec 06, 2012 6:51 am

Post by summ »

Hey guys ...

thanks for all the insight. But it looks like I have plenty of time left until I can even start this project. I bought the model kit on Amazon UK for nearly double the price of the original, because it appeared to be the only kit to get my hands on. But after it did not arrive on time I contacted the seller and they said that the parcel had been returned to them by Royal Mail due too its weight. As far as I can tell the model is sold out all over europe. Remaining kits are on ebay for a price that almost tripples the original. I´am a bit crazy, but not that much ;)

So no model kit ... nothing to do.
Post Reply