Pages: 1 [2]   Go Down
Author Topic: Remote vehicle ignition - code help.  (Read 1823 times)
0 Members and 1 Guest are viewing this topic.
Seaford, Victoria, Australia
Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Isn't it possible to create a global rule etc, so once after the 5second delay, the rule is if the alternatorPin is low, the ignitionPin is set high until the alternatorPin goes high?
Then so long as the alternatorPin is HIGH, it waits either 10 minutes or for a brakePin to go HIGH, then loops the code back to the beginning waiting for another serial input?
Logged

Seaford, Victoria, Australia
Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've done a little reading on state machines.
I guess the tables for this would be as follows. completly scrap the brakePin, and instead use a 10 minute delay, if the user isn't in the car with the key in and switched to ON, then bad luck, he/she has to start the vehicle again.

State0: onPin = off, ignitionPin = off, alternatorPin = LOW.
Upon recival of serial command, go to state 1.

State1: onPin = on, ignitionPin = off, alternatorPin = LOW.
after 5 seconds go to state 2.

State2: onPin = on, ignitionPin = on, alternatorPin = LOW.
once alternatorPin becomes HIGH, go to state 3, if alternator pin is alrady HIGH, go to state0 (in case if someone floods the serial)

State3: onPin = on, ignitionPin = off, alternatorPin = HIGH.
once 10 minutes has elapsed go to state 0

Does this seem right?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 640
Posts: 50335
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Does this seem right?
It looks pretty good to me. Make sure that you have considered all possibilities. To ensure that you have, find a 10 year old, and have them start the car, using only the instructions that you have written down. If the 10 year old can start the car, without damaging anything, then the Arduino should have no problems starting it.

Test each part of the code separately, before trying to combine all the code into one program.

For instance, make sure that you can detect each switch, and that the alternator is read correctly, after starting the car manually. Make sure that the relays open and close when they are supposed to, with nothing connected to them. Make sure that they still open and close correctly with a load on them.
Logged

Seaford, Victoria, Australia
Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
find a 10 year old, and have them start the car, using only the instructions that you have written down.
Are you being sarcastic?

The way i'm wireing is is by having a seperate set of relays, along side the ones the car has. if the car is to be started manually, which will happen most of the time, the arduino has nothing to do with it.
The arduino only controls it's own relays based on the serial command.

Well, like i said, i know very little about C++ or any programming for that matter.
So a little help with the actual code would be nice, if it's not too much trouble?
Logged

Seaford, Victoria, Australia
Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

And, the wireing side of this is completed, i've tested the relays by controlling them individually over wifi. i'm just in the middle of having a proper pcb for the arduino's power supply made.
I'm just stuck on the code.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 309
Posts: 26496
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Are you being sarcastic?
No, I don't believe he is, just overestimating the reasoning powers of an Arduino.

Seriously, that's what it boils down to - clear, unequivocal instructions that can be followed by an entity that will do exactly what it is told to do, time and time again.
Unlike a ten year-old.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Seaford, Victoria, Australia
Offline Offline
Jr. Member
**
Karma: 0
Posts: 51
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I see.

This still hasn't gotton me anywhere.
Like i've stated, i really don't have the time to learn a complete programming language to make just one arduino project.
I started reading C++ tutorials, but that hasn't helped me whatsoever, i already know what int's, loops and setups are.
And as you've already seen, i know an extremly small ammount already.

What i'm asking is for someone to help me/guide me to write this code, maybe even some code snippets, or writing some of the code and explaining it. i've only ever learnt things parrot fashion, to be honest, i did very poorly in language and math class at school. And nothings changed since.

If anyone is willing to spare some time, that would be excellant, i could even pay for some help.

Regards, Matt.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 640
Posts: 50335
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Are you being sarcastic?
No. My point was that older people generally already know how to start a car. They will automatically fill in missing steps. For example. if you tell an adult to insert the key, rotate to the ignition position, then rotate a bit farther to the start position, wait 5 seconds, then rotate back, the adult will know that you mean wait no more than 5 seconds to rotate back. They will rotate back as soon as the engine starts.

They will know what it takes to set the choke, if the vehicle has an automatic choke.

The 10 year old will know none of these things, so you will need to provide very clear directions - the kind that can be implemented in code.
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Like i've stated, i really don't have the time to learn a complete programming language to make just one arduino project.


If you're doing this yourself then you really do need to learn that. It's a project that has scope to go wrong quite impressively if you don't know what you're doing.

If you really don't fancy taking on the code yourself them perhaps you should move this discussion to gigs and collaborations and make it clear you're asking for somebody to take it on for you.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Pages: 1 [2]   Go Up
Jump to: