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!

Auto circuit switch

3401 views
18 replies
1 rating 2 rating 3 rating 4 rating 5 rating
  • Member since
    June 2016
  • 81 posts
Auto circuit switch
Posted by Ron Hume on Friday, August 18, 2017 9:45 AM

Hi all,

I tried an Arduino Uno chip to switch structure lighting on randomely without success so I'll scrap thaty idea and replace it with some type of mechanical switching device, like an automatic rotary switch with seven or so positions. Can anyone suggest a unit to fit the bill?

Ron from down under.

  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Friday, August 18, 2017 12:38 PM

Hi Ron
 
Check out my blog post on my Arduino lighting controller, it will drive 14 LEDs directly or by adding a driver expansion board it will drive 14 lamps up to 500 ma per port.  I have three lighting controllers working without any problems.
 
 
If you need any additional info send me message though the Forum.
 
 
 
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 Friday, August 18, 2017 4:12 PM

 In addition to Mels circuit there are some on other sites, like Geoff Bunza's blog on MRH. Just google Geoff Bunza Arduino and you'll find all sorts of interesting projects. Code is supplied as well, so you just have to wire it up as shown and load the code and it will work.

                              --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, August 18, 2017 11:41 PM

Hi Mel,

I tried the Arduino gig twice with two different sketches from this forum without success and I'm sick of crawling under the bench fitting and removing the chip at my age. So I've decided to toss out the chip and find something more robust. Hence the request for an automatic mechanical or electronic switch.

Ron from down under.

  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Saturday, August 19, 2017 3:23 PM

 That's why you test this stuff at the bench, and only when you have it working do you crawl under the bench and hook it up. Big Smile

                             --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
    July 2009
  • From: lavale, md
  • 4,678 posts
Posted by gregc on Sunday, August 20, 2017 6:03 AM

might be able to solve your Arduino problem if you describe what you want to do, post a copy of the program (or where you got it) and a description of how you wired it.

a thread like this is a turn-off for others who might be interested in using a Arduino for similar things.

greg - Philadelphia & Reading / Reading

  • Member since
    June 2016
  • 81 posts
Posted by Ron Hume on Sunday, August 20, 2017 9:33 AM

Hi Greg,

I got the sketch from RR_Mel on 17/10/16 (10/17/16) together with lots of helpful info from Randy and Dave. I loaded it ok and wired the chip into the LED circuits but it did nothing but blink at me. Checked polarity etc to no avail. Don't know how to check on the bench before installation so gave up on it. I think it's too complicated for me, maybe I'll have to use a bank of toggle switches manually.

Ron from down under.

  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Sunday, August 20, 2017 10:03 AM

Ron
 
Did you go with the high current driver expansion board or just the UNO and LEDs?
 
The expansion board I show on my blog is not a standard Arduino expansion board.  It has two hole links that a standard Perf board doesn’t have.  This is where I purchased the boards I used.
 
 
Message me and I’ll walk you through building up my Arduino light controller.  It really is an easy project and very doable.
 
 
 
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
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Sunday, August 20, 2017 10:44 AM

Ron
 
I went over my blog lighting controller and found several errors.  I’m in progress of correcting them.  The wiring drawings are for my original 12 port version not 14 port.  The Sketch is for 14 ports.
 
Sorry about that, my BAD.
 
 
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
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Sunday, August 20, 2017 12:09 PM

I have updated my blog and Google Drive on my 14 port Arduino Lighting Controller.  I proofed it a dozen times and it looks correct now.  It must be an age thing, my brain still works but some of the wiring must have cold solder joints.
 
Sorry for any problems my errors may have caused!!!!
 
 
 
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 Sunday, August 20, 2017 2:12 PM

 If you have LEDs in your buildings, just get some extra LEDs and you cna plug them into the Arduino on the workbench and make sure it all works before crawling under the layout. It also helps to use some plug and sockets of some type, that way the under the layout connections are easy. If it doesn't work at the bench, no sense crawling around under the layout. And if it does work at the bench, then there's no reason it won;t work on the layout.

LEDs are polarity dependent, so if they never light up, likely they are just hooked up backwards. As long as they also have the required resistors, no harm will come, just try then with the leads reversed.

If by "it just blinked at me" you mean the LED on the Arduino just flashed - seems like maybe it never got the sketch uploaded (programs are called sketches in the Arduino world because they were originally designed for artists). Most Arduinos out of the box have a simple 'blink' sketch loaded that blinks the one LED on the board, and this will start up as soon as power is applied, until you upload a different program to it and overwrite it. It's sort of like DCC decoders coming set on address 3. The programs to randomize structure lighting are very much the same as the basic Blink program except the intervals are more than the half a second used for the blinking LED and instead of turning just the one pin on and off, it controls more of them. Blink turns pin 13 on and off, but depending on which particualr Arduino you have, there are a lot more pins you can control.

                                      --Randy

 

                             --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 Monday, August 21, 2017 11:33 AM

Hi Mel,

I used the Arduino Uno chip with a shield to facilitate connections to the LEDs.

I tried the circuit before having all the LEDs connected, nothing worked, then I temporarily connected all seven LEDs to see if it made any difference, nothing. I checked polarity, no go.

What, if anything, happens if all circuits aren't connected?

I don't know why I need the high current driver with LEDs. 

  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Monday, August 21, 2017 2:02 PM

Ron Hume

Hi Mel,

I used the Arduino Uno chip with a shield to facilitate connections to the LEDs.

I tried the circuit before having all the LEDs connected, nothing worked, then I temporarily connected all seven LEDs to see if it made any difference, nothing. I checked polarity, no go.

What, if anything, happens if all circuits aren't connected?  Everything connected will work normal, not having all ports in use doesn't change the operation.

I don't know why I need the high current driver with LEDs.  You don't need the high current driver for LEDs.  The Arduino Specifications say the ports are good for 20ma but to be on the safeside I keep the port load to 15ma per port, 15ma should more than enough for one LED

 

The blog post wiring that you used was incorrect, it was for my original 12 port controller.  I have since corrected the post to my 14 port controller and it should work OK.
 
Ron I’m so sorry that I dinged your project.  If you would send me your email address through the Forum Messaging I will be happy to walk you through getting yours working.
 
 
 
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
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Monday, August 21, 2017 8:07 PM

Ron
 
The drawing below will work as a test circuit or wire it direct to your LEDs.  No need for an expansion shield for LEDs, the Arduino connectors plug directly into the Arduino UNO.
 
I use 330Ω ¼ watt resistors for my test setup, using bright white 5mm LEDs with 330Ω resistors from the 5 volts in the Arduino the LEDs draw 6.8ma and they are very bright.
 
 
Use the connections above with the sketch below and it will work.
 
====================================
#define numleds  14                                                      
byte ledpins [ ] =  { 0,1,2,3,4,5,6,7,8,9,10,11,12,13 } ;
void setup( )  {                  
    for ( int  i=1; i <= numleds;  i++ )  {     
    pinMode ( ledpins [ i ], OUTPUT) ;
    digitalWrite ( ledpins [ i ] , HIGH) ;
   }
  
}
void loop ( )  {  
                digitalWrite ( ledpins [ random ( 0, numleds+1 ) ], lightsw ( ) ) ;
                delay ( 4000 ) ;                  
}
boolean lightsw ( )  {
 
 if  ( random (0,100) > 60 ) return LOW ;
   else return HIGH ;
}

=====================================
 You can juggle the timing by changing the delay (4000).  The delays in the sketch above work great for my needs, the random pick runs from about 30 second to 4 minutes.
 
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 Monday, August 21, 2017 9:15 PM

Thanks Mel,

I have copied your post and will delve into it. Thanks for all your help and patience, this is all like trying to learn Chinese for me.

Ron from down under.

  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Monday, August 21, 2017 9:34 PM

If you have any problems contact me and we will work it out.  I will be glad to help you if you need help.
 
 
 
 
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 Wednesday, August 23, 2017 4:52 AM

Your sketch was loaded successfully and bench tested ok. The chip is reinstalled on the layout and is controlling the lights as expected.

All good things come to those who persevere!

  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Wednesday, August 23, 2017 7:06 AM

 Your next assignment, should you chose to accept it, is to compare the old diagram and the new one and see if yoou can spot the mistake and why it is a mistake. If you understand that - grab another Arduino and see what else you can come up with to use it for on your layout! But it's addictive!

                                      --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, August 23, 2017 8:56 AM

Ron
 
I’m sorry that I created a problem for you, it’s hard enough to learn new goodies without help from a lousy instructor.  I’m glad you got it going and take Randy’s advice and dig in.  The Arduino is very addictive but fun with everything you can do with them.  There are a lot of Forum members that can help you through tough the spots.
 
 
 
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.
 

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!