Trains.com

Subscriber & Member Login

Login, or register today to interact in our online community, comment on articles, receive our newsletter, manage your account online and more!

Random switching for structure lighting

8512 views
45 replies
1 rating 2 rating 3 rating 4 rating 5 rating
  • Member since
    June 2016
  • 81 posts
Posted by Ron Hume on Friday, October 21, 2016 7:02 AM

Thanks Mel for the sketch and everyone for your help.

I assume  the circuit goes; 12 serial pins to 12 resistors to 12 LEDs to a common block of 5v powered from the Arduino?

As to LEDs, I will be looking for dim mellow yellow in keeping with the 1860s-80s.

Ron from down under.

  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Friday, October 21, 2016 7:27 AM

 If you are using Mel's sketch, then yes, this is how you would wire them. The pin being LOW turns on the LED. The cathode of the LED (- side) goes toward the Arduino pin, the anode (+) side goes to the 5V common.

 Doesn;t really matter which side of the LED the resistor is on, as long as there is one. Whichever makes the wiring more convenient.

+5V-------<resistor>----->|------ Arduino pin

is exactly the same as

+5V------->|------<resistor>---- Arduino pin.

                          --Randy

 

 


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

  • Member since
    June 2016
  • 81 posts
Posted by Ron Hume on Friday, October 21, 2016 7:32 AM

I may use a model of these rocks on my layout, but would need to change the trees to US western types.

Ron from down under.

Tags: Alice Rocks!
  • Member since
    June 2016
  • 81 posts
Posted by Ron Hume on Wednesday, October 26, 2016 12:08 AM

Looking for plugs to connect to 12 digital pins and the 5v pin on the Arduino Uno. What do you recommend?

Ron from down under.

  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Wednesday, October 26, 2016 6:32 AM

 I guess it depends on how those LEDs are split up - if all 12 go into one structure then a large connector might be ok, but if they are split up, I would use seperate connectors per building. As many as 12x 2 pin connectors, where one pin goes to the Arduino pin and the other to the +5. RC servo connectors are 3 pin, that would give you 2 pins plus the 5V. You could use telephone jacks and plugs, there are PC mount versions of the jacks, so you could put a row of jacks on the Arduino board and put jacks in the structures and then wire them all up with telephone cables. With a standard 4 position jack you could have 3 lighting circuits plus the +5, or hook the +5 to the two outer pins and 2 light circuits to the two middle pins - that way if you have a backwards cable it just means the LED connected to Arduino pin 2 will come on when you expected the LED connected to pin 3.

 You'll want to mount the Arduino to some sort of perf board so you have room for all your connectors, with a common line from +5 to the common pin of each connector, and then the individual lines to the Arduino outputs. You MIGHT fit 6x 4 wire phone jacks on what's called a Proto Shield - they have connections to each Arduino pin plus a +5 and GND bus, the rest is holes where you can build your circuit.

                        --Randy

 


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Wednesday, October 26, 2016 10:07 AM

Ron
 
You can get a blank UNO expansion perf board with connectors off eBay.
 
 
 
Good Luck!
 
 
Mel
 
Modeling the early to mid 1950s SP in HO scale since 1951
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
  • Member since
    June 2016
  • 81 posts
Posted by Ron Hume on Thursday, October 27, 2016 9:46 AM

I'm blinded with science Randy!

I was thinking of two x 6 male connector for the digital pin holes on the Arduino with 12 separate leads from them to 12 structure LEDs via 12 resistors, and from the Leds back to a common 12 block of 5v. But I don't know the nomenclature for the connectors. By the way, I found a 7.5v x 100ma Dc power supply in my box of tricks today, so could probably use that for the lighting.

Ron from way down under.

 

  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Thursday, October 27, 2016 2:36 PM

 There are so many possible connectors, you can do pretty much whatever you want. I o like the idea of putting connectors at each end, so you can lift off a structure without disconnecting a bunch of wires and so forth. If they are all close together, then I guess a single 5V common run between them all would work fine, but my thought was to make each structure independent of any other, unplug one without affecting anything else, replace it, or just take it off the layout to clean, or to clean or work on part of the layout without damaging the structure, that sort of thing. It may seem counterproductive, but if each cable from the Arduino to the structure includes the power and the signal line, it actually makes it easier. I'll see if I can draw something up, Fritzing has most of the components we're talking about and makes nice pictorial diagrams as opposed to plain schematics.

 I just ordered a 10 pack of the proto shields, mostly because a pack of 1 was not valid for Prime shippign on Amazon but a 10 pack was. I'll eventually use them. Right now I just need 1 to build up a permanent programming adapter for the ATTiny85's. Right now I just have it cobbled up on a solderless breadboard but one bump and a wire will come out, or the capacitor will get popped off, so I want to build a soldered together version.

                   --Randy

 


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

  • Member since
    February 2007
  • From: Christiana, TN
  • 2,134 posts
Posted by CSX Robert on Thursday, October 27, 2016 3:09 PM

rrinker
Right now I just have it cobbled up on a solderless breadboard but one bump and a wire will come out, or the capacitor will get popped off, so I want to build a soldered together version.

Any time I have something on a solderless breadboard that I want to make more permanent, I've started using these:

https://www.adafruit.com/products/591 (also available from Digi-Key and Mouser)

These reproduce the breadboard layout so you can easily move the circuit over and they have plated through-holes with pads on both sides.

  • Member since
    February 2007
  • From: Christiana, TN
  • 2,134 posts
Posted by CSX Robert on Thursday, October 27, 2016 3:22 PM

This looks interesting:

https://www.adafruit.com/products/256

It uses standard cat 5 cable to go between the connectors on the patch panel shield and the connectors on the remote boards.

  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Thursday, October 27, 2016 4:41 PM

 That's sort of what I was thinking, although 8 leads to each structure is probably more than he needs - I was thinking maybe RJ11 jacks and cables for 4 wires to each structure. The other alternative would be 2 and/or 3 pin connectors although those may be too small - I don't mean the ones use inside locos for lights so you can take the shells off, or for between steam locos and tenders, those are definitely too small to work with easily, I'm talking things like the 3 pin connectors used for RC servos. The cables are readily available, and the male end is just 3 of those same pins that are used on those proto shields to make it plug into the socket on the Arduino. You buy them in strips of 40 or more and just break off however many you need. Servo cables of course are 3 conductor but the same style and spacing of connectors are available in everything from a single wire to 6 or more. If you don't want to go through the trouble of PC mounting the male end, you can take a servo extension cable, which has a male connector on one end and a female on the other, cut it in half, and solder the wires of one half to the Arduino shield and solder the wieres of the other half to the LEDs in the building. Another extension cable will then connect the two ends, allowing you to unplug either the Arduino or the building.

 My ordering of 10 when I need only 1? That's the trick to having a supply of components - if you need 1 of something, order 10, use 1, have 9 left for the next project(s). I have surprisingly few parts saved up over the years so recently I've bought resistor assorments and capacitor assortments, and when I bought the ATTinys it was too cheapo to pass up so I bought a bag of 50 8 pin sockets. Based on each ATTiny controlling 2 turnouts, I'll probably need MORE than 50 to build all the circuits I will need, but 50 is a good start. And of course the one thing I just throught of that I should have added to my last order, those header pins are also available in a female version, as an alternative to IC sockets, or for non-standard size things, or to make disconnects when combined with the male ones. The Arduino Nano is a non-standard size dual inline device, so to socket them I need those female header pins to make my own socket. Those I do not have.

                       --Randy


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

  • Member since
    June 2016
  • 81 posts
Posted by Ron Hume on Saturday, October 29, 2016 8:24 AM

I purchased an Anduino Proto/Screw shield on line and will run 12 leads to the structures LEDs via resistors, and RCA plugs/sockets in the structures for easy removal as you suggested Randy. Then return to the 12 block 5 volt common.

I also ordered a number of Barley Twist gas street lamps and will feed them via a toggle switch direct to power. (Random lit street lights would give the town a bad name!) So with the help of all you good men, I think I've sorted the lighting problems out. Thanks guys. I notice we sure had a lot of hits on this subject.

Ron from down under.

  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Saturday, October 29, 2016 10:31 AM

Randy
 
It’s great to have a good parts supply but there is a slight down side to a good inventory, I now have four 39 drawer and two 60 drawer small parts cabinets stuffed to overflow above my workbench.  I also have a 6’ wide closet with five 18” deep shelves full of larger cardboard parts bins also overflowing . . . . and that is just in my hobby room, doesn’t count the garage storage shelving.
 
When you loose your local sources for hobby (model Railroad) and electronic parts there is no alternative, it is a necessity to stock your own goodies.
 
The Bakersfield metro population is over 600K and a hundred miles from the LA Basin, there isn’t even one electronics store here now.  Radio Shack closed all but two stores here and as far as I'm concerned they can close them too, they're just a skosh better than worthless at a very high price.  We have several RC type LHS here but only one has a very small railroad inventory.  He is great at three to four day order turnaround and that's a big help.
 
I went with the Arduino male and female header sockets for my UNOs, I also buy them in bulk now.  Life is much easier by using multiple conductor ribbon cable with my Arduino UNOs.  I stock 10, 16 & 20 conductor ribbon cable too.  A single run to a structure sure beats individual or even bundled wiring.   
 
It’s time for me to order another 60 drawer cabinet.  Soon I’ll be out of space for my trains.   
 
 
 
Mel
 
Modeling the early to mid 1950s SP in HO scale since 1951
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Saturday, October 29, 2016 11:37 AM

 I hadn't been getting any parts at Radio Shack for years, way too expensive, unless it was an absolute need to have right then and there. And now there are none. The last independent electronics shop disappeared over 20 years ago, so it's been mail order for me for a long time. Since the shipping on a small order is so much, I always ordered multiples, like the last time I ordered parts to build a LocoIO, I ordered enough parts for 4 of them even though I only had 1 PC board - because of some bulky components, going to 5 of each jumped the shipping costs. Likewise with model stuff, I never buy a single strip or sheet of styrene, if I need a given size, I will always buy a full pack of it. If I organized my stuff better I'd need a lot of storage cubbies and drawers, like the bank of mailing tubes to keep styrene and stripwood, and way more of those little drawers I have for electronic components. I don't have the space my friend, also an EE, but a practicing one, has - he has one full wall of his shop space in his basement lined with storage cabinets that reach from the floor to over 6 feet tall. Some of these things that I buy in qunatity, like the 100 packs of IC sockets, I should probably put like a dozen in a drawer and the rest keep in the bags and put in a plastic tote stored elsewhere - until I forget about them and order another 100 after I use the dozen. One thing at least is that once I actually get started on my layout, I will have much increased storage space since my plan is to use as few legs as possible, leaving the under layout space clear to handle 2 or 3 high stacked plastic totes for organized storage - labels on all of them. If I get really ambitious about it I might even make a map of the room and mark the general category of items under various parts of the layout - not holding my breath on that one.

 The application of Arduinos to model railroads is really taking off - a few articles and tons of web information from Geoff Bunza over at MRH, several articles now in MR, including the most recent issue (December), and plenty of posts here. I'm kind of curious why Detlef hard wired the BOD-8's to his Arduino instead of sticking a compatible 10 pin connector on his shield and just using a piece of 10 conductor ribbon cable for the connection - most all of the RR-CirKit accessory boards are equipped with the common 10 pin connectors which is a perfect size since the Tower Control was grouped in 8 bits of I/O per port, so you get _ and - plus 8 bits in a nifty 10 pin connection.

                     --Randy

 


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Saturday, October 29, 2016 12:21 PM

Having proper storage and labeling is very critical to prevent double ordering as well as just being able to find what you’re looking for.  I spend hour’s just labeling and relabeling parts drawers about twice a year.  It doesn’t take long for it to go bonkers.   
 
The Arduino alone has taken up over 30 drawers and it’s still expanding.  All the new electronic goodies and parts on eBay make it hard for me to pass up.
 
Another good niche is fiber optics, I recently bought some 2mm fiber cable to go with my .5 & 1mm fiber, that really gets lots of light in tight places.
 
I want to thank you again Randy for convincing me to go Arduino, my model railroad would never be as slick as it is without the Arduino goodies.  Using the Arduino to drive the micro servos is fantastic!!!!  Open and close doors, animated figures that move and a truck that dumps.
 
Mel
 
Modeling the early to mid 1950s SP in HO scale since 1951
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
 
  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Saturday, October 29, 2016 1:02 PM

 I'm considering writing up my little dual servo controller once I get the design and software finalized, but I think it may be too complex for MR - it still uses the Arduino and the Arduino IDE but the process is a bit more complex than directly using an Arduino plus you need to build a little circuit to attach to the Arduino - it's really just connecting wires from a pin on the ATTiny85 to the specified Arduino pin, except for the 10uF cap that needs to go across gnd and reset.

 Software-wise it's really pretty simple other than the routine I cam eup with to stor the last position (so it can always position each turnout at the right spot on power up). The EEPROM in the AT micros is only rated for 100,000 writes (seems like a lot, but if you update the setting every time you push a button to throw a switch, and you like to run trains, you blast through that in no time). I came up with a routine that will stagger the writes throughout the whole memory, with one location used as a pointer to whatever block is being used currently - every other memory location hits the 100K writes long before the pointer gets written anywahere near 100K times. Since I am writing 3 bytes and the Tiny85 has 512K of EEPROM, I worked it out such that if you run trains 4 hours per day 4 days a week and for that 4 hours you change that one specific turnout 20 times a minute (warp speed switching, I guess), it would take 20 YEARS before any memory location accumulated 100K writes.

 I just have to get the details down to make it work as a proper sketch. The nested counting loops are the easy part, getting it to work with the EEPROM library and loading the initial values at startup is the tough part. But in the end - $5 of parts plus servos that are under $2 each means less than $10 to remote control 2 turnouts.

                  --Randy

 


Modeling the Reading Railroad in the 1950's

 

Visit my web site at www.readingeastpenn.com for construction updates, DCC Info, and more.

Subscriber & Member Login

Login, or register today to interact in our online community, comment on articles, receive our newsletter, manage your account online and more!

Users Online

There are no community member online

Search the Community

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
Model Railroader Newsletter See all
Sign up for our FREE e-newsletter and get model railroad news in your inbox!