You are on page 1of 5

TE Index for website

Talking Electronics
Kits

IGNITION
SWITCH

Ordering Items ^

ELEKTOR, EPE &


SILICON CHIP
PROJECTS

Home
See more projects using micros:
Elektor,EPE,Silicon Chip

Chapter 1
Introduction
12 FREE PIC Books

Chapter 2

This project is a discussion on how to program PIC10F200 chips.

Talking About Micro's

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

Here's what the circuit does:


Put your Ignition Switch and Starter into one unit. The push-switch has a blue LED to indicate
when the ignition is "On." Push and hold the button while the starter turns over and release
when the engine starts. The ignition stays "On." Push again to stop the engine. You've seen it on
new, top-end luxury cars. . .now it can be in your car, too.

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

Some of these projects


are not yet finished:

PROJECTS:

+
+
+
+
+
+
+
+

2 Digit Up/Down Counter


12Fxxx ProtoBoard

7x5 Games Console


Alarm - Space Gun
Audio CRO

Bike & Car Gears


Call Reminder

Code Puzzle

http://www.talkingelectronics.com/te_interactive_index.html[21.1.2014 18:23:39]

TE Index for website

+
+
+
+
+
+
+
+
+
+
+
+

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

Things you will need:


blank template
Decimal to HEX
Disassembly zip exe
Code Microsoft Library (unzip

IGNITION SWITCH for PIC10F200


;******************************************************************
;*
*
;* Filename: Ignition 10F200 v2.asm
*
;*
Author: Mike McLaren, K8LH
(k8lh@arrl.net)
*
;*
Date: 30-Sep-09
*
;*
*
;*
*
;* 10F200 Ignition Switch Experiment
*
;*
*
;*
*
;*
MPLab: 8.14
(tabs=8)
*
;*
MPAsm: 5.21
*
;*
*
;******************************************************************
include "p10f200.inc"
list
st=off

it into a folder CML.)

.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

_MCLRE_OFF & _CP_OFF & _WDT_OFF


dec

;--< hardware >--------------------------------------------------#define ignition


#define starter

GPIO,0
GPIO,1

; GP0 = active hi ignition relay


; GP1 = active hi starter relay

;--< variables >-------------------------------------------------cblock

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

TE Index for website

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

#define running swold,0

; running flag

;--< macros >----------------------------------------------------clock


usecs

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

; 32-msec debounce delay


; sample active lo GP3 switch
; save fresh sample

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

;
;
;
;
;
;
;
;
;
;
;

switch timer running?


no, branch, else
is it timed out?
no, branch, else
do a double beep
ignition == 1 and
running == 0 (allow start)?
no, branch, else
set "running" flag
turn GP1 'starter' on

;******************************************************************
; 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]

TE Index for website

movlw
b'00000100'
skpnc
xorwf
GPIO,F
inDlyCy(1000*usecs-6)
decfsz mstmr,F
goto
dbloop
clrc
retlw
0

;
;
;
;
;
;
;
;

mask for GP2 'spkr' pin


beep task? no, skip, else
toggle the speaker pin
1-msec minus 6 cycles
done? yes, skip, else
loop

;******************************************************************
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 SWITCH for PIC10F200


;******************************************************************
;*
*
;* Filename: Ignition 10F200 v2.asm
*
;*
Author: Colin Mitchell
*
;*
Date: 11-Feb-2010
*
;*
*
;*
*
;* 10F200 Ignition Switch Project
*
;*
*
;*
*
;******************************************************************
include "p10f200.inc"
list
st=off
__CONFIG
radix

_MCLRE_OFF & _CP_OFF & _WDT_OFF


dec

;--< hardware >--------------------------------------------------#define


#define
#define
#define

ignition
starter
spkr
Sw

GPIO,0
GPIO,1
GPIO,2
GPIO,3

;
;
;
;

GP0
GP1
GP2
GP3

=
=
=
=

active hi ignition relay


active hi starter relay
piezo speaker
input - switch

;--< variables >-------------------------------------------------temp


DelA
DelB

equ
equ
equ

10h
11h
12h

;general purpose registers 10h to 1Fh


; used in delay
; used in delay
; used in delay

;******************************************************************
; 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

;20mS debounce delay


;Is Sw LOW? - pushed
;loop
;40mS beep
;activate ignition relay
;activate starter relay

;Turn off starter relay


call
btfss
goto
bcf
call

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

TE Index for website

;Turn off Ignition


call
btfsc
goto
call
btfsc
goto
bcf
call
call
call
call
call
call
goto

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]

You might also like