Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Building a remote starter...

Status
Not open for further replies.

yfx4

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

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
 
Hi,

The hardware will not run because you do not have Mclr Pin4 pulled up. - fit a 10k from pin 4 to +5v.
Alternativley change the Config statement to MCLRE_OFF

The connection from the switch to +5v should be cut and another 10k resistor inserted so it is pulled up instead of direct.

Your leds might be very dim, dependant on the type of leds, 470R might be better.

Have not looked at your code, see if it works with the hardware changes first.


Edit - Tested - your code and circuit do work.
 
Last edited:
Yes, MCLR must be pulled high or change the code as per Wp100's suggestion, your LED's wont light very well with a 1k Resistor, I go on the following:
5v output from PIC, Vf from LED is approx 2v, 5v - 2v = 3v across LED, ohms law suggests 3/0.01 (10 mA) = 300R, so I use either a 300R or a 330R resistor.

As for sensing, I have done something similar on a 12v connection (I presume your motorcycle runs on 12v?) I use a 3.3k and 2.2k voltage divider.
 
Did something similar in another thread awhile back using a single switch with timed "short" and "long" switch press detection.

A short press toggles the "ignition" relay output from on to off or from off to on. A long press is used to engage the starter (for as long as you hold the switch pressed) and simple logic is used to prevent additional long presses from engaging the starter again while the engine is running. If you have a failed start you must use a short press to turn off the ignition and then another short press to turn the ignition back on before attempting a long press to engage the starter.

Good luck with your project. Regards, Mike

**broken link removed**
 
Last edited:
Cool. I modified the HW as y'all suggested. I turned off MCLRE. IT WORKED!!! sort of. The 'starter' wouldn't turn off. OOOPPPS. So I added a bit to fix it. Then sometimes it would go off, some times not. I figured it was bouncing so added the delay.

Now it works to this point. I'll work on the turning off part now. Thank you all!!!

Code:
START
	bsf	OUTPORT,STARTER	        ;turn Starter on
	call	Del50			; to be sure switch doesn't bounce during off
	btfss	SWPORT,	SW1		;wait until button is released
	bcf	OUTPORT,STARTER   	; stop when released.
	btfss	SWPORT,	SW1		;wait until button is released
	return
	goto	START

If there are any ideas on how to make it tighter I would love to learn them.
 
as a qualified 'bike mechanic i would advise great caution in installing any control to a motorcyles ignition system

there have been cases of immmobilisers which where poorly wired/made switching 'on' when riding, killing the rider...

you dont get thrown off a car.

a freind of mine made an adaption of the Maplinmagazine 'compuguard' alarm system and hacked it using a flip-flop to get remote start for his BMW K series
the remote was encoded with a MC14026 IC and sent via IR, as per the original car alarm circuit;with an IR transistor peaking out inside the fairing to receive the code bursts.it featured an interlock so when the engine was running the immobiliser would not switch on,it could ONLY be turned off by the ignition key

he managed to blag 'free' miniature resistors from work (in the days before surface mount!) and shoved it in the toollbox under the rear seat,potted into a case,and wrapped in foam (belt and braces!)

think the thing used about 7 ICs in the receiver;it could probably all be done in code now inside 1 PIC/AVR;and cheaper!

it gave people quite a turn when the bike they where passing suddenly started,with no-one by it!
remember too that there needs to be an interlock to prevent the starter operating WITH THE BIKE IN GEAR!!!;
IF THE REAR WHEEL IS IN CONTACT WITH THE GROUND ITS GOING TO GET MESSY!
 
Last edited:
as a qualified 'bike mechanic i would advise great caution in installing any control to a motorcyles ignition system

there have been cases of immmobilisers which where poorly wired/made switching 'on' when riding, killing the rider...

you dont get thrown off a car.

a freind of mine made an adaption of the Maplinmagazine 'compuguard' alarm system and hacked it using a flip-flop to get remote start for his BMW K series
the remote was encoded with a MC14026 IC and sent via IR, as per the original car alarm circuit;with an IR transistor peaking out inside the fairing to receive the code bursts.it featured an interlock so when the engine was running the immobiliser would not switch on,it could ONLY be turned off by the ignition key

he managed to blag 'free' miniature resistors from work (in the days before surface mount!) and shoved it in the toollbox under the rear seat,potted into a case,and wrapped in foam (belt and braces!)

think the thing used about 7 ICs in the receiver;it could probably all be done in code now inside 1 PIC/AVR;and cheaper!

it gave people quite a turn when the bike they where passing suddenly started,with no-one by it!
remember too that there needs to be an interlock to prevent the starter operating WITH THE BIKE IN GEAR!!!;
IF THE REAR WHEEL IS IN CONTACT WITH THE GROUND ITS GOING TO GET MESSY!

Thx for the thoughts. I have the same fears. My plan is to have a remote start that shuts off when the brake is touched. since the 'on' relay will be in parallel to the key, to ride it I will need to put in the key and turn it on. Then, when the remote start shuts off when I use the brake to engage the gear the bike will not turn off--the key circuit is still closed. I do not plan any immobilizers for fear they will engage on the highway. The starter relay will be in parallel with the stock starter switch so the stock lockouts (neutral, kickstand, etc) will still be active. My bike only has a sidestand so the wheels always touch the ground. Currently it will turn over if the sidestand is down only if in neutral. If the sidestand is put down while it is in gear it turns off and the starter will not engage. I will not bypass any of this--only the handlebar switch and key switch will be paralleled.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top