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!

So explain an arduino please

5700 views
40 replies
1 rating 2 rating 3 rating 4 rating 5 rating
  • Member since
    September 2002
  • 7,474 posts
So explain an arduino please
Posted by ndbprr on Friday, August 21, 2020 5:20 PM

Voltage, size,usage examples, what it does or anything else I should know.

  • Member since
    July 2009
  • From: lavale, md
  • 4,640 posts
Posted by gregc on Friday, August 21, 2020 5:30 PM

it's a small microcontroller on a board with headers providing access to its I/O pins and with an USB interface chip that supports programming and serial communication while running.

it is a microcontroller vs a microprocessor in that the chip includes functionality other than just program execution including, digital I/O, USART, analog to digital conversion, PWM output, I2C/SPI interfaces and built in EEPROM

it can run off the 5V from the USB interface

many use them to control LEDs.   i've built an NCE compatible cab and a turntable controller using an encoder and the PID algorithm to control motor speed.   i'm sure it can be used for many other applications.

it is programmed in C/C++

greg - Philadelphia & Reading / Reading

  • Member since
    September 2003
  • 21,326 posts
Posted by Overmod on Friday, August 21, 2020 9:35 PM

gregc
...USART

Is that a real USART with synchronous clocking options or just that scam thing where they use the 's' redundantly as 'serial' to make you think their UART is something more sophisticated?

  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Friday, August 21, 2020 9:54 PM

 

There are literally hundreds of uses for the Arduino micro processors in model railroading, the limiting factor is your imagination.

Arduinos are available from postage stamp size to the MEGA 4 in × 2.1 in.

They operate at 5 volts.  Their max current output is 40ma per port, 500ma using a driver chip.

I have almost all sizes of Arduinos, more UNOs than others.

My primary use for the UNO is Random Lighting Controllers, I use the MEGAs for CTC signaling controllers.

My UNO Random Lighting Controller.

https://melvineperry.blogspot.com/b/post-preview?token=APq4FmBZ1Z4vSsWWqfierGUeqI4kPQg-aZFyqgJfGzTYO2wcdiaGp4M39XCaNEjnV9VBFosI4ZWEorFUm-j1kGa5d92l75zWghA3jmIAkYXXGDCmWwvPAnIimvbS-MyRs5i-6Up9BGXU&postId=3194113493259308193&type=POST


My Crossing Gate Controller.

https://melvineperry.blogspot.com/p/blog-page_97.html

My CTC Signal Controller.

https://melvineperry.blogspot.com/2017/02/february-3-2017-arduino-mega-signal.html

My Emergency Vehicle Light controller.

https://melvineperry.blogspot.com/2019/01/january-16-2019-arduino-multasking.html

My tower beacon flasher.

https://melvineperry.blogspot.com/2019/01/january-21-2019-arduino-nano-tower.html

Many many more, just use your imagination and do it to it.



Mel


 
My Model Railroad  
http://melvineperry.blogspot.com/
 
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 21, 2020 11:27 PM

Overmod

 

 
gregc
...USART

 

Is that a real USART with synchronous clocking options or just that scam thing where they use the 's' redundantly as 'serial' to make you think their UART is something more sophisticated?

 

Arduino is more an ecosystem that a particular piece of hardware. There is a LOT of hardware which is compatible with the Arduino development environment, including micros that have 32 bit ARM cores. The main point of Arduino is to isolate you from all the 'fiddly bits' of working with a microcontroller in assembly or straight C. Downside is the code runs slower because of the extra layers. But instead of doing a bitmask operation to set bit 3 of port C to output, you just have to say pinMode(3,OUTPUT). You can do inline code to do direct register access - it makes things run a LOT faster, if speed is important. For most model railroad uses, the stock performance is perfectly fine, nothing really happens all that fast. 

 The most popular one thos is the Uno, which has an 8 bit Atmel ATMega328. It has one hardware UART. The Arduino Megas, using the ATMegas 2560, has a LOT more IO pins, and has 4 UARTs. Per the data sheets, they really are USARTs, and can be used either synchronously or asynchronously. Section 22 of the 2560 data sheet, if you care to look.

                                          --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
    September 2004
  • From: Dearborn Station
  • 24,019 posts
Posted by richhotrain on Friday, August 21, 2020 11:57 PM

ndbprr

Voltage, size,usage examples, what it does or anything else I should know. 

It is a mystery component that we all sense that we need for our layout, but no one actually owns. Laugh

Seriously, though, I am sure that others probably understand and use an Arduino, but it remains a mystery to me.

Rich

Alton Junction

  • Member since
    July 2009
  • From: lavale, md
  • 4,640 posts
Posted by gregc on Saturday, August 22, 2020 5:09 AM

Overmod
gregc
...USART

Is that a real USART with synchronous clocking options or just that scam thing where they use the 's' redundantly as 'serial' to make you think their UART is something more sophisticated?

sect 19 of the mega328p datasheet describes synchronous operation.

these are commercial products used in non-hobbyist applications

greg - Philadelphia & Reading / Reading

  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Saturday, August 22, 2020 12:46 PM

 Actually, I only use the full Arduino boards for prototyping. As you might catch in my servo thread, my final product uses the microcontroller itself. One exception is a device I made to program the bare microcontrollers, it uses an Arduino Nano on the board to do the programming. So in the end, there probably will be no actual Arduinos on my layout, but there will be plenty of bits programmed with the Arduino development environment.

                                        --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,640 posts
Posted by gregc on Saturday, August 22, 2020 1:13 PM

the advantage of actually using an arduino, or something with that USB interface chip is that you can cable it to a laptop and reprogram it.

i helped straighten out an interlock controller that had some mis-configured routes using a 15' usb cable to reprogram and quickly test the routes from the panel.

arduino uno is bottom left.   i2c i/o boards on left to read switches and pulse latching relays on right.   (will drive tortoises with lm324 op-amps on other west interlock)

greg - Philadelphia & Reading / Reading

  • Member since
    September 2002
  • 7,474 posts
Posted by ndbprr on Monday, August 24, 2020 7:03 AM

So the framus connects to the dohicky which vibrates the gizmo to light a light.  Think i will just use a switch.  At least I understand it.

  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Monday, August 24, 2020 8:21 AM

 The idea is that it does more than a switch. If all you need to do is turn something on and off when you want to, just use a switch. But if you put full interiors into things and want to make the house come alive, where in early evening the kitchen and living room lights are on, then after dinner the living room is lit up and the family is watchign TV, then everyone goes upstairs while Dad stays in the living room watching TV until a bit later when he too goes up to bed....

 Yeah, you can do that with plain switches, but then you have to spend time watching and controlling that instead of running the train.

 We used to put lights in all our structures, had a pretty big switch board to control it all. But then we'd go visit other layouts and no houses or anything had lights in them, seemed dull. Now that companies are making pre-printed interiors, you don't even have to be some sort of master scratchbuilder to actually put a full interior in a structure, at least ones close up where they can be seen (seems silly to put all that in something that's way back in the corner where no one could possibly see it), instead of one monolithic light bulb, or even the whole thing either being lit up or dark, individual room lights are where it's at these days, especially with readily available micro LEDs (which can even be had with the wires already attached, so the hard part is done). 

 Sure, you can use a slow speed motor, a big wheel, or drum, and lots of switches.

A good not too technical article is Geoff Bunza's Arduino for Modelers article. Can't link it, it references another publication, but you can Google it. Keep in mind - Arduino was designed for Artists, not Engineers.

                                          --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
    September 2004
  • From: Dearborn Station
  • 24,019 posts
Posted by richhotrain on Monday, August 24, 2020 8:38 AM

I always come away from these Arduino discussions with the sense that what an Arduino is mostly used for is to create lighting effects inside buildings. But, when you are looking down on your layout from 260 scale feet in the air, how much are you going to see going on inside a building anyhow?

Rich

Alton Junction

  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Monday, August 24, 2020 8:43 AM

You see it. You always see it. It really sticks out when I visit layouts if they have structure lighting or just plopped a bunch of models in the scene.

 Lighting is probably the easiest thing to do, which is why it always comes up on Arduino 101. But there's a lot more. All my turnout controls are Arduino. My signalling and control will be Arduino. Etc.

                                     --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 Monday, August 24, 2020 9:36 AM

richhotrain

I always come away from these Arduino discussions with the sense that what an Arduino is mostly used for is to create lighting effects inside buildings. But, when you are looking down on your layout from 260 scale feet in the air, how much are you going to see going on inside a building anyhow?

Rich

 

Rich

I have 8 houses on my layout each using an Arduino UNO Random Lighting Controller.  The homes are my wife and I plus one for each of our children, each house has 20 individual lights.



The random on and off lighting jumps out at you.  The house on the right is a Kit (Winter’s Mansion) the one in the middle is scratch built.  Winter’s Mansion has 18 rooms and two porch lights, the scratch built has two porch lights, 13 rooms and the garage has 5 lights, 3 over doors and one over each stall.

The on off timing is programmable in the Arduino so no two houses look the same.  All look lived in.  Two have a flickering fireplace in the living room.

The emergency vehicles on my roads with non synced flashing roof light look awesome.  I have a 150’ communications tower and two elevated water tanks with flashing beacons also flashing out of sync.

https://melvineperry.blogspot.com/p/blog-page_56.html

The lighting on my layout brings more comments than any train moving. 


Mel


 
My Model Railroad  
http://melvineperry.blogspot.com/
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.

  • Member since
    July 2009
  • From: lavale, md
  • 4,640 posts
Posted by gregc on Monday, August 24, 2020 11:15 AM

richhotrain
I always come away from these Arduino discussions with the sense that what an Arduino is mostly used for is to create lighting effects inside buildings.

you don't hear about other applications because most modelers on this forum are not interested.   neither are model railroad magazines. 

while wiring and electronics is an important aspect of model railroading, software is of very narrow interest.    most modelers are challenged by understanding electronics much less software and those that don't have a software background use an Arduino for simple things.

but because the Arduino is programmable and comes on several different size boards with pin headers you just stick a wire into and a USB programming interface, they can be used for more sophisticated projects than just LEDs using commercial hardware and software off the web.

many projects require a small stock of parts.    i recently needed an NCE USB interface to try out a Wifi throttle.   finding the serial command set on the web used by JMRI, i was able to build an adapter using an Arduino Mega with its multiple serial interfaces.     most modelers would just buy the adapter for $50, but building electronics is my thing.   think of it as scratch building.

based on what I see on the arduino programming questions forum many people have ambitious goals but struggle with programming.   but for those having the skills to develop your own programs its possible to build your own electronics and experiment with things you can't buy commercially; either saving $$ or doing something you couldn't do otherwise

beyond the Arduino are esp32 boards which have WiFi and Bluetooth radio interfaces.    the radio interfaces make these suitable for wireless applications and can be programmed using the same development environment and USB cable as an Arduino

 557

greg - Philadelphia & Reading / Reading

  • Member since
    September 2004
  • From: Dearborn Station
  • 24,019 posts
Posted by richhotrain on Monday, August 24, 2020 1:57 PM

greg, I think that you hit the nail on the head. Since the Arduino requires a working knowledge of C++ programming language for more sophisticated applications, most model railroaders are not inclined to learn how to program code.

In the early part of my career, I was a computer programmer, and I have learned several high level languages. Later in my career, as a financial planner, I developed a suite of programs written in Visual Basic that I sold commercially.

So, I would not be intimidated by Arduino, but I would have no interest in programming it. Been there, done that.

Rich

Alton Junction

  • Member since
    July 2009
  • From: lavale, md
  • 4,640 posts
Posted by gregc on Monday, August 24, 2020 2:49 PM

richhotrain
Since the Arduino requires a working knowledge of C++ programming language for more sophisticated applications, most model railroaders are not inclined to learn how to program

you need to know C to develop sophisticated Arduino programs.   C is closer to assembler than many languages.   but knowing a language and understanding programming concepts are two different things.     

a programming concept many newbies don't take advantage of is writing a single function instead of using cut&paste to duplicate code.  another is using arrays.

620

greg - Philadelphia & Reading / Reading

  • Member since
    May 2016
  • 51 posts
Posted by Atchee on Thursday, August 27, 2020 11:42 AM

Think of an Arduino as a building block.  It can be used to replace switch machines using servo motors, animating semaphores and grade crossing arms, various lighting on a layout (or in the room for that matter.)

There are a number of add on modules often called shields that make a lot of building circuitry unnecessary.  These include things like servo drivers, relay boards, MOSFETs for high current use, wifi capability (if the Arduino doesn't have it already).

Yes, there is coding involved.  However, a lot that is already written and available can be adapted easily to your needs and you don't need to be a guru to do it.

There are a lot of thoughts on how to program an Arduino to get the most out of it.  I ignore almost all of it because I find the things cheap enough to use one anywhere there is a cluster of stuff to operate, for example, a double crossover using 4 servos, and maybe handle signals at the location. 

You can become very knowledgeable about Arduinos using YouTube, various articles in model railroad magazines, robotics, and so on. Honestly if you cut and paste available code to suit your needs the difference in how fast the code runs versus the needs on a layout, unless you get into using the Arduino for controlling locomotives, doesn't matter too much.  This approach lets you get right into using Arduinos while learning how to do more with them.

So, if you get interested in using Arduinos be prepared to spend time learning to use them.  The effort was/is worth the time for me. YMMV

  • Member since
    February 2008
  • From: Potomac Yard
  • 2,761 posts
Posted by NittanyLion on Thursday, August 27, 2020 12:51 PM

rrinker

Lighting is probably the easiest thing to do, which is why it always comes up on Arduino 101. 

 

 

Exactly.  A basic lighting module is basically just taking the "blink" sketch (which is the Arduino Hello World) and changing some variables.  

While I definitely could not write the sketch for it, my very first Arudino project was building a DCC module so I can run JMRI to program decoders.  It has enough output that I could probably run a 4x8 off of it with one or two locomotives.

  • Member since
    April 2012
  • From: Huron, SD
  • 1,016 posts
Posted by Bayfield Transfer Railway on Thursday, August 27, 2020 6:41 PM

If one wanted to know about the Arduino, wouldn't it make more sense to do a Google search on "Arduino?"

I'm retired and have no desire to learn another computer language, personally.  When they make an Arduino that can complie COBOL, wake me up.

 

Disclaimer:  This post may contain humor, sarcasm, and/or flatulence.

Michael Mornard

Bringing the North Woods to South Dakota!

  • Member since
    April 2012
  • From: Huron, SD
  • 1,016 posts
Posted by Bayfield Transfer Railway on Friday, August 28, 2020 5:12 PM

Also, the notion of "programmable doohickey to control stuff on my railroad" has more than one answer.  There is also, for instance, the "Basic Stamp" from Parallax, which uses a simpler language.

https://www.parallax.com/product/bs2-ic

 

 

Disclaimer:  This post may contain humor, sarcasm, and/or flatulence.

Michael Mornard

Bringing the North Woods to South Dakota!

  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Friday, August 28, 2020 6:01 PM

Comes at a price. The BASIC Stamp goes way back, long before Arduino, actually. Probably the first easy to use microcontroller. But they don't seem to have nearly the support or the following any more, compared to Arduino. For example, you can get 3 packs of Arduino Nanos for under $15 on Amazon. Yes, less than $5 each. 

                                       --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
    December 2004
  • From: Rimrock, Arizona
  • 11,241 posts
Posted by SpaceMouse on Friday, August 28, 2020 6:52 PM

I already suspect that the Lilliputians on my layout are alive, but if they start turning their lights on and off...

Chip

Building the Rock Ridge Railroad with the slowest construction crew west of the Pecos.

  • Member since
    April 2012
  • From: Huron, SD
  • 1,016 posts
Posted by Bayfield Transfer Railway on Saturday, August 29, 2020 11:44 AM

The Basic Stamp may be pricey, but not having to teach myself a new language holds a high value.

Disclaimer:  This post may contain humor, sarcasm, and/or flatulence.

Michael Mornard

Bringing the North Woods to South Dakota!

  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Saturday, August 29, 2020 12:03 PM

Bayfield Transfer Railway

The Basic Stamp may be pricey, but not having to teach myself a new language holds a high value.

 

As the old saying says, “if you haven’t tried it don’t knock it”.  The Arduino is a terrific compact high powered processor for the price.  $5

If an 83 year old fart like me with no programming experience can get an Arduino to go it should be a snap for anyone with any kind of programming background.

 

Mel



 
My Model Railroad   
http://melvineperry.blogspot.com/
 
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, August 29, 2020 12:45 PM

 Once you know one programming language, picking up others is fairly easy - because you already understnad the concepts, it's just specific syntax. 

 If you're just using one or two - OK. But I am building my own turnout controllers, and will need probably 50 of those, plus at least a dozen nodes for detectors and signals. I'm not even using $5 Arduinos, I am using the microcontroller chip itself. It costs about $2 for the chip plus the components to make it 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
    July 2009
  • From: lavale, md
  • 4,640 posts
Posted by gregc on Monday, August 31, 2020 5:04 AM

rrinker
Once you know one programming language, picking up others is fairly easy - because you already understnad the concepts, it's just specific syntax.

pointers and user defined variables (structures) make C suitable to implement an operating system controlling hardware and embedded applications.

these aren't features of many languages: basic, fortran, cobol, even pascal.   the concept of pointers to data is developed in pascal to support linked lists and tree structures for managing data.   but pascal doesn't allow a user specified pointer value to access hardware/memory.

1143

greg - Philadelphia & Reading / Reading

  • Member since
    September 2004
  • From: Dearborn Station
  • 24,019 posts
Posted by richhotrain on Monday, August 31, 2020 6:51 AM

gregc

pointers and user defined variables (structures) make C suitable to implement an operating system controlling hardware and embedded applications.

these aren't features of many languages: basic, fortran, cobol, even pascal.   the concept of pointers to data is developed in pascal to support linked lists and tree structures for managing data.   but pascal doesn't allow a user specified pointer value to access hardware/memory. 

In appropriate applications, C wins, hands down, over Basic, Fortran, Cobol and Pascal. Of course, in a lot of situations, the non-C languages are adequate. The best programmers have learned to master multiple programming languages.

Rich

Alton Junction

  • Member since
    July 2009
  • From: lavale, md
  • 4,640 posts
Posted by gregc on Monday, August 31, 2020 7:46 AM

the one i use most is AWK

greg - Philadelphia & Reading / Reading

  • Member since
    February 2002
  • From: Reading, PA
  • 30,002 posts
Posted by rrinker on Monday, August 31, 2020 8:11 AM

 Pascal never interested me - it always felt like it was simply created to make it easy to teach and grade programming. It's pretty structured such that there aren;t a whole lot of ways to solve a given problem. By comparison, C is the wild west. there are a million ways to solve a given problem, and programmers will argue for days over which is the better solution. And all be correct.

 I started with BASIC, it was approachable (heck, there was even an anthropomophic computer cartoon in the manual) and my 11 year old brain readily absorbed it. But even the cheapest machine running it was out of my reach, so I had to learn direct machine code programming for my first machine, the realtively obscure RCA 1802. Second machine language I learned was Z80, as my friend bought the Editor/Assembler for his TRS-80 and had no idea what it was for. The 1802 architecture especially spoiled me, so by the time I tried 6502 on the Apples at school, I was wondering why everyone praised the 6502 so much. So clunky. But it was cheap...  To this day I have never understood the infatuation for the Commodore 64. Maybe because I was more into making the computer do useful thing than playing neat looking games.

 FORTRAN was next, and outside of higher level stuff like dBase/Foxbase programming, the first I actually used in a work environment. Not into Pascal, but when Borland Turbo C came out, I started learning C. Also coincided with playing with early versions of Linux. A bunch of years ago I got a PIC experimenter kit and tried learning those, to use in my own projects. I didn;t get too far, then I saw Arduino. Within a few minutes I got past the basic Blink and variations of it. This just all clicked and for the past few years I have been building and tryuing all sorts of different things.

                                       --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!