|
1
|
- Microprocessor Controlled Engines
It is much easier than you may think
|
|
2
|
- Introduce the basics of programming and using microprocessors to control
lights, motors and other devices
- Explore the use of simple microprocessor based controllers in garden
railway applications
- Allow time for discussion and questions
|
|
3
|
- BASIC Stamp www.parallax.com
- PICAXE microcontrollers are exciting, low-cost, re-programmable chips
that can be used as low-cost 'brains' in many kinds of electronic
projects.
- www.picaxe.com
|
|
4
|
- PICAXE 08M is an 8 pin integrated circuit that can be used to control
lights, sound boards, motors and other devices
- It is also able to sense
- Touch
- Light
- Motion
- other things in its environment
|
|
5
|
- The key to its simplicity is the capability to program it in BASIC
rather than a more complex and difficult to learn language
- All software and documentation are free
- Extensive support and sample programs are available
- Chips range in price from less than $4.00 to around $20.00
- Even the simplest chip is VERY capable!
|
|
6
|
- First Project: Flashing crossing
lights
- Objectives:
- Flash two red LEDs alternately
- Pause and repeat
- Battery power
- Alter timing from software
|
|
7
|
- 7404 based LED flasher circuit
|
|
8
|
|
|
9
|
- Other items needed:
- Any PC with serial port (or USB to serial adapter)
- programming cable
- needs only 3 wires
- can use old mouse cable
- Soldering iron & wire cutters
- Software from www.picaxe.com
|
|
10
|
|
|
11
|
|
|
12
|
|
|
13
|
|
|
14
|
- Software modified to flash 10 seconds and turn off for 10 seconds
|
|
15
|
- Hardware modification for button or reed switch activation:
|
|
16
|
- Software modified to flash 5 seconds on button push
|
|
17
|
|
|
18
|
- Design objectives
- Gradually brighten a bulb or LED to near full brightness
- Flash to full brightness briefly
- Gradually dim till off
- Delay for a set time
- Repeat
- Provide for LED or halogen lights
|
|
19
|
|
|
20
|
- Parts
- Adds one resistor and one transistor to the flasher circuit
- The most significant changes are to the software
|
|
21
|
|
|
22
|
|
|
23
|
|
|
24
|
- Halogen bulb circuit diagram
- adds a voltage regulator and larger transistor
|
|
25
|
- Eggliner prototype with commercial detection unit
|
|
26
|
- Areas for enhancement
- 9+ volts needed to operate sensor
- Relay gave full on or full stop
- Size makes concealment difficult
- Rapid oscillation between on / off
- Option to put beacon on car in front
|
|
27
|
- Using PICAXE to build on and enhance Ralphs idea
- IR LED flasher (38 kHz)
- IR sensor high when it sees 38 kHz
- Relay / resistor for speed control
- Timed delay to avoid choppy movement
- Addition of a beacon on forward train to extend distance (FRED)
|
|
28
|
|
|
29
|
- IR sensor high when it sees 38 kHz
|
|
30
|
- Relay / resistor for speed control
|
|
31
|
- Picaxe sends out pulses, detects them and controls the motor in response
to what is sees
- Prototype:
|
|
32
|
|
|
33
|
|
|
34
|
- Objectives:
- Detect passing train with 38 KHz pulsed IR sensor
- Lower crossing gate with servo
- Flash crossing lights
- Sound crossing bell
- Continue till 10 seconds passes without detection
|
|
35
|
- Hardware:
- Picaxe for control
- 38 KHz IR transmitter and detector
- Inexpensive bell module
- Amplifier and speaker
- Radio control airplane servo
- LED lights for crossing
- Battery or solar power
|
|
36
|
|
|
37
|
- ' 0=38 kHz pulse chip
- ' 1=LED
- ' 2=LED
- ' 3=input from IR receiver
- ' 4=Servo control
- symbol flashdelay = 15
- init: high 0: low 1: low 2
- servo 4, 100
- start: b3=0
- low 0 '38kHz on
- pause 3
- if pin3=0 then train:
- high 0
- pause 100
- goto start:
- train: high 0
- high 1: low 2
- for b1=100 to 190 step 1
- pause 15
- b2=b2+1
- if b2< flashdelay then skip1:
- toggle 1: toggle 2
- b2=0
- skip1:
- servo 4, b1
- next b1
- loop1: b3=b3+1
- pause 250
- toggle 1: toggle 2
- low 0
- pause 3
- if pin3 = 0 then loop1:
- high 0
- pause 250
- low 0
- pause 3
- if pin3 = 0 then loop1:
- if b3<9 then loop1: ' only
stop if no IR for 9 loops
- high 0
- for b1=190 to 100 step -1
- pause 15
- b2=b2+1
- if b2< flashdelay then skip2:
- toggle 1: toggle 2
- b2=0
- skip2:
- servo 4, b1
- next b1
- goto init:
|
|
38
|
- Objectives:
- Complete speed and direction control
- Start gradually and accelerate smoothly to top speed
- Detect magnet on track (reed switch)
- Repeat
|
|
39
|
- Motor control is accomplished with an LM293D H-Bridge chip
- The LM293D can provide up to 1 amp of current
- Three pins on the LM293 will be connected to the PICAXE. Two are used for direction control
and the third, called enable, for speed.
|
|
40
|
|
|
41
|
|
|
42
|
|
|
43
|
|