Presentation on theme: "PICAXEPIC 1 2013 East Coast Large Scale Train Show Dave Bodnar March 22, 2013 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets,"— Presentation transcript:
PICAXEPIC East Coast Large Scale Train Show Dave Bodnar March 22, 2013 York, PA Electronics, Microcontrollers & Trains Electronic Gizmos, Gadgets, Tips, Tricks & More! Whats New? This presentation is available on-line at: or Revised
PICAXEPIC 2 Objectives 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!
PICAXEPIC 3 Topics 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
PICAXEPIC 4 Hypothesis 1 We all have an interest in how things work and many of us have enough knowledge of basic electronics to know that something can be done… we just need a bit of help putting all of the parts together to make it happen! we just need a bit of help putting all of the parts together to make it happen!
PICAXEPIC 5 Hypothesis 2 We Already Know About & Have Experience With: Batteries & power supplies Track wiring & motors AC, DC, voltage, amperage & resistance LEDs & incandescent bulbs Series & parallel circuits Switches, relays & transistors Simple Programming
PICAXEPIC 6 Hypothesis 3 Inexpensive microcontrollers allow us to leverage the basic electronics and programming knowledge that we have so that we can do some amazing (and personally satisfying) things!
PICAXEPIC 7 Highly Recommended: PICAXE Designed in the UK for use in schools SUPERB support Free manuals, tutorials and software Active & helpful forums PICAXE manuals are super Several Books available on Amazon – Search for PICAXE YouTube videos & Instructables
PICAXEPIC 8 PICAXE Best choice in terms of: –Capability –Ease of use –Cost –Support Many PICAXE articles at Large Scale Online &
PICAXEPIC 9 PICAXE Basics Not spending much time on a PICAXE introduction this year You can view my introductory PICAXE seminars on YouTube davebodnar.com or trainelectronics.comdavebodnar.com trainelectronics.com Under Presentations Or search YouTube for Bodnar PICAXE
PICAXEPIC 10 Garden Railways PICAXE Article April 2013 Issue pages Contains a detailed introduction to the PICAXE and several projects
PICAXEPIC 11 Garden Railways PICAXE Article Shows how to build: Single LED Lighthouse Single LED Mars Light Morse Code Beacon All using the same circuit
PICAXEPIC 12 PICAXE - What You Need 1.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 AA cells = 4.5 volts
PICAXEPIC 13Tip USB to Serial Adapter Spark Fun sells PICAXE cable – part # PGM for about $26.00 Or Spark Funs USB to Serial – part # PGM for about $15.00 Details on use at
PICAXEPIC 14Tip USB to Serial Adapter #2 Modern Device sells a similar board for about $14.00 Details on use at com
PICAXEPIC 15 Garden Railways PICAXE Article Single LED Lighthouse #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 = 150 'set constant Dlay to 150 Start: For Loopie = 0 to 100 step 1 '100 steps from off to bright brightness=255-loopie pwmout c.2, brightness, loopie 'use PWM to brighten the LED pause Dlay 'pause a bit next loopie 'get the next item in for/next pwmout c.2, 255,1023:pause 1000 'flash to full bright briefly for loopie = 100 to 0 step -1 'repeat above backwards brightness=255-loopie pwmout c.2, brightness,loopie pause Dlay next loopie pause 2000 'pause a bit with LED off goto start 'do it again!
PICAXEPIC 16 Garden Railways PICAXE 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
PICAXEPIC 18 Garden Railways PICAXE Article More to come…
PICAXEPIC 19 New PICAXE Chip 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
PICAXEPIC 20 New 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!
PICAXEPIC 21 PICAXE 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
PICAXEPIC 22 Speed Controller Parts: –PICAXE 18M2 or 18M2+ –Single chip H-Bridge –IR Receiver chip –18+ volt power supply
PICAXEPIC 23 Speed 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
PICAXEPIC 24 Speed 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!)
PICAXEPIC 25 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
PICAXEPIC 26 IR Control Built into PICAXE PICAXE program to display IR codes Symbol IRSense = b.2'pin 8 Symbol InfraRED= b12 #TERMINAL 4800 IRTEST: Irin [50, IRTEST],IrSense, InfraRED SERTXD("InfraRED Code = ",#InfraRED,13,10) GOTO IRTEST
PICAXEPIC 27 LED Test Routine Symbol Direction1 = b.5 'pin 11 Symbol Direction2 = b.0 'pin 6 Symbol IRSense = b.2 'pin 8 Symbol LEDBlue = c.7 'pin 16 Symbol LEDAmber = c.6 'pin 15 Symbol Motor = b.3 'pin 9 LEDTest: HIGH LEDAmber:PAUSE 500 HIGH LEDBlue:PAUSE 500 HIGH Motor:PAUSE 500 LOW IRSense:PAUSE 500 HIGH Direction1:PAUSE 500 HIGH Direction2:PAUSE 500 LOW LEDAmber LOW LEDBlue LOW Direction1 LOW Direction2 HIGH IRSense LOW Motor PAUSE 1000 GOTO LEDTest
PICAXEPIC 28 Motor Control Routine SYMBOL Direction1 = b.0 'pin 6 SYMBOL Direction2 = b.1 'pin 7 SYMBOL Motor = b.3 'pin 9 SYMBOL Loop1 = b27 SYMBOL ADRate = b16 SYMBOL MinSpeed = w3 SYMBOL Loopie0 = W1 SYMBOL SetSpeed = w2 Symbol Relay = c.0 'pin 17 SetSpeed=0 PWMOUT motor,50,500 '150 ; set PWM duty HIGH Direction1:LOW Direction2 PWMDUTY motor, SetSpeed setspeed=200 ADRate=100 GOSUB Accel Cruise: SERTXD("Pausing 5000 millisecods",13,10) PAUSE 5000 GOSUB revers GOTO Cruise Revers: toggle relay GOSUB decel SERTXD("Pausing 1000 millisecods",13,10) PAUSE 1000 TOGGLE direction1:TOGGLE direction2 GOSUB accel RETURN Accel: FOR loopie0= MinSpeed TO SetSpeed STEP 5 SERTXD(#loopie0," ") PWMDUTY motor,loopie0 ; set pwm duty PAUSE adrate NEXT loopie0 SERTXD(13,10) RETURN Decel: FOR loopie0= SetSpeed TO MinSpeed STEP -5 SERTXD(#loopie0," ") PWMDUTY motor, loopie0 PAUSE adrate NEXT loopie0 SERTXD(13,10) RETURN
PICAXEPIC 29 Control Options Remote Control Buttons –Channel UP - Increase speed –Channel DOWN - Decrease speed –Volume UP - Change direction to forward (if not already going forward) –Volume DOWN - Change direction to backwards (if not already going backwards) –MENU - stop the train remembering the current speed - press MENU again to restart at the same speed and in the same direction
PICAXEPIC 30 Additional Control Options –Press the RETURN button to change settings 1.Change Maximum Speed 2.Change Minimum Speed 3.Change Run Time 4.Change Acceleration / Deceleration rate
PICAXEPIC 31 Point-to-Point Setup OPTIONAL: Reset RETURN / V-Chip / EXIT Set Min speed then hit MUTE Set Max speed Set run time - RETURN / 3 / three digit time in seconds POWER to set deceleration point
PICAXEPIC 32 Train Recorder The newest version automatically records (at a rate of 50 recordings per second) a trains movements so that you can play them back over & over A rather unusual but very cool thing to do! Makes station-stops and complex routes a snap!
PICAXEPIC 33 Train Recorder Additional Components: –A memory chip to store activity (can store up to 20 minutes of train movements!) –A potentiometer to control speed & direction –Optional: A relay to control a stop block that keeps things in sync
PICAXEPIC 34 More POWER! The L298N supplies up to 3 amps with a heat sink This is enough for most of us but not all! There is an easy add-on that can handle 12 amps continuously and peaks of up to 30 amps! Voltage can be as high as 24 volts
PICAXEPIC 35 Other Uses The same controller can be used to automate and control anything that has a DC motor Animations –circus rides –cranes, trucks, cars –inclines –trams
PICAXEPIC 36 I was blind and now I see… Volt / Ohm Meters are right up there with indoor plumbing. Less than $10.00 Sometimes free Use two to give both volts & amps See Trainelectronics.com for details
PICAXEPIC 37 Animation Animation adds fun and excitement to your layout Moving things is easy with the PICAXE as it knows how to talk to model airplane servos
PICAXEPIC 38 Servos A servo is made up of a small motor and set of gears A string of control pulses precisely position the servos arm They are commonly used to operate control surfaces on model planes, boats and cars
PICAXEPIC 39 Animation By sending precisely timed pulses the PICAXE can set the servos arm to a specific position and hold it there.
PICAXEPIC 40 Servos The PICAXE can talk directly to a servo SYMBOL Temp = b0 SYMBOL ServoPin = c.2 pin 5 Start: FOR Temp = 225 TO 75 Step -1 sertxd (#temp," ") SERVO ServoPin, Temp PAUSE 15 NEXT Temp sertxd (13,10) FOR Temp=75 TO 225 Step 1 sertxd (#temp," ") SERVO ServoPin, Temp PAUSE 15 NEXT Temp sertxd (13,10) GOTO Start:
PICAXEPIC 41 Animation Only three wires go to the servo –Two for power and 1 for control pulses –The SERVO command is built into the PICAXE
PICAXEPIC 42 Servo Examples Elephant
PICAXEPIC 43 Servo Examples Outhouse
PICAXEPIC 44 Servo Examples Water Spout
PICAXEPIC 45 Servo Examples Prairie Dogs
PICAXEPIC 46 Servo Recorder For more complex servo movements the train recorder has been modified to operate one or two servos Ideal for –dual axis searchlight –dual servo bear animation
PICAXEPIC 47 Servo Examples Scanning Spotlight Uses bright LED And two Servos
PICAXEPIC 48 Servo Examples Bears –Two servos on large bear –One each on others
PICAXEPIC 50 Servo Examples Childrens Hospital Searchlight –Rotates back & forth via servo –Only works when train is running and lights are down
PICAXEPIC 51 Servos Come in Many Sizes Standard 9 gram 4.3 gram 1.5 gram
PICAXEPIC 52 Servos 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
PICAXEPIC 53 Servos with the Revolution Auxiliary 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
PICAXEPIC 54 Where do project ideas come from? I recently received an 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
PICAXEPIC 55 LED 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 LEDs Hours /w 2000 mAh cells one two three four five209020
PICAXEPIC 56 LED 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
PICAXEPIC 57 LED Coach Lights Brightness and power consumption can be controlled by a resistor wired in series with the LEDs (these resistors are 100 )
PICAXEPIC 58 LED Coach Lights A custom circuit board was designed And sent off for manufacture
PICAXEPIC 59 LED Coach Lights The circuit board –Is about 13 long –can accommodate up to 25 LEDs a latching reed switch current limiting resistor
PICAXEPIC 60 LED 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
PICAXEPIC 61 LED Coach Lights with Super Caps! Super Caps can keep lights going for minutes after the power is removed
PICAXEPIC 62 LED 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
PICAXEPIC 63 Tip – Inexpensive RC Relays Keychain transmitter and SPDT relay for less than $7.00 Switch-200M_p htmlhttp://www.tmart.com/12V-10A-Single-Channel-Wireless-Remote-Control- Switch-200M_p html
PICAXEPIC 64 Crossing Signal Controller (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…
PICAXEPIC 65 Crossing Signal Controller 0000 Flash on/off every 1/2 second as long as power is on - triggers & pots are not used 0011 Flash on/off at a rate determined by Pot #1 as long as power is on - triggers are not used 0102Flash on/off at a rate determined by Pot #1 as long as Trigger 1 is on 0113 Flash on/off at a rate determined by Pot #1 - starts when Trigger 1 or 2 is hit, stops when the other Trigger is hit 1004 Flash 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 1015Ditch lights at a rate determined by Pot #1 as long as Trigger 1 is on 1106 Ditch lights at a rate determined by Pot #1 - starts when Trigger 1 or two is hit, stops when the other Trigger is hit 1117 Ditch 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
PICAXEPIC 66 Crossing Signal Controller Modification for ditch light operation –Trigger 1 = both LEDs full on –Trigger goes into ditch light bright / dim –Both Triggers off = both LEDs full off –Length of ditch light operation set by pot
PICAXEPIC 67 Tip - Connectors We are always looking for ways to connect electrical devices together –For low current use: –Deal Extreme item # –$2.78 for 10 pair including shipping!
PICAXEPIC 68 Tip – Connectors Connectors: –High current for track and battery connections: Deal Extreme item # $5.70 for 10 pair including shipping!
PICAXEPIC 69 Tip – Connectors 4mm Bullet Connectors: –High current for track and battery connections: Search eBay for 4mm bullet Shown here before adding heat shrink tubing
PICAXEPIC 70 Tip – Connectors 3.5mm Bullet Connectors: –High current for track and battery connections: Search eBay for 3.5mm bullet Nice between cars
PICAXEPIC 71 Tip – Connectors 2mm Bullet Connectors: –High current for track and battery connections: Search eBay for 2mm bullet Thinner & longer than the others
PICAXEPIC 72 Tip – Connectors 3 wire Servo Cables have lots of uses Can be used as is for 3 conductors or back-to-back for 6 conductors
PICAXEPIC 73 Revolution with Sound The Revolution receiver now comes with sound –Generic Diesel –Generic Steam –More sounds are planned
PICAXEPIC 74 Revolution with Sound The kit includes –Receiver –NonPlug&Play board –Smoke controller –Trigger, link & speaker cables
PICAXEPIC 75 Revolution with Sound
PICAXEPIC 76 Revolution with Sound The receiver is just a bit higher than its predecessor There are four connections at the bottom of the board
PICAXEPIC 77 Revolution with Sound TRIG – trigger for whistle, bell or chuff G-FEDCBA – auxiliary output SET – link to transmitter SPEAKER
PICAXEPIC 78 Revolution with Sound The basic hookup is shown here
PICAXEPIC 79 Revolution 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
PICAXEPIC 80 Revolution with Sound Sounds are controlled by the keypad #1 on/off #2 bell #3 whistle #7 vol max #8 vol mid #9 vol min
PICAXEPIC 81 Revolution 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
PICAXEPIC 82 Revolution with Sound Speakers work better with a baffle They can be added to factory speakers, too
PICAXEPIC 83 Revolution with Sound Pros... 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
PICAXEPIC 84 Revolution 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
PICAXEPIC 85 Revolution 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.
PICAXEPIC 86 Tip – Connectors Multi pin cables with sockets Great for connecting cars to one another, tenders to locos, etc
PICAXEPIC 87 Tip – Connectors For the Revolution receiver –7 pin for auxiliary interface –3 pin for chuff, bell, whistle triggers –2 pin for speaker –http://www.trainelectronics.com/ART5700TrainEngineerRevolution/Connectors/index.htm
PICAXEPIC 88 Tip – Tiny Motor Gear head motor a bit larger than a penny Surprisingly high torque item # http://www.suntekstore.com Less than $6.00 shipped Ideal for many animations
PICAXEPIC 89 Tip – Dubro Collars Ideal for connecting to motor shafts & to join piano wire for servos
PICAXEPIC 90 Mars Light The new version uses the eight pin connector / cable to join the 7 LEDs to the circuit board Makes installation much easier
PICAXEPIC 91 Tip – 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 $ $2.00 shipping
PICAXEPIC 92 Tip – Tiny Volt Meter Makes a nice track voltage tester Use a 10 watt / 12 volt bulb as a load
PICAXEPIC 93 Tip - 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 (dont forget the 40% off coupon!)
PICAXEPIC 94 Tip – CA Accelerator Most of us have used cyanoacrylic glue (super glue) But have you also used CA accelerator which dries CA in seconds?
PICAXEPIC 95 Tip - Soldering A good iron makes you a better solderer! –MPJA.com –Item #ZD 929C –$46.95 –Digital temperature readout –Replacement handle assembly $6.95
PICAXEPIC 96 Tip - Soldering A clean tip makes all the difference. Item $6.03
PICAXEPIC 97 Tip – Measure Grade Digital Gauges from –Micro-Mark –and… Harbor Freight
PICAXEPIC 98 Tip Plumbers Putty to hold for Soldering I find Plumbers Putty to be ideal for holding parts while I solder them Easy to remove and reasonably inert
PICAXEPIC 99 Tip Meter with Buzzer to test Continuity A meter with an audible continuity tester is worth its weight in gold! Least expensive one that I use is from Harbor Freight – part # or part # (a bit more $$ but has auto-off)
PICAXEPIC 100 Tip Salvage 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!
PICAXEPIC 101 Tip Testing 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
PICAXEPIC 102 Tip Rubber 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!
PICAXEPIC 103 Tip - 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
PICAXEPIC 104 Relays with the Revolution Auxiliary Port The Revolutions 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
PICAXEPIC 105 Relays with the Revolution Auxiliary Port Details at Trainelectronics.com
PICAXEPIC 106 Animation
PICAXEPIC 107 Its more fun to make it yourself than to buy it ready to go! "I am always doing that which I cannot do, in order that I may learn how to do it." Pablo Picasso Remember: