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.

HELP! Building Keyless Access for Automobile

Status
Not open for further replies.

thekyguy11

New Member
Inspired by the all new 2009 Acura TL (I work at an Acura Dealership), I decided I want to re-create the keyless access system featured in this new car. The system eliminates the need to use a key when starting the vehicle . If you would like to help me do this, please feel free to read my post. If not, try not to waste your time because it will probably take me quite a bit of typing to explain everything.

The Acura system uses a transponder in the key fob to detect when the owner of the car enters it. You can keep the key fob right in your pocket. Then, Pressing the stop/start button once turns on Accessory mode. Pressing it again turns on the ignition. Pressing the stop/start button again while depressing the brake pedal starts the engine. Or, for a quick start: Get in, depress the brake and press the stop/start once and it will go straight to starting the engine. Pressing the stop/start button while the engine is running shuts everything down.

My car is a 92 Integra. I am very familiar with Automotive electrical systems, and I am trying to learn electronics. So far, I only know the basics (ie: resistors, transistors, capacitors, relays, diodes, voltage drop, current, etc etc.). I've purchased and built a Junebug from Blueroomelectronics to learn more, but I still don't have any code writing skills. I'm hoping the code required for this project will be relatively simple.

So, I thought a good place to start would be to learn how to make the LED's on the junebug respond to the three buttons similar to the way the Keyless Access System works:

Button 1= simulate input from proximity detector (already purchased one)
Button 2= simulate Stop/Start Button input
Button 3= simulate Brake Sw input

And the LED's would simulate the output to the three 5v relays that would be used the activate three 12v automotive relays mounted under the dashboard of the car. They would have to respond as follows...

-Button one must be held to do anything
-Pressing Button 2 lights an LED.
-Pressing Button 2 again lights a second LED
-Pressing Button 2 again lights a third LED for approx 7 seconds
-Pressing Button 2 again shuts all lights off
-If Button 2 and 3 are pressed at the same time, the first and second LEDs should light for 1 second, followed by the third lighting for 7 seconds
-Letting go of Button 1 at any point shuts everything down

If I can accomplish this, I'll be on a solid path to making this system work. Now I don't need the code written for me (unless you want to, I'll study it! lol) But I need a LOT of guidance.

I downloaded Swordfish and printed the reference guide to keep on hand. I know I'm semi-close to understanding the code, but all I can do to the "blinky" code is make the LEDs run faster or slower, lol.

(See Acura.com for more info on the real thing. click TL>Features>Luxury and Convenience>Keyless Start System)

Any and all help is GREATLY appreciated. Thanks in advance guys!!!!!
 
Last edited:
Hi thekyguy11,

Welcome to the forum.

To get you started here is some simple code that just lights an LED when a switch is pressed.
Code:
Device = 18F1320
Clock = 4 // 4MHz clock
Config OSC = INTIO2, WDT = OFF, LVP = OFF

Dim NOT_RBPU As INTCON2.7
Dim Lit As Byte
Dim Keys As Byte

OSCCON = $62            // select 4MHz internal clock
ADCON1  = $7f           //all digital
NOT_RBPU=0              //WPUs on port B
While true
    DelayMS(10)
    If(PORTB.0=0) Then                  //is button 1 pressed
        TRISA.7 = 1
        High(PORTA.0)
        Low (PORTA.6) 
    EndIf
    If(PORTB.2=0) Then 
        TRISA.7 = 1
        Low (PORTA.0)
        High(PORTA.6)      
    EndIf
    If(PORTB.5=0) Then 
        TRISA.0 = 1
        High(PORTA.6)
        Low (PORTA.7)      
    EndIf
Wend
End

The problem you will face with using the Junbug is that (unless you multiplex) only two LEDs can be lit at the same time. This can be overcome but it's a little tricky.

You should download Junebug.bas from Bill's site and study it.

Mike.
 
-Button one must be held to do anything
-Pressing Button 2 lights an LED.
-Pressing Button 2 again lights a second LED
-Pressing Button 2 again lights a third LED for approx 7 seconds
-Pressing Button 2 again shuts all lights off
-If Button 2 and 3 are pressed at the same time, the first and second LEDs should light for 1 second, followed by the third lighting for 7 seconds
-Letting go of Button 1 at any point shuts everything down

Think "states"...

In more words ... what states your device can be in?
- state0 / initial state
This is the state your device is when button1 is not pressed. In state0 only thing you "expect" is button1 press, and that is the "way" to state1

- state1 / button1 pressed, "engine" in initial off position
From this state you can
- go back to state0 (if button1 is released)
- go to state2 (if button2 is pressed and released and button3 is released)
- go to state4 (if button2 is pressed and released and button3 is pressed)

- state2 / LED1 lit
From this state you can:
- go back to state0 (if button1 is released)
- go to state3 (if button2 is pressed and released and button3 is released)
- go to state4 (if button2 is pressed and released and button3 is pressed)

- state3 / LED1 lit, LED2 lit
From this state you can:
- go back to state0 (if button1 is released)
- go to state4 (if button2 is pressed and released and button3 is pressed)

- state4 / LED1 lit, LED2 lit, LED3 lit
From this state you can:
-??? go back to state0 (if button1 is released) ??? check this out, what is going on if motor is working and you exit the car ???
- go to state5 (automatic after xyz seconds)

- state5 / motor is running
From this state you can:
- go to state1 (if button2 is pressed and released) (this will turn the engine off - maybe you need to go trough "state6" that will turn the engine off and auto switch to state1)
- go to state3 (if motor turn off by itself for some reason)
---

hope this is clear ... you might need few more states (I do not know much about car's) but that's roughly what you need. you keep the "current" state in some variable, in every state you monitor "events" that can "change the state" .. so for e.g. in state0 you just need to monitor button1 while in state5 you need to monitor button2 and you need to monitor if motor is working properly ....

with regards to coding, I do not have any exp with swordfish but you need to
- get how to read a button state (you have example made by pommie)
- get how to turn output pin high/low (you have example made by pommie)
- understand WHILE loop
- understand IF flow control statement
- understand CASE flow control statement (if such exist in swordfish)
- grasp the basic concept of variables

now, after you make it using these :) you can advance it and implement interrupts (get the button1 - 4 to B0-B4 and use interrupts instead of loops)

I hope this helps you a bit
 
Last edited:
I must first admit to skimming over the thread, but one of the primary questions you need to answer for yourself, before you choose a PIC, is:

"How many input/output pins do I require?" then add a few more for things you may have overlooked.

For instance, there are some very important conditions that need to be satisfied with this system.

It must be impossible to activate the starter motor, unless the transmission is in neutral, or the clutch is pressed (for a manual), or the transmission is in park/neutral (for an automatic)

The starter motor must not be allowed to continue to be engaged once the engine is actually running.

It should (correct if this is wrong) be impossible to switch off the engine above a certain speed threshold.


With these considerations taken into account, there is a need for additional inputs from your initial estimate.

It could be suggested that you should think about inputs for:

Proximity detector.
Door handle.
Door-open monitoring.
Brake pedal.
Clutch pedal.
Stop/Start switch.
Engine RPM sensor. (is engine running above cranking speed?)
Vehicle speed sensor. (VSS - is the vehicle actually moving above a certain speed and would it be safe to switch off the engine at this speed and lose power steering etc.)
Parking brake.
Ignition circuit 1 feedback. (Auxiliary position - heater system, entertainment etc.)
Ignition circuit 2 feedback. (Ignition position - engine management, transmission management, ABS, Traction control, Stability control, etc.)
Starter feedback. (Is the engine actually cranking?)

The feedback inputs could be argued as being redundant, but there would be no point cranking the engine if the ignition 2 relay is not functioning correctly. Also, these inputs could be used for fault diagnosis - no output detected from Ignition circuit 1 relay, flash an LED indicator once and repeat. No output detected from Ignition circuit 2 relay, flash an LED indicator twice, pause, then repeat. No output from Starter relay, flash an LED three times, pause, then repeat.

Ok the last example (Starter) could theoretically be monitored by the Engine RPM sensor, but suppose the starter motor itself is actually faulty....you could probably rule out the relay as being the cause of a no-crank condition if you have an output, saving some time spent troubleshooting.


Outputs that should be considered:

Ignition circuit 1 relay.
Ignition circuit 2 relay.
Starter relay.
Malfunction Indicator Lamp (MIL - you should be familiar with this one ;) )
Door locking/unlocking signal - This function is two-fold....you should probably have a requirement to unlock the vehicle only when a valid ID device is in proximity AND the door handle is actuated, and also have to pull the handle once again to open the door. If the door is not opened within a determined time period from the door being unlocked, the system should re-lock the door. (This would also require an additional IO pin for door-open monitoring)

Once your I/O needs are catered for, and you have added a few extra pins for overhead/future enhancements, choose your PIC.

If one further piece of advice can be suggested, it would be to download and read the datasheet for the PIC you choose.

Regards, and good luck.
 
Last edited:
IMHO putting a keypad on your car may or may not look great (of course if you're a good bodywork mechanic then I'm sure it'll look great)
Take a look at iButtons, the receptacle can be lit and the keys are cool IMO.
**broken link removed**
 
Those things are cooooool! Thank goodness for samples!:D

BTW, where did you get the photo? I couldn't find that particular pic anywhere on the site?
 
Last edited:
I'll post a link when I'm off the iPhone. The picture link has the site name and it's found in products.
The glowing led would make for a neat armed indicator. I'm told BMW uses ibuttons as part of their keys
 
Thanks for the replies guys!!!

Mickster: I wanted to also include in my OP that I addressed all these details already, but I figured it would be way too lengthy and perhaps difficult to follow. But, here are some answers...

-Because the 12v relays are going to be taking the place of the actual Ignition Switch, I don't need to add the clutch safety switch. The only bummer to my setup is I'll have to remove the steering wheel lock, until I find the part number and get a price on the electric motor that locks the column on the 09 TL.

-I want the "Start" Circuit relay to be ON for 6-7 seconds, and I plan to build an RPM switch to open this circuit once say...300 rpm is reached (although, I'm sure some testing is needed to determine what RPM is optimal for this). If the starter runs and the car doesnt start for some reason, it will stop trying after 6-7 seconds.

-The 09 TL will allow you to shut down the vehicle regardless of speed, so my system will do the same (Kind of like pulling the key out while driving). The TL will not lock the steering wheel if there is any speed registered from the VSS. Since I wont have a steering wheel lock at first, I'll address this part when the time comes.

-There will be no need for a keyboard, or anything. The proximity detector detects when the supplied "chip" comes within range. I'll explain more about this system when I receive it in the mail.

-I'll be purchasing the actual Stop/Start Button from Acura soon.

I've run out of time to reply, I'll be back later. Thanks again.
 
Last edited:
o, and I have a car alarm installed with power locks, so entry into the vehicle is already handled.
 
Last edited:
I like the idea of having self-diagnosis, as mentioned earlier, but since I need to keep the code simple, I won't incorporate that in this design. Maybe down the road.

I'm searching through the PICs on Microchip's website, and I have so many questions. I'd like to work with what I got, so It would be nice if I could use my junebug as a programmer. Although, I do also have a Willem Eprom burner that I use for OBD1 Honda/Acura ECU programming. It seems to program a lot of different things, but I don't have a clue if it could help me with this.

Here's what I'm looking for

-12v (Not seeing any that are. If this is the case, is there a better way to activate a 12v relay without using a 5v relay to do the job? I hate having to double-relay things, if I don't have to.
-4 inputs, 4 outputs minimum
-Oscillator/s (I'm assuming I need these for timers?)

It almost looks like if there really is no 12v PICs, I could just use the 18f1320. That would be keeping things simple, which I like.
 
To switch a 12V relay you just use a NPN transistor. Relay between 12v and collector, emitter to ground and base via a resistor to pic. To read 12V signals with the pic you just use a large resistor to limit the current into the pic.

I would start with the 18F1320. Have you managed to get anything working in Swordfish yet?

Mike.
 
To switch a 12V relay you just use a NPN transistor. Relay between 12v and collector, emitter to ground and base via a resistor to pic.
Maybe I'm wrong, but shouldn't someone mention to thekyguy11 that he needs a diode in there somewhere as well, to prevent killing the PIC pin when the relay turns off?
 
Last edited:
Maybe I'm wrong, but shouldn't someone mention to thekyguy11 that he needs a diode in there somewhere as well, to prevent killing the PIC pin when the relay turns off?

Yes, forgot that bit.:eek:

Mike.
 
Before I forget... arhi, I was thinking the same thing about the different "states" of the outputs to cleanup/simplify the code a bit, I'm glad you kind of confirmed I was on the right track.

Pommie, Correct me if I'm wrong (i might be showing off my newbie-ness here), but my understanding of transistors was that the emitter voltage only matches the voltage at the base. If the PIC is sending 5v to the base, wouldn't that mean only 5v can flow through the relay coil circuit in the setup you described, despite the 12v at the collector?

And I don't have a clue what you guys mean about the PIC pin. Unless you are talking about the supply voltage to the PIC. This would be provided by a HOT AT ALL TIMES wire. edit: Oooooo, you mean a diode to suppress voltage spikes caused by the magnetic field in the relay coil collapsing????

And for a regulator, I bought a 5v regulator at Radio Shack a while back that I'm not using (looks just like a transistor), but I swear I remember reading somewhere about a 5v regulator that was made specifically for automotive use, I think because of the unstable voltage values in automotive systems, or something along these lines.
 
Last edited:
And I don't have a clue what you guys mean about the PIC pin. Unless you are talking about the supply voltage to the PIC. This would be provided by a HOT AT ALL TIMES wire. edit: Oooooo, you mean a diode to suppress voltage spikes caused by the magnetic field in the relay coil collapsing????
Yes, a snubber diode is what they call them. Very important when connecting to any large inductive load.
 
Last edited:
Pommie, Correct me if I'm wrong (i might be showing off my newbie-ness here), but my understanding of transistors was that the emitter voltage only matches the voltage at the base. If the PIC is sending 5v to the base, wouldn't that mean only 5v can flow through the relay coil circuit in the setup you described, despite the 12v at the collector?

Had to go back and make sure I said to connect the relay between 12V and collector. Pheew.

With a little help from a diagram stolen from .
**broken link removed**
I started to write an explaination but realised the best thing for you to do is read Nigel's tutorial.

Mike.
 
I was thinking the same thing about the different "states" of the outputs to cleanup/simplify the code a bit, I'm glad you kind of confirmed I was on the right track.

do not think of it as "states of outputs" but the "state of the device"... your device will be in stateX and in stateX it might output different things.... draw a graph of all states your machine can be in, link the states with arrowed lines (every line is possible change state) and write on the line "when" the device changes state (on what event) .. this will make the programming much easier... read:
State diagram - Wikipedia, the free encyclopedia
Finite state machine - Wikipedia, the free encyclopedia

And for a regulator, I bought a 5v regulator at Radio Shack a while back that I'm not using (looks just like a transistor), but I swear I remember reading somewhere about a 5v regulator that was made specifically for automotive use, I think because of the unstable voltage values in automotive systems, or something along these lines.

The simple 7805 might work (I used it in few "not important" projects in the car) but some more specialised regulator should be used imho, for example: TA14832

screenshot1-png.25369
 

Attachments

  • screenshot1.png
    screenshot1.png
    61.6 KB · Views: 626
  • 83984_1.pdf
    87.2 KB · Views: 227
Status
Not open for further replies.

Latest threads

Back
Top