PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics,...
-
Upload
baldric-wright -
Category
Documents
-
view
222 -
download
3
Transcript of PICAXEPIC 1 2015 East Coast Large Scale Train Show Dave Bodnar March 27, 2015 York, PA Electronics,...
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
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!
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
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”
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
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
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
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
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
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!
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
1212
PICAXE PIC
Garden RailwaysGarden RailwaysPICAXE ArticlePICAXE Article
Morse Codebeacon
1313
PICAXE PIC
Garden RailwaysGarden RailwaysPICAXE Article #2PICAXE Article #2
Focus is on a more advanced PICAXE chip
August 2014 issue
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
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
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
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
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
1919
PICAXE PIC
VideoVideo
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!)
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
2222
PICAXE PIC
Tip - SolderingTip - Soldering
• A clean tip makes all the difference.• http://www.dealextreme.com
• Item 34154 • $6.03
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
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
2525
PICAXE PIC
Tip: Nuts & Volts MagazineTip: Nuts & Volts Magazine
– Lots of PICAXE and Arduino projects & tutorials
– Back issues are available on CD
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
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
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
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
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
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!
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
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
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
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
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
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
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
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
4040
PICAXE PIC
VideoVideo
4141
PICAXE PIC
TipsTips• HF multi tool
• …works better if mounted to a bench• https://www.youtube.com/watch?v=x1TYueXHxgE
4242
PICAXE PIC
VideoVideo
4343
PICAXE PIC
Tip – HF Center PunchTip – HF Center Punch
• Accurately start holes when drilling
• Makes rivets, too!
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)
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
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
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
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
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
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!
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
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
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!
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
5555
PICAXE PIC
Arduino - First ProgramArduino - First Program
• Select board
• Select serial port
5656
PICAXE PIC
Arduino - First ProgramArduino - First Program
• Load “blink” from basic examples– File / Examples / 01.Basics / Blink
5757
PICAXE PIC
Arduino - First ProgramArduino - First Program
• Comments– //– /* */
• Variable definitions
• setup • loop
5858
PICAXE PIC
Arduino - First ProgramArduino - First Program
• Upload to Arduino & observe• Modify to blink faster, slower, non-symmetrically
5959
PICAXE PIC
Arduino - First ProgramArduino - First Program
– Add 2nd LED – modify for
crossing signal
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
6161
PICAXE PIC
Arduino - First ProgramArduino - First Program
• Modify for ditch lights
6262
PICAXE PIC
Arduino - First ProgramArduino - First Program
• Modify to remove “bug”while flashing
6363
PICAXE PIC
Arduino - First ProgramArduino - First Program
• Add a “pot” to vary the speed
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
6565
PICAXE PIC
Arduino Projects:Arduino Projects:• DCC
decoder • Used as an
accessory decoder to operate animations & sounds
• From MRH magazine
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
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
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
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!
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?)
7171
PICAXE PIC
Arduino Projects:Arduino Projects:• Add an Arduino and each button press
selects either– The next file– A random file
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
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:
7474
PICAXE PIC
Your Ideas?Your Ideas?
• Questions?
7575
PICAXE PIC
7676
PICAXE PIC
Servo Extension CablesServo Extension Cables
• Need to connect 3 wire device?
• Available in many lengths up to 1 meter
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
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!
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
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
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
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
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!
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:
9090
PICAXE PIC
Your Ideas?Your Ideas?
• Questions?
9191
PICAXE PIC
9292
PICAXE PIC