END command

hippy

Ex-Staff (retired)
I do have a little knowledge of insurance companies from a friend who worked for one (UK). Their attitude was that any modification which they were not informed of invalidated the insurance though they had discretion on that. There's usually a clause in the insurance policy that you must inform them of any modifications. So basically you are at their mercy and facing potential litigation should you not agree with how they see it should the situation arise.
 

Dippy

Moderator
Chippy: fair enough, I only came in on this at the end and had a quick read of your first couple of posts where you mentioned having a button but didn't want to power-cycle. Confession: I only just noticed you mention 08M.

I'm now confused as you imply (or I inferred) you now don't want a button. Or did you want the PICAXE to pop out of 'sleep' when you press the ignition button?
Sorry, I'm lost. I'll go away now and have a lie down 8000 miles away:) (Ah, if only....)

Hippy: Yes, I see your point. Good eyesight. Basically, you're saying they could wriggle out if any add-ons don't have 'approval'. Fair enough. Judging by some projects I have seen I don't blame them.

I was going to take out a 'false claims' lawsuit against the manufacturers of Viagra - it would be the only time in history that anyone won an action when something wouldn't stand up in court.
 

chipset

Senior Member
yeah I want ONE single button. When the car is off and you press the switch I want it to wake up and start doing its thing. I can use a relay to open the power circuit for a moment to cycle power or just let it loop.
 

Dippy

Moderator
So, how about a loop at start of code with a pin-status-test in it? When button is pressed it pops out and does its thing.
When its finished doing its thing it goes back to loop and waits for next button-press.

If it can only do its thing when the car is OFF then a simple power sense wire pot/div and a drop of code will sort that.

Does it need to stop doing it's thing if ignition turned on? - simple interrupt will sort that.

Bear in mind I haven't got a clue as to what it will be doing OR why it is doing it OR how long it will be doing it for - so I may have wrong end of stick.

Just take care that the button sense part isn't electrically triggered by noise, cellular phones etc.
But thats a simple bit of electronics.
 

hippy

Ex-Staff (retired)
My take on it ...

Ignition1.bas - implements your specification with the exception of the double-push within one second ( we'll come back to that ). Fixed the missing specification clause that ACC should turn on after the starter stops turning ( the release in Step Three ). Note that Step Four is an 'instant off' as soon as the button is pushed which you probably don't want in practice; the merest knock or noise induced button push will cut the engine when travelling at speed. Likewise a noise induced button push may sequence through Steps and kick the starter unexpectedly which is not a good idea.

I attempted to implement the double-push within one second which works when going from Step One to Step Two but is flawed when going from Step Two to Step Three. You have a specification problem in that you cannot implement the functionality in the manner described as it is in conflict.

Ignition3.bas - is how I'd do it. Instead of double-click, a short push will turn everything off in Step One or Two while a concerted push is needed to get to the next step. A prolonged two second push starts the engine ( I'd actually increase that time ). Once the car is started, a concerted push is needed to turn it off. Likewise a concerted push is required to turn the ACC on in the first place.

This is all implemented as a Finite State Machine (FSM) similar to how your own code was intended to work but puts all timing within the GetButton routine. The FSM states simply react according to the 'timeHeld' variable, zero if button is not pushed an indicator of how long it has been pushed.

I'd add a timeout when ACC+IGN on and no starter to turn off IGN, though I'd probably be inclined to skip Step Two all together as the need to go through ACC+IGN is simply a throwback to a mechanical keyswitch system; use Off -> ACC -> IGN/STARTER -> ACC+IGN -> Off.
 

Attachments

chipset

Senior Member
thanks Hippy. I thought about the double click idea and got rid of it. instead what I did was write the code to only move through the steps if the button is held for more than .5 seconds. Anyless and the car is turned off. It is set though to wait .1 seconds though to filter switch bounce. I suppose any noise that could turn it off could be filtered out via this delay as well. I just tyhough it would be safer to impose a time sensitive hold on the button in order to make sure it was being pressed intentionally and not add in features that could potentially cause problems. Ill look through your .bas when I get home and see what will work for me though. Thanks a ton youve been a lot of help:D
 

chipset

Senior Member
heres my finalized code hope the PIC just looping at the top will be fine as far as current draw for extended periods of time. And just to reiterate, this module makes the rest of the car turn on so anything made to sense voltage to turn it on or the like wont work. If you consider this in the strict sense that the only input the pic can have is from one and only one button then you can see where Im at. The code in and of itself is pretty much done and works good in the simulator, at this point all I have left to do is figure out the PCB design and the necessary power circuits to filter noise and other bad stuff. Ill start a new thread strictly about vehicle power stage circuits to get a wider audience on the subject. Hell we got more than a few pages just about that subject which is TOTALLY off topic lol.

Code:
main:						;label
low 0 					;turn of ACC
low 1
do 						;start loop
loop until pin3 = 1			;loop until button is pressed
pause 100					;wait for debounce
do 						;start loop
loop until pin3 = 0			;loop until button is let go
goto ACC					;go to ACC step
acc:						;label
high 0					;turn on ACC relay
do 						;start loop
loop until pin3 = 1			;loop until button is press
pause 100					;wait for debounce
if pin3=1 then				'Is pin3 high?
	for b0 = 1 to 5			'Run this loop to make sure the button is held down
		pause 100			'Pause 0.1 seconds
		if pin3=0 then main 	'If the button has been released then goto main and start over
	next					'Loop round (part of for b0 = 1 to 20)
	goto preign				'If the button has been held down then goto preign
endif
goto main		
preign:
do loop until pin3=0
goto ign

ign:
high 1
do 
loop until pin3=1
if pin3=1 then				'Is pin3 high?
	for b0 = 1 to 5			'Run this loop 5 times to make sure the button is held down
		pause 100			'Pause 0.1 seconds
		if pin3=0 then main 	'If the button has been released then goto ing
	next					'Loop round (part of for b0 = 1 to 5)
	goto starter		'If the button has been held down for .5 seonds then goto starter
endif
goto starter
starter:
low 0
high 1
high 2
do
loop until pin3 = 0
if pin3 = 0 then goto RUN
run:
high 0
low 2
do
loop until pin3 = 1
pause 100
do 
loop until pin3 = 0
low 0
low 1
goto main
 
Top