RR_MelAs usual Randy is right on the money with the ULN2003! I checked into them and for $7.54 I have 10 boards on the way.
Excellent! Just the information I was looking for...
Thanks again to you both, Mel and Randy. (and Dave for starting the whole thread!)
Regards, Ed
The ULN2003 isn't specifically a 'stepper motor driver' - they use it as oen in a lot of the starter kits. It's really just a package of 7 Darlington transistors with snubber diodes included (but when driving a relay you really should still add your own snubber diodes and not rely on the chip). So it can be used to turn anything on and off, up to the rated current and voltage (I think it's 40V). 4 of the outputs together can form an H bridge to drive a DC motor with PWM, like a DCC decoder's output stage, or pretty much anything else you can think of. The actual ULN2003 library in the Arduino IDE is probably geared towards using it to drive a stepper motor, for lights or other simple on/off operations you wouldn;t even need a library, just connect say D5 output to one of the UNL2003's inputs and turn it on and off with basic digitalWrite commands.
There are other options as well, all you need is a buffer chip to allow the relatively low power Arduino output pin to drive a larger load. Even a basic transistor circuit would work - examples can be found on many of the relay boards. Much of that stuff is open source hardware so the schematics are freely available, instead of the relay coil and the snubber diode you would connect your LEDs there and that's it. All that transistor is doing is acting as a higher current switch to control teh relay coil since the Arduino can't do so directly. Whether it controls a relay coil or a string of LEDs really makes no difference. There are some technicalities that could affect how this works but experimenting is aprt of the fun and worst case with the transistor driver is you either can;t turn the LEDs off or they won't come on, it wouldnt fry anything. The ULN2003 and similar chips shouldn;t have any issues with this unless you exceed the maximum current
--Randy
Modeling the Reading Railroad in the 1950's
Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.
This was the relay module I had in mind, Mel, but as Randy points out, there are better options.
http://www.allelectronics.com/make-a-store/item/rlm-4/4-channel-relay-module/1.html
I can't imagine the micro-relays are all that noisy but they do place a mechanical link into the chain and I surely don't need the 10 amps!
I'll stick with all solid-state.
[edit::] It didn't take long to find a neat 2A solid state relay.
http://www.ebay.com/itm/4-Channel-5V-Solid-State-Relay-2A-For-Arduino-UNO-MEGA-2560-R3-AVR-Raspberry-PI-/171923205134?hash=item28076bec0e:g:RM0AAOSwPhdVKSCd
Thanks Mel, Thanks Randy...
Ed
ULN2003 drivers, 5 for $4 or less oon ebay - each of the 7 outputs on the ULN2003 can drive up to 500ma, about 2.5 amps total for the chip (so obvious all 7 can't run at 500ma). At 300ma per output, that's at least 30 LEDs at 10ma each. That should be sufficient for darn near anyone's town - 210 LEDs, plus you can use more than one per Arduino since there are more than 7 output pins. And there is a library for accessing the ULN2003 chip already in the Arduino IDE. I'm using one to drive the relays for my Test Track Switcher - though it turns out the relays I bought are such low current I can actually drive them direct from the Arduino pins.
gmpullman As inexpensive as these processors are, it is worthwhile to have a dedicated one for each structure. Thanks again, Ed
As inexpensive as these processors are, it is worthwhile to have a dedicated one for each structure.
Thanks again, Ed
I'm glad I caught this thread the second time around, you guys have me wanting to pick this up and start playing.
Thanks!
"The true sign of intelligence is not knowledge but imagination."-Albert Einstein
http://gearedsteam.blogspot.com/
Thanks for that update, Mel!
Like your setup, I planned on having 12 outputs. I wasn't sure what the current was rated on the output that's why I was thinking of the relay board but it may not be necessary.
I have been browsing the tutorials here:
https://www.arduino.cc/en/Guide/HomePage
High ED, good news!
hon30critterI'm thinking of something like an apartment building or an office building where I want lights in various rooms to turn off and on on their own in a random pattern.
Dave, Mel, Randy—
It has been four months since this thread ran its course and I wondered what circuitry and program you settled on for your random lighting generator.
I'm at a stage where I'll be installing the lighting in several multi-story downtown buildings and I'm interested in jumping into the Arduino pool.
I recieved an All Electronics catalog yesterday showing relay modules that I believe would be needed for my use since I'll probably be driving several dozen LEDs on each output.
I'm just curious about which board you used and if you would do anything different. Did you modify an existing Arduino "sketch" or did you write your own for the random effect?
Thanks, Ed
For the small ones, I just came across this. I don;t have one, so I am only going by the description, but it syas it has the Arduino bootloader in it so it programs from the Arduino IDE just like any other one. It's super tiny, there are 4 usable pins (6 total but 2 are for USB)
http://www.ebay.com/itm/2X-PCS-Digispark-Kickstarter-Attiny85-USB-Development-Board-for-arduino-/191722373418
I did just order other items from this seller so we shall see what sort of quality they offer. But for a small structure or whatever, this teeny little boards might be useful.
Edit: Same seller has them in 5 packs at $13.75 - $2.75 each! Insane.
I'm finding all sorts of neat stuff to mess around with. I need to get working on my workbench design - I have room and an idea for an L shaped table made from a couple of solid core doors, one leg will be for my modeling stuff, the other for electronics, with a computer in the middle - I have some electronic test equipment that can be controlled/monitored from the computer plus the DCC programmers like PR3 and Lokprogrammer.
It's fun, and addictive, isn't it?
If you need to control more LEDs then there are ports, your starter kit probably came with a 74HC695 shift register - there are lessons in the learning material on using them. That lets 3 lines control 8 outputs. There are other more complex chips that can do even better - the code gets more complex as well, but you can control 64 or more individual outputs with just 3 of the Arduino's outputs.
rrinker THat's why I suggested Arduino, boards can be had for not much more the PIC board, and no programmer needed, they have USB on them. Arduino was designed for non-engineers to work with. There are NMRA DCC, Loconet, and CMRI libraries already for Arduino. That's the key to a 'cheap' interface device for any bus, like LCC - someone, or you, needs to develop a library to access the protocol - not exactly an easy job but if someone does so and makes it freely available you can build on that. --Randy
THat's why I suggested Arduino, boards can be had for not much more the PIC board, and no programmer needed, they have USB on them. Arduino was designed for non-engineers to work with. There are NMRA DCC, Loconet, and CMRI libraries already for Arduino.
That's the key to a 'cheap' interface device for any bus, like LCC - someone, or you, needs to develop a library to access the protocol - not exactly an easy job but if someone does so and makes it freely available you can build on that.
No problem Mel. Appreciate your help.
Dave
I'm just a dude with a bad back having a lot of fun with model trains, and finally building a layout!
hon30critter Mel: Thanks for the leads. Unfortunately that particular supplier doesn't ship to Canada but as I told Steve, the Canadian Amazon site has tons of listings for items available in Canada. Dave
Mel:
Thanks for the leads. Unfortunately that particular supplier doesn't ship to Canada but as I told Steve, the Canadian Amazon site has tons of listings for items available in Canada.
Randy:
Thanks for the explanation and for the offer of help. At the rate that I am getting information from you recently I'll have to put up a plaque with your name on it in the layout room.
I looked up the article related to the video that Steve referenced and it includes the 'sketch' needed to run multiple LEDs although the example only has one LED per output.
Here is the article for those who might be interested. If the link doesn't take you directly to the page, it starts on page 99:
http://mrhpub.com/2014-11-nov/land/#99
It would be amazing to have several dozen LEDs going on and off randomly with only one or two small inexpensive micro processors running the whole show. It looks entirely doable but I can just imagine the maze of wires under the layout!
Steve:
Thanks for the MicroCenter lead. I'm in Canada so that particular source is going to be expensive with the exchange rate and shipping.
I did a brief search on the Canadian Amazon site and the clones are actually available for only slightly higher amounts in Canadian $ and lots of the suppliers offer free shipping.
If you have a MicroCenter store near you, they have Uno clones on sale for $6, and Mega clones for $10.
http://www.microcenter.com/product/431997/Uno_R3_MainBoard
http://www.microcenter.com/product/431995/Arduino_Mega_2560
They only have 25 stores nationwide. Here are the locations...
(scroll down)
http://www.microcenter.com/site/stores/default.aspx
Steve S
The most common Arduino, the Uno, has 20 outputs that can be used to switch LEDs on and off (the analog lines can be used for digital). They can only drive one or two LEDs directly, but you can find simple circuit examples that drive a transistor which can then drive a dozen LEDs per line or so, so you can run a whole town on a single Arduino and have multiple lights on multiple circuits in each building.
The most basic beginner examples show you how to turn an LED on and off and make it blink. They will typicall just use one LED, often on pin 13 (because the Arduino has traditionally come with an LED already on the board, connected to pin 13, so you don;t even have to add external components). The key thing to take away from those examples to expand it to the concept of driving multiple LED circuits is the part of the code where you spcify which pin the LED is connected to. You can reference ANY pin number, so long as you hook the LED to it. Or many at the same time. In just a few minutes I had a Knight Rider thing going with 4 LEDs, and a simple change to the code made it just sweep in one direction instead of back and forth.
It's really hard to actually damage anything by having your program incorrect, but when connecting things to the Arduino you do have to remember things like putting current limiting resistors on LEDs. Just like if you were powering them with a toggle switch instead of a miniature computer - concept as far as the LED circuit goes is exactly the same, the difference is with the Arduino, your program turns the LED on and off instead of your finger on the toggle. So the same wiring rules apply.
ANd if you start playing around and need help with your sketch (see - Arduino was made for art students originally - it's not a 'program', it's a 'sketch'), I can help you out. I don;t need to have your exact circuit - you might have a transistor connected to the Arduino driving 10 LEDs, but the sketch is exactly the same even if all I do is hook 1 LED to mine. That is, of course, how you should start - one LED and resistor per output to test the program, then worry about the transistor driver later - the code would remain unchanged.
There are other Arduino models better suited to building into a permanent circuit that are less expensive than the Uno - I also have a Nano, which basically looks like an overgrown IC chip but it runs the same code as the Uno and has the same outputs and I think the one I have cost $3.99. And if the 20 outputs aren;t enough, the Arduino Mega has over 60.
Hi Ed:
I'm familiar with All Electronics but thanks for the links.
Just ordered the book 'Arduinos for Dummys'. Sounds like its aimed right at my level!
Wow - lots of possibilities!
For those who suggested the mechanical devices - thanks very much. I think I'm leaning towards the electronic options but I will keep the others in mind.
Neal:
The Random Lighting Control is a great product but I would need a bunch of them to do what I want because they will only drive 6 LEDs each. The low Canadian dollar is becoming a serious issue, and it is predicted to go even lower by the summer so buying 12 - 15 of the RLC units would get expensive.
Steve and Randy:
Arduino obviously addresses the issue about the number of LEDs that can be driven by a single unit, plus there is apparently greater flexibility in the timing settings.
Where did you order your Arduino kit from?
Thanks everyone!
Take some pictures as you go, and keep good notes of how you program the Arduino unit.
This would make a great how-to article for a certain model railroading magazine.
It takes an iron man to play with a toy iron horse.
Dave,
I don't have any answers to your question - but I can see how cool it would be to have a building have randon lights turning on and off.
Let us know if the Arduino kit works out.
In the old days we would have has a batch of switches to control the lighting - nowadays you can let a circuit board do it all for you. Is that progress?
Okay I'm a luddite that works in the computer industry - go figure.
Chris.
Loco Guy - is a state of mind - not an affinity to locomotives.
Sit back and enjoy your track...
rrinker Arduino was designed for non-engineers to work with. --Randy
Arduino was designed for non-engineers to work with.