I am building a remote starter for the motorcycle. Just because. Anyway, my fisrt step is to test the basic code on a breadboard. I am using the attached circuit and code. It doesn't work.
Can someone help me figure out what stupid mistake I made??
The 'Key" led should go on and stay on with the first press of the button. The "starter" led should then go on with the second press and hold of the button. There should be about a 2 second delay from the first LED until the second one will light up.
Thankyou!!!!
I do have a .01 uf cap on the +/- pins not shown in the schematic.
**broken link removed**
Can someone help me figure out what stupid mistake I made??
The 'Key" led should go on and stay on with the first press of the button. The "starter" led should then go on with the second press and hold of the button. There should be about a 2 second delay from the first LED until the second one will light up.
Thankyou!!!!
I do have a .01 uf cap on the +/- pins not shown in the schematic.
**broken link removed**
Code:
;**********************************************************************
; This file is a basic code template for object module code *
; generation on the PIC16F628A. This file contains the *
; basic code building blocks to build upon. *
; *
; Refer to the MPASM User's Guide for additional information on *
; features of the assembler and linker (Document DS33014). *
; *
; Refer to the respective PIC data sheet for additional *
; information on the instruction set. *
; *
;**********************************************************************
; *
; Filename: RemStart.asm *
; Date: Mar/7/2010 *
; File Version: 1 *
; *
; Author: Scott Schwalm *
; Company: DocLED *
; *
; *
;**********************************************************************
; *
; Files required: P16F628A.INC *
; *
;**********************************************************************
; *
; Notes: Adapted from: *
; Tutorial 2.2 - Nigel Goodwin 2002 *
; and Moontaj.com remote car starter *
; *
;**********************************************************************
list p=16F628A ; list directive to define processor
#include <p16F628A.inc> ; processor specific variable definitions
errorlevel -302 ; suppress message 302 from list file
__CONFIG _CP_OFF & _DATA_CP_OFF & _LVP_OFF & _BOREN_OFF & _MCLRE_ON & _WDT_OFF & _PWRTE_ON & _INTOSC_OSC_NOCLKOUT
cblock 0x20 ;start of general purpose registers
count1 ;used in delay routine
counta ;used in delay routine
countb ;used in delay routine
endc
OUTPORT Equ PORTB ;set constant OUTPORT = 'PORTB'
SWPORT Equ PORTA ;set constant SWPORT = 'PORTA'
OUTTRIS Equ TRISB ;set constant for TRIS register
SWTRIS Equ PORTA ;set constant for TRIS register
;set constants for the switches
SW1 Equ 0 ;FOB Button 1 on RA0
SW2 Equ 1 ;FOB Button 2 on RA1
;SW3 Equ 2 ;Already on Indicator on RA2
;and for the Outputs
KEY Equ 3 ;KEY output to relay on RB3
STARTER Equ 2 ;output to starter relay RB2
SWDel Set Del50 ;set the de-bounce delay
;end of defines
org 0x0000 ;org sets the origin, 0x0000 for the 16F628,
;this is where the program starts running
movlw 0x07
movwf CMCON ;turn comparators off (make it like a 16F84)
bsf STATUS, RP0 ;select bank 1
movlw b'00000000' ;set PortB to 8 outputs
movwf OUTTRIS
bsf STATUS, RP0 ;select bank 1
movlw b'11111111' ;set PortA as all inputs
movwf SWTRIS
bcf STATUS, RP0 ;select bank 0
clrf OUTPORT ;set all outputs low
Loop btfsc SWPORT, SW1
call BUTTON1
;btfsc SWPORT, SW2 ;to be later used for lockout and alarm part of code
;call BUTTON2
goto Loop
BUTTON1 call Del50 ;give switch time to stop bouncing
btfss SWPORT, SW1 ;check it's still pressed
return ;return if not
btfss OUTPORT,KEY ;see if KEY is already on if not, turn it on
goto KEYON
; I need a test for the engine running here. If yes then goto
; KEYOFF, if no then goto START
; need to figure out engine running sensor. There is no tach wire.
; The blue/yellow or yellow/blue go from the ECM to the coils (1 to each)
; These may be used for a Tach signal then compare to be over a threshold.
; Idle will give coil pulse every 1/10 sec. perhaps check for at least 2
; pulses in a ¼ sec period.
goto START ; if the key is on then engage the starter motor
; for the whole time the button is pressed
; stop when released.
KEYON bsf OUTPORT,KEY ;turn KEY on
call Del2sec ;wait about 2 sec for fuel pump to come up to pressure
return
START bsf OUTPORT,STARTER ;turn Starter on
btfss SWPORT, SW1 ;wait until button is released
return
goto START
;KEYOFF bcf OUTPORT, KEY ;turn Key off
; call Del50
; btfss SWPORT, SW1 ;wait until button is released
; return
; goto KEYOFF
; I need a key off code module here with some sort of safety interlock to
; prevent accidental turn off while riding. KEYOFF is not used yet.
; Maybe have to press 2 keys in sequence within a time period?
;BUTTON2 call Del50 ;give switch time to stop bouncing
; Return ;BUTTON2 is just a spaceholder for now
;Canned Delay routine from Nigel,
;direct calls for specified times
;or load W and call Delay for a custom time.
;Later delete the options I don’t want.
Del2sec Call Del250 ;8 250ms delays for slightly over a 2 sec delay
Call Del250
Call Del250
Call Del250
Call Del250
Call Del250
Call Del250
Call Del250
Return
Del0 retlw 0x00 ;delay 0mS - return immediately
Del1 movlw d'1' ;delay 1mS
goto Delay
Del5 movlw d'5' ;delay 5mS
goto Delay
Del10 movlw d'10' ;delay 10mS
goto Delay
Del20 movlw d'20' ;delay 20mS
goto Delay
Del50 movlw d'50' ;delay 50mS
goto Delay
Del100 movlw d'100' ;delay 100mS
goto Delay
Del250 movlw d'250' ;delay 250 ms
Delay movwf count1
d1 movlw 0xC7 ;delay 1mS
movwf counta
movlw 0x01
movwf countb
Delay_0
decfsz counta, f
goto $+2
decfsz countb, f
goto Delay_0
decfsz count1 ,f
goto d1
retlw 0x00
end