Ignition Switch
Ignition Switch
Talking Electronics
Kits
IGNITION
SWITCH
Ordering Items ^
Home
See more projects using micros:
Elektor,EPE,Silicon Chip
Chapter 1
Introduction
12 FREE PIC Books
Chapter 2
We are not selling the program or the project. Go to Mike McLaren - Micro Application Consultants for details on these
things.
We are just teaching how to write a program PIC10F200 chips.
We have specialised in presenting programs for the simplest PIC chip: the PIC12F629 and the PIC10F200 is even smaller in
size and pin-count.
It has 3 in-out lines and one input-only line. It has 256 locations for your program and the 16 General Purpose Registers are
located between 10h and 1Fh.
It has only a 2-level stack and one 8-bit timer. All the other features are the same as the PIC12F629 and if you want to
produce something extremely small, this chip is the challenge for you.
Chapter 3
Start HERE with PIC12F629
Chapter 4
In Circuit Programming
Chapter 5
Changing Micros
The first IGNITION SWITCH program has been written by a very qualified programmer and shows what can be done with this
6 pin chip, but the program also contains a number of difficult-to-understand instructions, with some of them coming from a
list that only expert programmers understand.
The second IGNITION SWITCH program has been written by Colin Mitchell and is much easier to understand. if you study
them both, you will gain a lot of understanding on how to create a program.
Chapter 6
Delay Codes
blank template
Decimal to HEX
Coding Problems,
or
Program Problems, or
Writing Problems
Chapter 7
Start Here with PIC16F628
PIC16F628 Instructions
PIC16F628 Data (.pdf)
PICkit-2 programmer
Chapter 8
Other people's programs (to
help you write code)
Elmer 160 ( PIC lessons
on the web - by J McDonough)
Click HERE for new frame
Gooligum PIC Tutorials
Chapter 9
Converting PIC'508A code
to PIC12F629 code
PROJECTS:
+
+
+
+
+
+
+
+
Code Puzzle
http://www.talkingelectronics.com/te_interactive_index.html[21.1.2014 18:23:39]
+
+
+
+
+
+
+
+
+
+
+
+
Dial Alarm-2
Dual LED 5x7 Display
EEPROM Write
Fish Shop Timer
Inductance Meter
LED FX
Mini Frequency Counter
Sky Writer
Spin The Dice
Stroop Game
Talk To Me
Whistle Key Finder
.inc files
IC Prog 106B (Help file)
Instructions for PIC12F629
Library of Routines A-E
Library of Routines E-P
Library of Routines P-Z
MPASM
Multi Chip Programmer
PIC Chip List
PIC Programmer
Prototyping Boards
PIC10F200 - 6 pin SM
micro
PIC10F222 - DICE
PIC10F200 - Ignition/starter
__CONFIG
radix
GPIO,0
GPIO,1
0x10
temp
swnew
swold
mstmr
swtmr
;
;
;
;
;
endc
http://www.talkingelectronics.com/te_interactive_index.html[21.1.2014 18:23:39]
delay subsystem
fresh switch sample (b3 bit)
switch state latch (b3 bit)
msec timer
1 sec switch timer
p12F629.inc
PIC12F629 Data ( .pdf 4.9MB)
PICkit-2 programmer
PICkit-2 from Modtronix
6 pin - 5 pin adapter
Surface Mount PC Board
S/mount Diodes/Zeners
Surface Mount LEDs
Surface Mount Resistors
Surface Mount Transistors
Surface Mount Outlines
12-8-2009
; running flag
equ
equ
4
clock/4
inDlyCy macro
pCycles
local
loop
if pCycles > 3
movlw
pCycles/4
loop
movwf
temp
decfsz temp,W
goto
loop
endif
if pCycles%4 >= 2
goto
$+1
endif
if pCycles&1 == 1
nop
endif
endm
; 4-MHz clock
; cycles/usec multiplier
; 0..1027 cycle range
;
;
; 4-cycle loop
;
;
; 2 cycles
; 1 cycle
;******************************************************************
; main program
*
;******************************************************************
org
0x000
start
movwf
OSCCAL
;
movlw
b'10011110'
; 10011110
; 1-------, IOC off
; -0------, weak pullups ON
; --0-----, T0CS source Fosc/4
; ---1----, T0SE edge hi>lo
; ----1---, PSA prescale WDT
; -----110, PS prescaler 64
option
;
movlw
b'00001000'
;
tris
GPIO
; GP3 input, all others outputs
clrf
GPIO
; set output latches to '0'
clrf
swold
; clear switch state latch
clrf
swtmr
; clear 1 second timer
clrc
; clear Carry
newsample
call
comf
movwf
newpress
btfsc
btfsc
goto
bsf
call
movlw
movwf
newrelease
btfss
btfss
goto
bcf
bcf
movf
bz
clrf
movlw
xorwf
bcf
timeout
movf
bz
decfsz
goto
call
btfsc
btfsc
goto
bsf
bsf
goto
dbdelay
GPIO,W
swnew
swnew,3
swold,3
newrelease
swold,3
beep1
1000/32
swtmr
;
;
;
;
;
;
;
swnew.3 == 1 and
swold.3 == 0 (new press)?
no, branch, else
update swold.3 state latch
do a single 32-msec beep and
start 1 second timer
swnew,3
swold,3
timeout
swold,3
starter
swtmr,W
newsample
swtmr
b'00000001'
GPIO,F
running
;
;
;
;
;
;
;
;
;
;
;
swnew.3 == 0 and
swold.3 == 1 (new release)?
no, branch, else
update swold.3 state latch
turn GP1 'starter' off
timed out "long" press?
yes, branch (done), else
turn off 1 second timer
use GP0 pin mask to
toggle GP0 'ignition' output
clear "running" flag
swtmr,F
newsample
swtmr,F
newsample
beep2
ignition
running
newsample
running
starter
newsample
;
;
;
;
;
;
;
;
;
;
;
;******************************************************************
; subroutines This subroutine creates a beep as well as a delay
*
; The setc instruction determines if the speaker bit is toggled
*
;******************************************************************
beep2
call
beep1
; 32-msec delay with beep
call
dbdelay
; 32-msec delay
beep1
setc
; 32-msec delay with beep
dbdelay
movlw
32
; C = 0, delay, C = 1, beep
movwf
mstmr
; mstmr = 32 msecs
dbloop
http://www.talkingelectronics.com/te_interactive_index.html[21.1.2014 18:23:39]
movlw
b'00000100'
skpnc
xorwf
GPIO,F
inDlyCy(1000*usecs-6)
decfsz mstmr,F
goto
dbloop
clrc
retlw
0
;
;
;
;
;
;
;
;
;******************************************************************
end
The following program is much simpler. It has been made simple by allowing the micro to
advance down the program and loop a number of instructions, looking for a "switch press"
or "switch release."
ignition
starter
spkr
Sw
GPIO,0
GPIO,1
GPIO,2
GPIO,3
;
;
;
;
GP0
GP1
GP2
GP3
=
=
=
=
equ
equ
equ
10h
11h
12h
;******************************************************************
; main program
*
;******************************************************************
org
0x000
SetUp
movlw
b'10011110'
;10011110
;-0------, weak pullups ON
option
;
movlw
b'00001000'
;
tris
GPIO
;GP3 input, all others outputs
clrf
GPIO
;make outputs LOW
Start
call
btfsc
goto
call
bsf
call
bsf
Delay1
GPIO,3
Start
beep1
GPIO,0
Delay1
GPIO,1
Delay2
GPIO,3
$-2
GPIO,1
beep2
http://www.talkingelectronics.com/te_interactive_index.html[21.1.2014 18:23:39]
;delay 1 second
;Is Sw released? - HIGH
;de-activate starter relay
; 40mS beeps
Delay2
GPIO,3
$-2
Delay2
GPIO,3
$-5
GPIO,0
beep2
Delay2
Delay2
Delay2
Delay2
Delay2
SetUp
;delay 1 second
;Is Sw LOW? - pushed
;delay 1 second
;Is Sw LOW? - pushed
;de-activate ignition
;40mS beeps
;delay 1 second
;delay 1 second
;delay 1 second
;delay 1 second
;delay 1 second
relay
;******************************************************************
; subroutines
*
;******************************************************************
beep2
call
beep1
; 40mS beep
call
Delay1
; 20mS delay
;(micro will go here after delay1 and execute beep1)
beep1
movlw
movwf
goto
decfsz
goto
movlw
xorwf
decfsz
goto
retlw
.40
temp
$+1
DelA,1
$-2
b'00000100'
GPIO,F
temp,1
$-6
00
Delay1
movlw
movwf
goto
decfsz
goto
decfsz
goto
retlw
.20
temp
$+1
DelA,1
$-2
temp,1
$-4
00
Delay2
movlw
movwf
call
decfsz
goto
retlw
.50
DelB
Delay1
DelB,1
$-2
00
;spkr pin
;spkr bit will toggle
; 20mS delay
;1 Second delay
;******************************************************************
end
If you are going to burn the program yourself, you will need a PICkit-2 programmer.
You should read about programming PIC chips by looking on Talking Electronics website,
under Elektor,EPE,Silicon Chip. and see Multi Chip Programmer.
If you have any other questions, contact Colin Mitchell via email.
2/1/2010
http://www.talkingelectronics.com/te_interactive_index.html[21.1.2014 18:23:39]