1 PICAXE PIC 2013 East Coast 2013 East Coast Large Scale Train Show Large Scale Train Show Dave Bodnar Dave Bodnar March 22, 2013 March 22, 2013 York, PA York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets, Tips, Tricks & More! What’s New? This presentation is available on-line at: www.trainelectronics.c om or www.davebodnar.com Revised 03-22-2013
98
Embed
PICAXEPIC 1 2013 East Coast Large Scale Train Show Dave Bodnar March 22, 2013 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
11
PICAXE PIC
2013 East Coast2013 East CoastLarge Scale Train ShowLarge Scale Train Show
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?• New PICAXE chip• A NEW PICAXE project• A NEW LED lighting project• Revolution /w Sound Overview• Lots of Animation ideas• Easy Uncoupling with Revo or Small Remote• Tips, Tricks, Tools• New & improved gizmos & gadgets
99
PICAXE PIC
PICAXE BasicsPICAXE Basics
• Not spending much time on a PICAXE introduction this year
• You can view my introductory PICAXE seminars on YouTube • davebodnar.com or
trainelectronics.com • Under Presentations • Or search YouTube for “Bodnar PICAXE”
• Prior seminars focused on the PICAXE 08M - 8 pins – about $3.00 each
• A new 18 pin chip, the PICAXE 18M2 -about $5.00 and has much more capability– Faster– 15 pins for input & output– Much more memory– Low voltage operation (as low as 2 volts!)– Built in timer & multitasking
2020
PICAXE PIC
New PICAXE ProjectNew PICAXE Project
• This new project is to create a completely solid state track side or on-board speed controller…
• …that has a really cool trick up its sleeve…
• …that can be modified to supply up to 12 amps of power!
2121
PICAXE PIC
PICAXE Speed ControllerPICAXE Speed Controller
• Objectives:– Controls DC track power: speed & direction– Manages smooth acceleration / deceleration– Never changes direction when power is on– Controlled by inexpensive television IR remote
control– Can handle several amps
2222
PICAXE PIC
Speed ControllerSpeed Controller
• Parts:– PICAXE 18M2 or 18M2+– Single chip “H-Bridge”– IR Receiver chip– 18+ volt power supply
2323
PICAXE PIC
Speed ControllerSpeed Controller
• Many older circuits used a relay to reverse direction and a transistor to control speed
• This circuit uses a single L298N to do both jobs
2424
PICAXE PIC
Speed ControllerSpeed Controller• The first version of the controller operates
a simple track side layout using the IR remote control
• It can be used as a basic speed / direction controller
• …or it can be programmed to change direction based on time (easy point-to-point controller!)
2525
PICAXE PIC
How Do We Control the Controller?How Do We Control the Controller?• Speed and other settings can be modified
with a simple TV remote control
– Set min & max speed– Set rate of deceleration– Set time to wait at ends on point-to-point
& IR sensor
2626
PICAXE PIC
IR Control Built into PICAXEIR Control Built into PICAXE
• PICAXE program to display IR codesSymbol IRSense = b.2 'pin 8
Symbol InfraRED = b12
#TERMINAL 4800
IRTEST:
Irin [50, IRTEST],IrSense, InfraRED
SERTXD("InfraRED Code = ",#InfraRED,13,10)
GOTO IRTEST
2828
PICAXE PIC
Motor Control RoutineMotor Control RoutineSYMBOL Direction1 = b.0 'pin 6SYMBOL Direction2 = b.1 'pin 7SYMBOL Motor = b.3 'pin 9SYMBOL Loop1 = b27SYMBOL ADRate = b16SYMBOL MinSpeed = w3SYMBOL Loopie0 = W1SYMBOL SetSpeed = w2Symbol Relay = c.0 'pin 17SetSpeed=0PWMOUT motor,50,500 '150 ; set PWM dutyHIGH Direction1:LOW Direction2PWMDUTY motor, SetSpeed
– Rotates back & forth via servo– Only works when train is running and lights
are down
5151
PICAXE PIC
Servos Come in Many SizesServos Come in Many Sizes
• Standard
• 9 gram
• 4.3 gram
• 1.5 gram
5252
PICAXE PIC
ServosServos
• Coupler control– Servos can easily uncouple cars– Uses a simple PICAXE controller and some
type of radio control• RC can be Revolution receiver• Can be an inexpensive keychain transmitter & its
small receiver
5353
PICAXE PIC
Servos with the Revolution Servos with the Revolution Auxiliary PortAuxiliary Port
• Revolution users who want to operate live steam or boats need to be able to operate servos
• A custom interface allows you to use the six auxiliary buttons to move two servos
5454
PICAXE PIC
Where do project ideas come from?Where do project ideas come from?
• I recently received an email from a garden railroader who wanted to illuminate his passenger cars with battery powered LEDs
• After some discussion and experimentation a solution was designed that provides us with many options for using and powering LED lighting
5555
PICAXE PIC
LED Coach LightsLED Coach Lights
• Design called for battery operation and enough lights to illuminate g-scale coaches using only 3 to 5 volts
• First units were built on popsicle sticks to get layout and spacing right
• All of the LEDs are wired in parallel to keep operating voltage down
• Adding parallel resistors increases brightness & decreases run time
100 ohm resistors
Resistance (ohms)
mA to LEDsHours /w 2000 mAh cells
one 100 20 100
two 50 40 50
three 33.3 60 33.3
four 25 80 25
five 20 90 20
5656
PICAXE PIC
LED Coach LightsLED Coach Lights
• Lights can be turned on and off by a latching reed switch
• Pass a magnet over one end of the reed switch and the LEDs go on
• Pass it over the other end and they go off
• The reed switch can be placed against the top of the car so nothing is seen and no holes are drilled in the car
5858
PICAXE PIC
LED Coach LightsLED Coach Lights
• A custom circuit board was designed
• And sent off for manufacture
5959
PICAXE PIC
LED Coach LightsLED Coach Lights• The circuit board
– Is about 13” long
– can accommodate • up to 25 LEDs• a latching reed switch• current limiting resistor
6060
PICAXE PIC
LED Coach Lights Power OptionsLED Coach Lights Power Options
• A power board was added that accommodates track power – DC or DCC– Bridge rectifier – gives consistent polarity– Voltage regulator- gives consistent 5 volts– Capacitors – no flicker on dirty track
6161
PICAXE PIC
LED Coach Lights with Super Caps!LED Coach Lights with Super Caps!
• Super Caps can keep lights going for minutes after the power is removed
6262
PICAXE PIC
LED Coach Lights with DCC PowerLED Coach Lights with DCC Power
• The circuit was modified to put groups of LEDs in series to accommodate higher voltages such as from DCC
• The power supply board was modified as well
6363
PICAXE PIC
Tip – Inexpensive RC RelaysTip – Inexpensive RC Relays
• Keychain transmitter and SPDT relay for less than $7.00
Crossing Signal ControllerCrossing Signal Controller(Ditch Lights, too!)(Ditch Lights, too!)
• This project grew out of a question posed on an on-line forum that I moderate
• “I'm looking for a simple & cheap LED flashing circuit. For a single LED, and for alternating flashing LED's.An "onboard" circuit, possibly to operate off of 5vdc.”
• After some discussion I decided to build one …
• … and one thing led to another…
6565
PICAXE PIC
Crossing Signal Controller Crossing Signal Controller
000 0Flash on/off every 1/2 second as long as power is on - triggers &
pots are not used
001 1Flash on/off at a rate determined by Pot #1 as long as power is on -
triggers are not used
010 2 Flash on/off at a rate determined by Pot #1 as long as Trigger 1 is on
011 3Flash on/off at a rate determined by Pot #1 - starts when Trigger 1 or
2 is hit, stops when the other Trigger is hit
100 4Flash on/off at a rate determined by Pot #1 - starts when Trigger 1 or
Trigger 2 is hit, stops after a time determined by Pot #2
101 5 Ditch lights at a rate determined by Pot #1 as long as Trigger 1 is on
110 6Ditch lights at a rate determined by Pot #1 - starts when Trigger 1 or
two is hit, stops when the other Trigger is hit
111 7Ditch lights at a rate determined by Pot #1 - starts when Trigger 1 or
Trigger 2 is hit, stops after a time determined by Pot #2
6666
PICAXE PIC
Crossing Signal ControllerCrossing Signal Controller
• Modification for ditch light operation– Trigger 1 = both LEDs full on– Trigger 1 + 2 goes into ditch light bright / dim– Both Triggers off = both LEDs full off– Length of ditch light operation set by pot
6767
PICAXE PIC
Tip - ConnectorsTip - Connectors
We are always looking for ways to connect electrical devices together– For low current
use:– Deal Extreme
item # 15234– $2.78 for 10
pair includingshipping!
6868
PICAXE PIC
Tip – ConnectorsTip – Connectors
• Connectors:– High current for
track and batteryconnections:
• Deal Extreme item # 10788
• $5.70 for 10pair includingshipping!
6969
PICAXE PIC
Tip – ConnectorsTip – Connectors
• 4mm Bullet Connectors:– High current for track and battery connections:
• Search eBay for “4mm bullet”• Shown here before adding heat shrink tubing
7070
PICAXE PIC
Tip – ConnectorsTip – Connectors
• 3.5mm Bullet Connectors:– High current for track and battery connections:
• Search eBay for “3.5mm bullet”• Nice between cars
7171
PICAXE PIC
Tip – ConnectorsTip – Connectors
• 2mm Bullet Connectors:– High current for
track and battery connections:
• Search eBay for “2mm bullet”
• Thinner & longer than the others
7272
PICAXE PIC
Tip – ConnectorsTip – Connectors
• 3 wire Servo Cables have lots of uses
• Can be used as is for 3 conductors or back-to-back for 6 conductors
7373
PICAXE PIC
Revolution with SoundRevolution with Sound
• The Revolution receiver now comes with sound– Generic Diesel – Generic Steam– More sounds are planned
7474
PICAXE PIC
Revolution with SoundRevolution with Sound
• The kit includes– Receiver– NonPlug&Play board– Smoke controller– Trigger, link & speaker cables
7575
PICAXE PIC
Revolution with SoundRevolution with Sound
7676
PICAXE PIC
Revolution with SoundRevolution with Sound
• The receiver is just a bit higher than its predecessor
• There are four connections at the bottom of the board
7777
PICAXE PIC
Revolution with SoundRevolution with Sound• TRIG – trigger for whistle, bell or chuff
• G-FEDCBA – auxiliary output
• SET – link to transmitter
• SPEAKER
7878
PICAXE PIC
Revolution with SoundRevolution with Sound
• The basic hookup is shown here
7979
PICAXE PIC
Revolution with SoundRevolution with Sound
• Setup and linking is identical to that of the original with one exception– The first funtion key (#1 on keypad) must be
set to LATCH, not MOMENTARY
8080
PICAXE PIC
Revolution with SoundRevolution with Sound• Sounds are controlled by the keypad
• #1 on/off
• #2 bell
• #3 whistle
• #7 vol max
• #8 vol mid
• #9 vol min
8181
PICAXE PIC
Revolution with SoundRevolution with Sound
• External triggers (TRIG) can be activated by a reed switch and magnet– On the diesel unit #1 controls the whistle and
#2 controls the bell– On the steam #1 is the whistle while #2 can
be used for chuff – If a pulse is not detected on #2 then chuff is
tied to speed
8282
PICAXE PIC
Revolution with SoundRevolution with Sound• Speakers work better with a baffle
• They can be added to factory speakers, too
8383
PICAXE PIC
Revolution with SoundRevolution with SoundPros...• Cost for a remote control receiver & sound is very
reasonable • Compact size • Plug-n-Play on many locomotives • Simple operation with the existing transmitter (no
upgrade needed) • More than ample volume for outside use • Smoke board included • Two trigger inputs that can be used for chuff and other
sounds • Software upgradeable
8484
PICAXE PIC
Revolution with SoundRevolution with Sound& Cons...• Whistle sound is fixed at three long blasts • Sound quality could be better • Lowest volume setting may still be too loud • Diesel volume settings are quite a bit higher than
those of the steam unit • Only "generic" steam and diesel sounds
available at this time • Minimal documentation
8585
PICAXE PIC
Revolution with SoundRevolution with Sound
& Suggestions• Change to a volume scheme where button 7 increases the volume
in small increments, button 8 goes immediately to the middle volume and button 9 decreases the volume in small increments
• Allow end users to add additional sounds and modify existing sounds with a computer interface & software
• Make the small plugs for speaker, linking, triggers and auxiliary outputs available for purchase
• Change the whistle on both the diesel and steam units to a crossing signal (two longs, short, long)
• Change the bell sound so that it latches or only rings as long as the button is pressed. That is, press the button on the transmitter once to have it start and again to stop it if the button is set to latch. If it is set to momentary the bell would only ring when the button is held down.
8686
PICAXE PIC
Tip – ConnectorsTip – Connectors
• Multi pin cables with sockets
• Great for connecting cars to one another, tenders to locos, etc
8787
PICAXE PIC
Tip – ConnectorsTip – Connectors
• For the Revolution receiver– 7 pin for auxiliary interface– 3 pin for chuff, bell, whistle triggers– 2 pin for speaker
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
8989
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
9090
PICAXE PIC
Mars LightMars Light
• The new version uses the eight pin connector / cable to join the 7 LEDs to the circuit board
• Makes installation much easier
9191
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
9292
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
9393
PICAXE PIC
Tip - AdhesiveTip - 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!)
9595
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
9696
PICAXE PIC
Tip - SolderingTip - Soldering• A clean tip makes all the difference.• http://www.dealextreme.com
• Item 34154 • $6.03
9898
PICAXE PIC
TipTipPlumber’s Putty to hold for SolderingPlumber’s Putty to hold for Soldering
• I find Plumber’s Putty to be ideal for holding parts while I solder them
• Easy to remove and reasonably inert
100100
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!
101101
PICAXE PIC
TipTipTesting LEDsTesting LEDs
• Just about any LED can be tested with a 3 volt lithium battery 2032, 2025, etc
• Touch the anode (longer wire) to the + side of the battery
• Touch the cathode
(wire by notch in LED)
to the - side
White LEDs are OK for long use at 3+ volts, Red, Green, Amber are not
102102
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!
103103
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
104104
PICAXE PIC
Relays with the Revolution Auxiliary Relays with the Revolution Auxiliary PortPort
• The Revolution’s auxiliary port can control up to six devices
• It is primarily designed for sound and smoke unit activation but can also be used for relays and other devices
105105
PICAXE PIC
Relays with the Revolution Auxiliary Relays with the Revolution Auxiliary PortPort
• Details at Trainelectronics.com
106106
PICAXE PIC
AnimationAnimation
107107
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