Presentation is loading. Please wait.

Presentation is loading. Please wait.

2013 NMRA Jamboree Dave Bodnar April 27, 2013

Similar presentations


Presentation on theme: "2013 NMRA Jamboree Dave Bodnar April 27, 2013"— Presentation transcript:

1 2013 NMRA Jamboree Dave Bodnar April 27, 2013
Unique Electronic Devices, Animations and Controls That You Can Make Plus Gizmos, Gadgets, Tips & Tricks That You Can Use to Improve Your Railroad Dave Bodnar April 27, 2013 Set up on table at start: Mars light, light house & Morse code on foam – should run from one battery or power supply This presentation is available on-line at: or Revised

2 Introduction This is my fourth Jamboree presentation
Our focus today is on animation, especially using light and movement Most projects are operated by PICAXE microcontrollers, a device that we have covered in each of the other talks

3 Animation with a Single LED
Used in an introductory article in the current issue of Garden Railways Magazine For more information on PICAXE see YouTube video links on web page

4 PICAXE - What Is It? A small microcontroller (is that redundant?) that can be programmed to do many tasks An device that is so inexpensive that it can be dedicated to a single task A device that is programmed from a PC with free software A device that is programmed in the BASIC programming language Show cables (mouse, USB & DB-9) #5 ok PHANDERSON.COM has solderless development kit for around $20.00 (+/- depending on cable / psupply) Show & pass around programming cable – can also be made from DB9 (from Hosfelt) and old computer wires – if Internet available go to PICAXE.com and/or PHAnderson.com

5 PICAXE - What You Need Computer with
serial port or … USB to serial adapter or … USB programming cable Windows computer running free PICAXE software (Mac & Linux, too) Power source AA cells = 4.5 volts Show cables (mouse, USB & DB-9) #5 ok PHANDERSON.COM has solderless development kit for around $20.00 (+/- depending on cable / psupply) Show & pass around programming cable – can also be made from DB9 (from Hosfelt) and old computer wires – if Internet available go to PICAXE.com and/or PHAnderson.com

6 Tip USB to Serial Adapter
Spark Fun sells PICAXE cable – part # PGM for about $26.00 Or Spark Fun’s USB to Serial – part # PGM for about $15.00 Details on use at Show cables (mouse, USB & DB-9) #5 ok PHANDERSON.COM has solderless development kit for around $20.00 (+/- depending on cable / psupply) Show & pass around programming cable – can also be made from DB9 (from Hosfelt) and old computer wires – if Internet available go to PICAXE.com and/or PHAnderson.com

7 Tip USB to Serial Adapter #2
Modern Devices sells a similar board for about $14.00 Details on use at Show cables (mouse, USB & DB-9) #5 ok PHANDERSON.COM has solderless development kit for around $20.00 (+/- depending on cable / psupply) Show & pass around programming cable – can also be made from DB9 (from Hosfelt) and old computer wires – if Internet available go to PICAXE.com and/or PHAnderson.com

8 Garden Railways PICAXE Article
April 2013 Issue pages 54-59 Contains a detailed introduction to the PICAXE and three single LED projects

9 The Projects All Use the Same Hardware
PICAXE 4-5 volt battery One LED and one current limiting resistor Two resistors for programming

10 Can be Built on a Solderless Prototype Board

11 On a Drilled Prototype Board

12 Or on a Custom Board

13 Animation with a Single LED
Symbol LED1 = c.2 'pin 5 Symbol Dlay = 12 top: high led1 pause Dlay low led1 pause 100 pause 400 pause 1000 goto top: School Bus Strobe

14 Animation with a Single LED
Mars Light 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 pwmout c.2, brightness,loopie sertxd (#loopie, " ") return #NO_DATA 'speeds up programming #PICAXE 08M 'identify the chip SETFREQ m 'speed it up to 32 MHz SYMBOL Loopie = b2 'label variable b2 as Loopie SYMBOL Brightness = b1 'label b1 as Brightness SYMBOL Dlay = 'set constant Dlay to 2 Start: Gosub ShortFlash 'do the shorter flash routine Gosub LongFlash 'do the longer flash routine GOTO Start: 'repeat 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 pwmout c.2, brightness,loopie return

15 Animation with a Single LED
Morse Code Beacon 137 lines of code Takes up about ½ of the 08M2’s memory! I found the code by searching Google for: PICAXE Morse code

16 Animation with a Single LED
SETFREQ m32 'speed it up to 32 MHz (8x normal) 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 pwmout c.2, brightness,loopie pause Dlay next loopie sertxd ("pausing") pwmout c.2,255,0 low c.2 pause 'pause a bit with LED off sertxd ("pausing DONE") goto start 'do it again! Lighthouse – more than just on & off!

17 Animation with a Single LED
Fred (Flashing Rear End Device) You could usa a PICAXE but DON’T It is much simpler & less expensive to use a flashing LED! Search eBay for: flashing LED

18 Animation with Multiple LEDs
Crossing Signal with 2 LEDs The LEDs flash “back & forth” Starts when power is applied Fixed ½ second rate

19 Flashing Crossing Lights
We will use the 14 pin PICAXE 14M2 Same as 08M but with more input and output pins About $1.00 more than the 08M Remember: Don’t use a 9 volt battery or 4 fresh 1.5 volt AA cells! 5.5 volts maximum! Detailed review of schematic – note pin 6 is “out1” and pin 5 is “out2” – note also that the 22k & 10K to ground are necessary on any board, programmable or not! Reinforce using 5 volts or less – NOT 9 VOLT BATTERY! Define Ground! Some don’t know what it is.

20 Flashing Crossing Lights

21 Custom Circuit Board for up to 6 LEDs
A custom multi-LED board was designed and fabricated Supports: up to 6 LEDs two trigger switches two potentiometers option for power transistors for each LED

22 Crossing Signal Software
#NO_DATA 'speeds up programming a bit #TERMINAL ' open terminal at speed 4800 baud after programming Symbol LED1 = b.2 'pin 11 Symbol LED2 = b.4 'pin 9 sertxd (13,10,"Simple Crossing Signal - d. bodnar ") ' show name on terminal Initialize: ' do this only once High LED1 ' LED1 is ON Low LED2 ' LED2 is OFF Start: ' LABEL so the GOTO knows where to go! Toggle LED1 ' if LED1 is on turn it off, if off turn on Toggle LED2 ' same for LED2 pause 500 ' pause for 1/2 second (500/1000ths) goto start: ' go back to Start and do it again

23 Crossing Signal with Variable Rate
A Potentiometer can be read by the PICAXE Its setting can be used to change the speed of flashing or how long it flashes or any other variable that changes its behavior

24 Crossing Signal with Variable Rate
When the pot is rotated to one extreme the wiper on the pot shows 5 volts At the other extreme it is 0 volts With proportional voltages in between This translates to a value between in the PICAXE with the READADC command

25 Crossing Signal with Variable Rate
Symbol LED1 = b.2 'pin 11 Symbol LED2 = b.4 'pin 9 Symbol Pot1 = pinb.1 'pin 12 Symbol PotValue = b2 Symbol Dlay =w3 sertxd (13,10,"Simple Crossing Signal - d. bodnar ") Initialize: ' do this only once High LED1 ' LED1 is ON Low LED2 ' LED2 is OFF Start: ' LABEL so the GOTO knows where to go! readadc b.1, PotValue sertxd ("pot=",#PotValue,13,10) Toggle LED1 ' if LED1 is on turn it off, if off turn on Toggle LED2 ' same for LED2 Dlay=PotValue*2 ‘double the pot reading pause Dlay ' pause based on pot reading goto start: ' go back to Start and do it again Pause between flashes is based on Pot reading

26 Crossing Signal with Trigger
To be really useful a crossing signal needs to be started by a switch of some sort This can be a pushbutton or a reed switch and magnet

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

28 Tip Harbor Freight sells small rare earth magnets Item number 67488
10 for $2.99

29 Flashing Crossing Lights
Hardware modification for button or reed switch activation: Add switch & resistor to solderless proto board Discuss need for 10K pull up resistor to give positive shift from + 5 to ground on button push & to protect against dead short if it were not there

30 Flashing Crossing Lights
Software modification for button: ‘ORIGINAL CROSSING PROGRAM – CONTINUOUS BLINKING Symbol LED1 = b.2 'pin 11 Symbol LED2 = b.4 'pin 9 Initialize: ' do this only once High LED1 ' LED1 is ON Low LED2 ' LED2 is OFF Start: ' LABEL so the GOTO knows where to go! Toggle LED1 ' if LED1 is on turn it off, if off turn on Toggle LED2 ' same for LED2 pause 500 ' pause for 1/2 second (500/1000ths) goto start: ' go back to Start and do it again Symbol LED1 = b.2 'pin 11 Symbol LED2 = b.4 'pin 9 Symbol Trigger1 = pinc.3 'pin 4 StayHere: if Trigger1 = 1 then StayHere: Initialize: ' Set up LEDs for flashing High LED1 ' LED1 is ON Low LED2 ' LED2 is OFF For B1 = 1 to 30 'repeat things between here and Next B1 30 times (each cycle takes 1/2 second) Toggle LED1 ' if LED1 is on turn it off, if off turn on Toggle LED2 ' same for LED2 pause 500 ' pause for 1/2 second (500/1000ths) Next B1 'go back and get the next B1 until it equals 30 Low LED1 'turn LED1 off Low LED2 'turn LED2 off goto StayHere: ' go back to Initialize and do it again Add switch & resistor to solderless proto board Discuss need for 10K pull up resistor to give positive shift from + 5 to ground on button push & to protect against dead short if it were not there

31 Two Buttons for Crossing
Add a second reed switch so that the light goes on when it passes one switch… …and goes off when it hits the other. Sensor 2 Sensor 1

32 Two Buttons for Crossing
Software must remember which switch is hit first CheckButtons: b1=0:b2=0 ‘zero variables that store which button came first if Trigger1 = 1 and Trigger2 = 1 then CheckButtons ' no hit if Trigger1 = 0 then b1=1 'save which button hit first goto flash 'skip ahead and start blinking endif b2=1 'save which button hit first Flash: high LED1 'LED 1 on low LED2 'LED 2 off FlashAgain: for w3= 1 to 100 'check for button before changing lights if b2=1 and Trigger1=0 then PauseBeforeStart if b1=1 and Trigger2=0 then PauseBeforeStart next w3 toggle LED1:toggle LED2 ‘switch lights goto FlashAgain: 'continue checking buttons Symbol LED1 = b.2 Symbol LED2 = b.4 Symbol Trigger2 = pinc.3 Symbol Trigger1 = pinc.4 PauseBeforeStart: low LED1 low LED2 pause 1000 Show crossing demo – need batteries & sensors #7

33 Using High Power LEDs and Bulbs
Adding a transistor switch to each output allows it to control much higher power devices High output LEDs Incandescent bulbs Motors

34 Emergency Light Flashers
Symbol LED1 = c.2 Symbol LED2 = c.0 Symbol Dlay = 4 Symbol Dlay2= 100 top: for b1=1 to 5 high led1 pause Dlay low led1 pause 70 next b1 pause Dlay2 high led2 low led2 goto top: Red / Blue / White on police car Two LED version

35 Emergency Light Flashers
Or six LED version pause Dlay2 for b1=1 to 5 high led3 pause Dlay low led3 high led5 low led5 pause Dlay3 next b1 high led2 low led2 high led4 low led4 goto top: Symbol LED1 = b.2 'pin 11 Symbol LED2 = b.4 'pin 9 Symbol LED3 = b.5 'pin 8 Symbol LED4 = c.0 'pin 7 Symbol LED5 = c.1 'pin 6 Symbol LED6 = c.2 'pin 5 Symbol Dlay = 8 Symbol Dlay2= 100 Symbol Dlay3= 50 top: for b1=1 to 5 high led1 pause Dlay low led1 high led6 low led6 pause Dlay3 next b1

36 Six LEDs Can Make a Traffic Light
A pair of traffic lights can be controlled with the six LED circuit board Each light can be addressed individually The two triggers can be used cycle the lights The pots can be used to vary cycle time or “yellow on time”

37 Animation …can take many forms
…can add interest and variety to your layout …surprises visitors …is great fun! Servo demo board with power supply #14a (foam) #14b (spout)

38 Animation Moving things is easy with the PICAXE as it knows how to talk to model airplane servos

39 Servos A servo is made up of a small motor and set of gears
A string of control pulses precisely position the servo’s arm They are commonly used to operate control surfaces on model planes, boats and cars

40 Animation By sending precisely timed pulses the PICAXE can set the servo’s arm to a specific position and hold it there.

41 The PICAXE can talk directly to a servo
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 GOTO Start:

42 Animation Only three wires go to the servo
Two for power and 1 for control pulses The SERVO command is built into the PICAXE

43 Tip – Tiny Motor Gear head motor a bit larger than a penny
Surprisingly high torque item # Less than $6.00 shipped Ideal for many animations

44 Tip – Dubro Collars Ideal for connecting to motor shafts & to join piano wire for servos

45 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 Pass connectors around

46 Tip – Tiny Volt Meter Makes a nice track voltage tester
Use a 10 watt / 12 volt bulb as a load Pass connectors around

47 Servo Examples Elephant

48 Servo Examples Outhouse

49 Servo Examples Water Spout

50 Servo Examples Prairie Dogs

51 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

52 Servo Examples Scanning Spotlight Uses bright LED And two Servos

53 Servo Examples Bears Two servos on large bear One each on others

54 Servo Examples Eggliner eyes blink and move

55 Servo Examples Children’s Hospital Searchlight
Rotates back & forth via servo Only works when train is running and lights are down Light sensor Power sensor

56 Servos Come in Many Sizes
Standard 9 gram 4.3 gram 1.5 gram

57 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

58 Train Recorder The newest version automatically records (at a rate of 50 recordings per second) a train’s 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!

59 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”

60 It’s more fun to make it yourself than to buy it ready to go!
Remember: "I am always doing that which I cannot do, in order that I may learn how to do it." Pablo Picasso About 1:21 to end

61 Your Ideas? Questions? 2:10

62 2:43

63 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 (don’t forget the 40% off coupon!) Pass connectors around

64 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


Download ppt "2013 NMRA Jamboree Dave Bodnar April 27, 2013"

Similar presentations


Ads by Google