PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics,...

87
1 PICAXE PIC 2015 East Coast 2015 East Coast Large Scale Train Show Large Scale Train Show Dave Bodnar Dave Bodnar March 27, 2015 March 27, 2015 York, PA York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets, Tips, Tricks & More! What’s This Arduino I’ve Been Hearing About? This presentation is available on-line at: www.trainelectronics.c om or www.davebodnar.com Revised 03-27-15

Transcript of PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics,...

Page 1: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

11

PICAXE PIC

2015 East Coast2015 East CoastLarge Scale Train ShowLarge Scale Train Show

Dave BodnarDave Bodnar

March 27, 2015March 27, 2015

York, PAYork, PA

Electronics, Microcontrollers & Trains

Electronic Gizmos, Gadgets, Tips, Tricks & More!

What’s This Arduino I’ve Been Hearing About?

This presentation isavailable on-line at:

www.trainelectronics.com or www.davebodnar.com

Revised 03-27-15

Page 2: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

22

PICAXE PIC

ObjectivesObjectives• Demonstrate various devices & projects that

utilize microcontroller operation …

• … and some that do not!

• (Hopefully) Excite you with the possibilities and

enable you to begin experimenting and enhancing your railroad!

Page 3: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

33

PICAXE PIC

Topics to be CoveredTopics to be Covered• PICAXE review – What is it? Why use it?

How do we use it?• Three Garden Railways PICAXE articles• Two Model Railroad Hobbyist PICAXE articles• Revolution Train Engineer for HO (and G!)• Introduction to Arduino & some of my projects• Tips, Tricks, Tools• New & improved gizmos & gadgets

Page 4: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

44

PICAXE PIC

PICAXE BasicsPICAXE Basics

• You can view my introductory PICAXE seminars on YouTube • davebodnar.com or

trainelectronics.com • Under Presentations • Or search www.YouTube.com for

“Bodnar PICAXE”

Page 5: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

55

PICAXE PIC

Links for You!Links for You!

• A file that includes links to most (hopefully all) items mentioned is on– www.trainelectronics.com – and– www.davebodnar.com

• This PowerPoint is there, too

Page 6: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

66

PICAXE PIC

Garden Railways Garden Railways PICAXE ArticlePICAXE Article

April 2013 Issuepages 54-59

Contains a detailed introduction to the PICAXE and several projects

Page 7: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

77

PICAXE PIC

Garden RailwaysGarden RailwaysPICAXE ArticlePICAXE Article

Shows how to build:• Single LED

Lighthouse• Single LED Mars

Light• Morse Code Beacon

All using the same circuit

Page 8: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

88

PICAXE PIC

PICAXE - What You NeedPICAXE - What You Need1. Computer with

serial port or …

USB to serial adapter or …

USB programming cable

2. Windows computer running free PICAXE software (Mac & Linux, too)

3. Power source– 3 @ AA cells = 4.5 volts

08M2 available from phanderson.com or sparkfun.com for < $3.00 each

Page 9: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

99

PICAXE PIC

PICAXE ProgrammingPICAXE Programming

• Download and install Editor

• Connect programming cable

• Select the PICAXE chip

• Load or cut & paste program

• Download program to PICAXE

Page 10: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

1010

PICAXE PIC

Garden RailwaysGarden RailwaysPICAXE ArticlePICAXE Article

Lighthouse Beacon #NO_DATA 'speeds up programming

#Picaxe 08M2 'identify the chipSETFREQ m32 'speed it up to 32 MHzSYMBOL Loopie = b2 'label variable b2 as LoopieSYMBOL Brightness = b1 'label b1 as BrightnessSYMBOL Dlay = 150 'set constant Dlay to 150Start:For Loopie = 0 to 100 step 1 '100 steps from off to brightbrightness=255-loopiepwmout c.2, brightness, loopie 'use PWM to brighten the LEDpause Dlay 'pause a bitnext loopie 'get the next item in for/nextpwmout c.2, 255,1023:pause 1000 'flash to full bright brieflyfor loopie = 100 to 0 step -1 'repeat above backwardsbrightness=255-loopiepwmout c.2, brightness,loopiepause Dlaynext loopiepause 2000 'pause a bit with LED offgoto start 'do it again!

Page 11: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

1111

PICAXE PIC

Garden RailwaysGarden RailwaysPICAXE ArticlePICAXE Article

Single LED Mars light

#NO_DATA 'speeds up programming

#Picaxe 08M2 'identify the chip

SETFREQ m32 'speed it up to 32 MHz

SYMBOL Loopie = b2 'label variable b2 as Loopie

SYMBOL Brightness = b1 'label b1 as Brightness

SYMBOL Dlay = 2 'set constant Dlay to 2

Start:

Gosub ShortFlash 'do the shorter flash routine

Gosub LongFlash 'do the longer flash routine

GOTO Start: 'repeat

ShortFlash: 'a label

For Loopie = 0 to 100 step 1 '100 steps from off to bright

brightness=255-loopie

pwmout c.2, brightness, loopie 'light the LED

pause Dlay

next loopie

for loopie = 100 to 0 step -1 'repeat above backwards

brightness=255-loopie

pwmout c.2, brightness,loopie

sertxd (#loopie, " ")

pause Dlay

next loopie

return 'return to the point where the routine was called

LongFlash: 'do the longer flash

For Loopie = 0 to 255 step 1 '255 steps from off to bright

brightness=255-loopie

pwmout c.2, brightness, loopie

pause Dlay

next loopie

for loopie = 255 to 0 step -1 'repeat above backwards

brightness=255-loopie

pwmout c.2, brightness,loopie

pause Dlay

next loopie

return

Page 12: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

1212

PICAXE PIC

Garden RailwaysGarden RailwaysPICAXE ArticlePICAXE Article

Morse Codebeacon

Page 13: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

1313

PICAXE PIC

Garden RailwaysGarden RailwaysPICAXE Article #2PICAXE Article #2

Focus is on a more advanced PICAXE chip

August 2014 issue

Page 14: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

1414

PICAXE PIC

PICAXE ArticlePICAXE Article

• Article #2 includes:– Working with multiple LEDs (up to 6)– Working with trigger inputs– Working with variable inputs (potentiometer)– Lots of projects / programs

Page 15: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

1515

PICAXE PIC

Article #2Article #2Custom Circuit BoardCustom Circuit Board

• I designed boards that support– up to 6 LEDs– 2 trigger switches – 2 potentiometers– 6 power transistors– 5 volt regulator

Page 16: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

1616

PICAXE PIC

Article #2 - ProgramsArticle #2 - Programs

• Crossing signal with two triggers

• Traffic light

• Emergency vehicle lights

• High power LED ditch lights

• School bus strobe light

Page 17: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

1717

PICAXE PIC

PICAXE ArticlePICAXE Article

• Article #3 • Two Parts: June & August 2015

• Train Detection – Using Infrared sensors

• Automatically trigger & stop crossing signal and other events

Page 18: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

1818

PICAXE PIC

Updated Cruise ControlUpdated Cruise Control

• Same IR sensor can be adapted to make an Eggliner or other small engine automatically slow as it approaches a train.

• Video on YouTube

Page 19: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

1919

PICAXE PIC

VideoVideo

Page 20: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

2020

PICAXE PIC

#1 Tip Ever - Adhesive#1 Tip Ever - Adhesive

Great for quick temporary or permanent connections– Similar to the “goo” on the

back of a new credit card– I use it in place of hot melt

glue– DOTS brand– Michaels (don’t forget the

40% off coupon!)

Page 21: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

2121

PICAXE PIC

Tip - SolderingTip - Soldering• A good iron makes you a better solderer!

– MPJA.com

– Item #ZD 929C – $46.95– Digital

temperature readout

– Replacement handle assembly $6.95

Page 22: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

2222

PICAXE PIC

Tip - SolderingTip - Soldering

• A clean tip makes all the difference.• http://www.dealextreme.com

• Item 34154 • $6.03

Page 23: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

2323

PICAXE PIC

Tip: Make MagazineTip: Make Magazine• Excellent source of

ideas and projects

• Not model railroad focused

• “Maker” focused

• Lots of excellent tips, projects & news

Page 24: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

2424

PICAXE PIC

Tip: MRH MagazineTip: MRH Magazine

– Free, on-line model railroad magazine– Mostly smaller scales– … but great articles that can easily be

adapted to larger scales– Don’t forget to check out their forum, too

Page 25: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

2525

PICAXE PIC

Tip: Nuts & Volts MagazineTip: Nuts & Volts Magazine

– Lots of PICAXE and Arduino projects & tutorials

– Back issues are available on CD

Page 26: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

2626

PICAXE PIC

Revolution for HO Revolution for HO & Others& Others!!

• Designed for HO but can be used with smallerG-scale locomotives &trolleys

• Available now

• Cost: $299 starter set $403 for 6 receivers

• http://www.crest-electronics.net/ho-revolution.html

Page 27: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

2727

PICAXE PIC

Revolution for HORevolution for HO• Very similar to the G-scale

version but incompatible transmitters & receivers

• Probably due to: – Size issues with the G-scale

radio receiver– Not needing the range of G-

scale allowed smaller components to be used

Page 28: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

2828

PICAXE PIC

Revolution for HORevolution for HO

• Transmitter operation and setup are nearly identical

• Main difference is that sound options (volume, steam vs diesel sound, etc) are in a menu, not on the main buttons

Page 29: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

2929

PICAXE PIC

Revolution for HORevolution for HO

• All receivers include sound

• diesel or steam – (selectable on transmitter)

• A speaker is NOT included

• Any 8 ohm speaker will work

• Tip: Cell phone speakers work very well!Search eBay for “iphone 4 speaker” less than $5.00

Page 30: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

3030

PICAXE PIC

Revolution for HORevolution for HO

• Linking receiver & transmitter uses a small magnet so it can be done through the loco’s body

• Full review on my web page:http://www.trainelectronics.com/HO_Train_Engineer/article.htm

Page 31: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

3131

PICAXE PIC

TipTipSalvage Magnets from old Hard DrivesSalvage Magnets from old Hard Drives

• Virtually all computer hard drives have strong (rare earth) magnets in them

• Remove case & carefully remove platters and other parts that are in the way

• Caution: some platters are GLASS! Fragile and easily converted to SHARP pieces!

Page 32: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

3232

PICAXE PIC

Tip – Magnets as ClampsTip – Magnets as Clamps

• I recently had to glue a sign to the middle of a building

• Putting a rare earth magnet on the front and another on the back made it a snap!

• Also great with “square” block behind

Page 33: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

3333

PICAXE PIC

Tip - MPJA Power SupplyTip - MPJA Power Supply

• Excellent tool for testing circuits

• Also works well for testing locomotive and other train related devices

• Dual meters (volts / amps) provide very valuable information

Page 34: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

3434

PICAXE PIC

TipTipdo-it-yourselfdo-it-yourself Power Supply Power Supply

• eBayDC-DC Contant Current Voltage Step-down Power Supply

• 3 amp < $15,

6 amp < $20

• Use your own fixedvoltage power supply

• Great for testingequipment

Page 35: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

3535

PICAXE PIC

3D Printing3D Printing

• Vendors continue to fine tune designs

• Dremel unit is first printer to be sold in large quantities from retail stores by a major tool manufacturer

• available @Home Depot

• ~ $1000.00

Page 36: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

3636

PICAXE PIC

3D Printing3D Printing

• Last year HP was rumored to be entering consumer market but…

• Their new printer is aimed at commercial clients and will not be ready for some time

Page 37: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

3737

PICAXE PIC

3D Printing3D Printing

• Design software still requires a commitment of time & effort to learn

• The free “Sketch Up” program is still my favorite

Page 38: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

3838

PICAXE PIC

3D Printing3D Printing

• www.Shapeways.com continues to do well printing from your designs

• More & more free files are available at www.thingiverse.com and at similar sites

Page 39: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

3939

PICAXE PIC

3D Printing3D Printing• My two 3D printers have become go-to tools for

many things • I use my saws, milling machine & lathe much

less often• Faster printers may be here soon

https://www.youtube.com/watch?v=VTJq9Z5g4Jk https://www.youtube.com/watch?v=MZs1fOSR2C8

Page 40: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

4040

PICAXE PIC

VideoVideo

Page 41: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

4141

PICAXE PIC

TipsTips• HF multi tool

• …works better if mounted to a bench• https://www.youtube.com/watch?v=x1TYueXHxgE

Page 42: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

4242

PICAXE PIC

VideoVideo

Page 43: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

4343

PICAXE PIC

Tip – HF Center PunchTip – HF Center Punch

• Accurately start holes when drilling

• Makes rivets, too!

Page 44: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

4444

PICAXE PIC

ArduinoArduino

• What is it?– A family of inexpensive and very capable

microcontrollers

• Developed in Italy in 2005

• Open source hardware and software (free license to use and modify)

Page 45: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

4545

PICAXE PIC

ArduinoArduino Why has it become so popular? Why has it become so popular?

• It is an inexpensive platform that is very well supported

• Hardware costs have dropped as thousands & thousands of hobbyists, world-wide, are using them

• It has become the most popular micro-controller development system in the world

Page 46: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

4646

PICAXE PIC

ArduinoArduino Why has it become so popular? Why has it become so popular?

• Free software to do just about anything you might need is available on the Internet

• On-line support is freely available

• Lots of books

• Tutorials on-line, too

• YouTube

Page 47: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

4747

PICAXE PIC

ArduinoArduino Why has it become so popular? Why has it become so popular?

• Can experiment without soldering!– Use a few jumper wires

• With a solderless prototype board

Page 48: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

4848

PICAXE PIC

ArduinoArduino Why has it become so popular? Why has it become so popular?

• Plug-in “shields” simplify building

• Some have a prototype board on them

Page 49: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

4949

PICAXE PIC

ArduinoArduino What Can It Do? What Can It Do?

• The Arduino can control just about any electronic device or component….

• … & gather and act on things it senses in the environment

• Originally designed for use by students and artists

Page 50: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

5050

PICAXE PIC

ArduinoArduino What Do You Need to Get Started? What Do You Need to Get Started?

• An Arduino board (< $10.00) and a computer (PC, MAC or Linux) with USB

• Software is free

• USB connections are included on many Arduino boards

• Recently purchased several UNO boards for < $5.00 each!

Page 51: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

5151

PICAXE PIC

Arduino Arduino

• The “down” side:– “C” language –can be confusing for beginners– C’s syntax and error messages (ie commands

are case sensitive!) can be illogical– Fortunately…– Books and on-line tutorials are available to

help – many YouTube videos, too

Page 52: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

5252

PICAXE PIC

Arduino Arduino

• But….– Once you see what it can do and how little it

can cost…. – It is worth learning!– I fought it for years but now have begun to

use them more and more

Page 53: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

5353

PICAXE PIC

Arduino Arduino

• And….– Using the Arduino and PICAXE controllers

with model railroading is an excellent way to get younger folks interested in model railroading!

Page 54: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

5454

PICAXE PIC

Arduino - First ProgramArduino - First Program• Download IDE (Integrated Development

Environment) • Free download from

– http://arduino.cc/en/Main/Software– For PC, Mac or Linux

Page 55: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

5555

PICAXE PIC

Arduino - First ProgramArduino - First Program

• Select board

• Select serial port

Page 56: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

5656

PICAXE PIC

Arduino - First ProgramArduino - First Program

• Load “blink” from basic examples– File / Examples / 01.Basics / Blink

Page 57: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

5757

PICAXE PIC

Arduino - First ProgramArduino - First Program

• Comments– //– /* */

• Variable definitions

• setup • loop

Page 58: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

5858

PICAXE PIC

Arduino - First ProgramArduino - First Program

• Upload to Arduino & observe• Modify to blink faster, slower, non-symmetrically

Page 59: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

5959

PICAXE PIC

Arduino - First ProgramArduino - First Program

– Add 2nd LED – modify for

crossing signal

Page 60: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

6060

PICAXE PIC

Arduino - First ProgramArduino - First Program

• Load “fade”– Have to change

to analog pin 9– 3, 5, 6, 9, 10,

and 11 can be used foranalog output

Page 61: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

6161

PICAXE PIC

Arduino - First ProgramArduino - First Program

• Modify for ditch lights

Page 62: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

6262

PICAXE PIC

Arduino - First ProgramArduino - First Program

• Modify to remove “bug”while flashing

Page 63: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

6363

PICAXE PIC

Arduino - First ProgramArduino - First Program

• Add a “pot” to vary the speed

Page 64: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

6464

PICAXE PIC

Arduino Projects:Arduino Projects:

• DCC controller

• A complete system can be built with very few parts

• Operated with a TV remote control

Page 65: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

6565

PICAXE PIC

Arduino Projects:Arduino Projects:• DCC

decoder • Used as an

accessory decoder to operate animations & sounds

• From MRH magazine

Page 66: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

6666

PICAXE PIC

Arduino Projects:Arduino Projects:

• auto-reverse unit – Two shields stack onto the Arduino– Shield 1 houses the power transistor and

relay– Shield 2 has the display and function buttons

Page 67: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

6767

PICAXE PIC

Arduino Projects:Arduino Projects:

• light controllers (lighthouse, etc)– Hardware is similar to what is used with the

PICAXE– Use an analog pin for gradual changes in

brightness– Can be very small with 8 pin Arduino chip

Page 68: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

6868

PICAXE PIC

Arduino Projects:Arduino Projects:

• Defect detector /w audio– Uses two lasers to count axles– Computes train length & speed– Reports random defects, temperature, length,

speed– Can transmit reports via radio

Page 69: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

6969

PICAXE PIC

Arduino Projects:Arduino Projects:

• MP3 module works with or without Arduino– Used in Defect Detector– Very high quality mono or stereo sound– Complex sound presentation with Arduino– Simple (next / previous / file #) sound with just

a few buttons– Uses micro SD card– < $5.00!

Page 70: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

7070

PICAXE PIC

Arduino Projects:Arduino Projects:

• MP3 player as stand alone player (only need a speaker, battery & switches)– High quality sound from MP3 files– Use with only a speaker or to drive amplified

speakers (from old PC?)

Page 71: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

7171

PICAXE PIC

Arduino Projects:Arduino Projects:• Add an Arduino and each button press

selects either– The next file– A random file

Page 72: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

7272

PICAXE PIC

Arduino Projects:Arduino Projects:

• LED matrix signs– Highly visible– Uses 3 or more 8x8 LED modules– Arduino libraries & sample programs make

using them quite simple

Page 73: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

7373

PICAXE PIC

It’s more fun to make it yourself than to buy it ready to go!

"I am always doing that which I "I am always doing that which I cannot do, in order that I may cannot do, in order that I may learn how to do it."learn how to do it."Pablo PicassoPablo Picasso

Remember:

Page 74: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

7474

PICAXE PIC

Your Ideas?Your Ideas?

• Questions?

Page 75: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

7575

PICAXE PIC

Page 76: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

7676

PICAXE PIC

Servo Extension CablesServo Extension Cables

• Need to connect 3 wire device?

• Available in many lengths up to 1 meter

Page 77: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

7777

PICAXE PIC

Servo Extension CablesServo Extension Cables

• Available on eBay

• For more connectors see my article:

Power Connectors for Garden Railroad Applications

• http://www.trainelectronics.com/Articles/Connectors/index.htm

Page 78: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

8080

PICAXE PIC

Tip – Heat Shrink TubingTip – Heat Shrink Tubing• Excellent for insulating joints & making

repairs• Soldering wires first is recommended but

not mandatory• Available in many colors – great trick for

identifying wires• Available in many diameters, too• Fry’s has an excellent supply, BangGood,

too!

Page 79: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

8181

PICAXE PIC

Tip – Tiny MotorTip – Tiny Motor• Gear head motor a bit larger than a penny

• Surprisingly high torque

• http://www.suntekstore.com item # 14002627

• Less than $6.00 shipped

• Ideal for many animations

Page 80: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

8282

PICAXE PIC

Tip – Dubro CollarsTip – Dubro Collars

• Ideal for connecting to motor shafts & to join piano wire for servos

• http://shop.dubro.com/c/aircraft_collars

Page 81: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

8383

PICAXE PIC

Tip – Tiny Volt MeterTip – Tiny Volt Meter

• Powered from voltage being measured – 4 to 30 volts

• Approx 1” x ½” x ½”

• Search eBay for:“Ultra Mini size LED Volt Meter”

• $6.99 + $2.00 shipping

Page 82: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

8484

PICAXE PIC

Tip – Tiny Volt MeterTip – Tiny Volt Meter

• Makes a nice track voltage tester

• Use a 10 watt / 12 volt bulb as a load

Page 83: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

8585

PICAXE PIC

TipTipRubber Bands to Join TrackRubber Bands to Join Track

• Cut bicycle tubes into loops to join track for club or other temporary layouts

• Road bike tubes work best

• Paper cutter is a plus

Free from most bike shops!

Page 84: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

8989

PICAXE PIC

It’s more fun to make it yourself than to buy it ready to go!

"I am always doing that which I "I am always doing that which I cannot do, in order that I may cannot do, in order that I may learn how to do it."learn how to do it."Pablo PicassoPablo Picasso

Remember:

Page 85: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

9090

PICAXE PIC

Your Ideas?Your Ideas?

• Questions?

Page 86: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

9191

PICAXE PIC

Page 87: PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,

9292

PICAXE PIC