tiptronic gearbox controller safety

Basically I’m building a tiptronic gearbox controller for my car, it consists of 3 solenoids inside the gearbox and 2 momentary push buttons.
2 solenoids control the gear changes, the other solenoid controls the torque converter lock up.

I’ve managed to write a code that works quite well when set up on a bread board but I cant work out how to stop it from cycling through the gears when the momentary switch is held down.

I’ve tried a few different ways to stop it with no success, were would I put it in the code and what would be the best way of doing so.

here is the code I have written:

int gear = 1;
int relay1 = 4;
int relay2 = 5;
int relay3 = 6;
int gearup = 2;
int geardown = 3;

int state = 1;

void setup() {
  pinMode(relay1, OUTPUT);
  pinMode(relay2, OUTPUT);
  pinMode(relay3, OUTPUT);
  pinMode(gearup, INPUT);
  pinMode(geardown, INPUT);

}

void loop() {

  if (gear == 1) {
    digitalWrite(relay1, 0);
    digitalWrite(relay2, 1);
    digitalWrite(relay3, 1);
  }

  if (gear == 2) {
    digitalWrite(relay1, 0);
    digitalWrite(relay2, 0);
    digitalWrite(relay3, 1);
  }

  if (gear == 3) {
    digitalWrite(relay1, 1);
    digitalWrite(relay2, 0);
    digitalWrite(relay3, 1);
  }

  if (gear == 4) {
    digitalWrite(relay1, 1);
    digitalWrite(relay2, 0);
    digitalWrite(relay3, 0);
  }

  if (gear == 5) {
    digitalWrite(relay1, 1);
    digitalWrite(relay2, 1);
    digitalWrite(relay3, 1);
  }

  if (gear == 6) {
    digitalWrite(relay1, 1);
    digitalWrite(relay2, 1);
    digitalWrite(relay3, 0);
  }

  delay(100);

  gear += digitalRead(geardown);
  gear -= digitalRead(gearup);
  if (gear < 1) gear = 1;
  if (gear > 6) gear = 6;


 
  
  delay(150);
}

kieran

Standard warning!

Adding ad-hoc attachments to your car's critical systems will almost certainly invalidate your insurance - and warranty if any though I doubt it is still under warranty. :roll_eyes:

kieran4x4: I cant work out how to stop it from cycling through the gears leds

I'm going to pretend that said leds and that this isn't part of a 2-ton lump of metal hurtling along at high speed.

Don't do this:

gear += digitalRead(geardown);
  gear -= digitalRead(gearup);

... but do this instead. Only increment or decrement gear when either of those buttons becomes pressed; then you can hold it down as long as you like, with only 1 count.

Paul__B: Standard warning!

Adding ad-hoc attachments to your car's critical systems will almost certainly invalidate your insurance - and warranty if any though I doubt it is still under warranty. :roll_eyes:

my vehicle has already got a bespoke ecu for the engine with a insurance policy that covers all of the modification that ive done to it including lpg conversion and a supercharger, ive spoken to the insurance about a gearbox controller and as long as it caries the relevant safety precautions then they are happy to continue to insure me, if there is any malfunctions with the system it locks its self in 4th gear using the factory modified gearbox ecu.

hannah_mackinlay: Don't do this:

gear += digitalRead(geardown);
  gear -= digitalRead(gearup);

... but do this instead. Only increment or decrement gear when either of those buttons becomes pressed; then you can hold it down as long as you like, with only 1 count.

i understand what your saying but how would i translate that into the code?

Are you sure on the safety aspects ? What if your Arduino decides to shift down a couple of gears at 80mph or go into park ? What failure modes are you considering ?

The insurance companies view on “ relevant safety precautions” really needs expanding .

kieran4x4: i understand what your saying but how would i translate that into the code?

Did you follow the link I gave?- it explains how to look for a pin to "become" a value rather than "be" a value.

hammy: Are you sure on the safety aspects ? What if your Arduino decides to shift down a couple of gears at 80mph or go into park ? What failure modes are you considering ?

The insurance companies view on “ relevant safety precautions” really needs expanding .

The gearbox cannot go into Park while driving as selecting park,neutral and drive are done via a mechanical linkage. Not electrical.

hannah_mackinlay: Did you follow the link I gave?- it explains how to look for a pin to "become" a value rather than "be" a value.

Sorry I didn't see the link as I was viewing on my phone, will have a look on the laptop now, thanks

kieran4x4: The gearbox cannot go into Park while driving as selecting park,neutral and drive are done via a mechanical linkage. Not electrical.

In regard to "Park", that should be self-evident. :astonished:

But what about Reverse, which is between Neutral and Park?

dillonj1777: Hmm have this been worked out yet?

Has WHAT been worked out yet? How we can smell SPAM from a long way away? ;)