Ignition Switch

  • Upload
    safet

  • View
    220

  • Download
    0

Embed Size (px)

DESCRIPTION

Ignition Switch

Citation preview

  • TE Index for website

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

    Talking ElectronicsKits

    Ordering Items ^

    ELEKTOR, EPE &SILICON CHIP PROJECTS

    Chapter 1Introduction12 FREE PIC Books

    Chapter 2Talking About Micro's

    Chapter 3 Start HERE with PIC12F629

    Chapter 4 In Circuit Programming

    Chapter 5Changing Micros

    Chapter 6Delay Codesblank template Decimal to HEXCoding Problems, or Program Problems, or Writing Problems

    Chapter 7Start Here with PIC16F628PIC16F628 InstructionsPIC16F628 Data (.pdf)PICkit-2 programmer

    Chapter 8Other people's programs (to help you write code)Elmer 160 (PIC lessons on the web - by J McDonough)Click HERE for new frameGooligum PIC Tutorials

    Chapter 9 Converting PIC'508A codeto 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

    IGNITIONSWITCH

    Home

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

    This project is a discussion on how to program PIC10F200 chips. We are not selling the program or the project. Go to Mike McLaren - Micro Application Consultants for details on thesethings.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 insize 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 arelocated 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 toproduce something extremely small, this chip is the challenge for you.

    The first IGNITION SWITCH program has been written by a very qualified programmer and shows what can be done with this6 pin chip, but the program also contains a number of difficult-to-understand instructions, with some of them coming from alist that only expert programmers understand. The second IGNITION SWITCH program has been written by Colin Mitchell and is much easier to understand. if you studythem both, you will gain a lot of understanding on how to create a program.

    Here's what the circuit does:Put your Ignition Switch and Starter into one unit. The push-switch has a blue LED to indicatewhen the ignition is "On." Push and hold the button while the starter turns over and releasewhen the engine starts. The ignition stays "On." Push again to stop the engine. You've seen it onnew, top-end luxury cars. . .now it can be in your car, too.

  • TE Index for website

    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 Things you will need:blank templateDecimal to HEXDisassembly zip exeCode Microsoft Library (unzip it into a folder CML.)

    .inc filesIC Prog 106B (Help file)Instructions for PIC12F629Library of Routines A-ELibrary of Routines E-PLibrary of Routines P-ZMPASM Multi Chip ProgrammerPIC Chip ListPIC ProgrammerPrototyping BoardsPIC10F200 - 6 pin SMmicroPIC10F222 - DICEPIC10F200 - Ignition/starter

    IGNITION SWITCH for PIC10F200

    ;******************************************************************;* *;* Filename: Ignition 10F200 v2.asm *;* Author: Mike McLaren, K8LH ([email protected]) *;* Date: 30-Sep-09 *;* *;* *;* 10F200 Ignition Switch Experiment *;* *;* *;* MPLab: 8.14 (tabs=8) *;* MPAsm: 5.21 *;* *;****************************************************************** include "p10f200.inc" list st=off __CONFIG _MCLRE_OFF & _CP_OFF & _WDT_OFF radix dec;--< hardware >----------------------------------------------------#define ignition GPIO,0 ; GP0 = active hi ignition relay#define starter GPIO,1 ; GP1 = active hi starter relay;--< variables >--------------------------------------------------- cblock 0x10temp ; delay subsystemswnew ; fresh switch sample (b3 bit)swold ; switch state latch (b3 bit)mstmr ; msec timerswtmr ; 1 sec switch timer endc

  • TE Index for website

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

    p12F629.incPIC12F629 Data (.pdf 4.9MB)PICkit-2 programmerPICkit-2 from Modtronix6 pin - 5 pin adapterSurface Mount PC BoardS/mount Diodes/ZenersSurface Mount LEDsSurface Mount ResistorsSurface Mount TransistorsSurface Mount Outlines

    12-8-2009

    #define running swold,0 ; running flag;--< macros >------------------------------------------------------clock equ 4 ; 4-MHz clockusecs equ clock/4 ; cycles/usec multiplierinDlyCy macro pCycles ; 0..1027 cycle range local loop ; if pCycles > 3 movlw pCycles/4 ;loop movwf temp ; 4-cycle loop decfsz temp,W ; goto loop ; endif if pCycles%4 >= 2 goto $+1 ; 2 cycles endif if pCycles&1 == 1 nop ; 1 cycle endif endm;******************************************************************; main program *;****************************************************************** org 0x000start 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 Carrynewsample call dbdelay ; 32-msec debounce delay comf GPIO,W ; sample active lo GP3 switch movwf swnew ; save fresh samplenewpress btfsc swnew,3 ; swnew.3 == 1 and btfsc swold,3 ; swold.3 == 0 (new press)? goto newrelease ; no, branch, else bsf swold,3 ; update swold.3 state latch call beep1 ; do a single 32-msec beep and movlw 1000/32 ; start 1 second timer movwf swtmr ;newrelease btfss swnew,3 ; swnew.3 == 0 and btfss swold,3 ; swold.3 == 1 (new release)? goto timeout ; no, branch, else bcf swold,3 ; update swold.3 state latch bcf starter ; turn GP1 'starter' off movf swtmr,W ; timed out "long" press? bz newsample ; yes, branch (done), else clrf swtmr ; turn off 1 second timer movlw b'00000001' ; use GP0 pin mask to xorwf GPIO,F ; toggle GP0 'ignition' output bcf running ; clear "running" flagtimeout movf swtmr,F ; switch timer running? bz newsample ; no, branch, else decfsz swtmr,F ; is it timed out? goto newsample ; no, branch, else call beep2 ; do a double beep btfsc ignition ; ignition == 1 and btfsc running ; running == 0 (allow start)? goto newsample ; no, branch, else bsf running ; set "running" flag bsf starter ; turn GP1 'starter' on goto 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 delaybeep1 setc ; 32-msec delay with beepdbdelay movlw 32 ; C = 0, delay, C = 1, beep movwf mstmr ; mstmr = 32 msecsdbloop

  • TE Index for website

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

    movlw b'00000100' ; mask for GP2 'spkr' pin skpnc ; beep task? no, skip, else xorwf GPIO,F ; toggle the speaker pin inDlyCy(1000*usecs-6) ; 1-msec minus 6 cycles decfsz mstmr,F ; done? yes, skip, else goto dbloop ; loop 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 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 _MCLRE_OFF & _CP_OFF & _WDT_OFF radix dec;--< hardware >----------------------------------------------------#define ignition GPIO,0 ; GP0 = active hi ignition relay#define starter GPIO,1 ; GP1 = active hi starter relay#define spkr GPIO,2 ; GP2 = piezo speaker#define Sw GPIO,3 ; GP3 = input - switch;--< variables >--------------------------------------------------- ;general purpose registers 10h to 1Fhtemp equ 10h ; used in delay DelA equ 11h ; used in delay DelB equ 12h ; used in delay

    ;******************************************************************; main program *;****************************************************************** org 0x000SetUp 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 Delay1 ;20mS debounce delay btfsc GPIO,3 ;Is Sw LOW? - pushed goto Start ;loop call beep1 ;40mS beep bsf GPIO,0 ;activate ignition relay call Delay1 bsf GPIO,1 ;activate starter relay

    ;Turn off starter relay call Delay2 ;delay 1 second btfss GPIO,3 ;Is Sw released? - HIGH goto $-2 bcf GPIO,1 ;de-activate starter relay call beep2 ; 40mS beeps

  • TE Index for website

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

    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

    ;Turn off Ignition call Delay2 ;delay 1 second btfsc GPIO,3 ;Is Sw LOW? - pushed goto $-2 call Delay2 ;delay 1 second btfsc GPIO,3 ;Is Sw LOW? - pushed goto $-5 bcf GPIO,0 ;de-activate ignition relay call beep2 ;40mS beeps call Delay2 ;delay 1 second call Delay2 ;delay 1 second call Delay2 ;delay 1 second call Delay2 ;delay 1 second call Delay2 ;delay 1 second goto SetUp;******************************************************************; subroutines *;******************************************************************beep2 call beep1 ; 40mS beep call Delay1 ; 20mS delay ;(micro will go here after delay1 and execute beep1)beep1 movlw .40 movwf temp goto $+1 decfsz DelA,1 goto $-2 movlw b'00000100' ;spkr pin xorwf GPIO,F ;spkr bit will toggle decfsz temp,1 goto $-6 retlw 00Delay1 movlw .20 ; 20mS delay movwf temp goto $+1 decfsz DelA,1 goto $-2 decfsz temp,1 goto $-4 retlw 00 ;1 Second delay Delay2 movlw .50 movwf DelB call Delay1 decfsz DelB,1 goto $-2 retlw 00 ;****************************************************************** end

    talkingelectronics.comTE Index for website