Make outputs short to ground

So I am busy making a caferacer from a BMW K75. Part of this project is replacing the original speedometer with an aftermarket one. However, BMW has some odd schematics which I need to work around, for instance it won't even start without the original speedometer since this also houses a circuit which checks whether you are in neutral, in gear, if the sidestand is out etc.
This one I have allready found a workaround for with some relays. However, the gear position sensor is where I am running into some trouble and I am looking for tips and advice.

Some background info: The new gear indicator works quite easy. For every gear it has one lead which, once shorted to ground will show the gear the bike is in (under condition only this lead is shorted to ground). The sensor on the bike however as 3 contacts, lets call them contact 1, 2 and 3. Inside the original speedometer there is a circuit which "calculates" which gear is selected by checking which combination of these 3 contacts are shorted to ground.
Here is the schematic:
1st gear: 1, 2 and 3
Neutral: 1 and 2
2nd gear: 1 and 3
3th gear: only 3
4th gear: 1 and 2
5th gear: Only 2

Now I am planning on (hopefully) using an arduino nano or micro where these 3 lines come in, write a code to "decode" the combination and have it put out the signals to 6 different leads (5 gears and 1 neutral). These outputs however need to be shorted to ground, so I was thinking of using 6 relays, one for each output and have these short to ground instead to make this possible but I am wondering if this even is possible since the input is also a short to ground.

Any thoughts?

The design for the input and output will be separate.

You can wire those inputs to a digital pin (through a level converter or transistor if they're 12V) and just read them high or low. When grounded they'll read low. You can write code to determine from which of the three inputs is currently reading low what gear you're in.

The outputs are driving leds. There are lots of examples for all different sorts of leds. Your arduino will output low or high on an output pin to turn them on or off. The logic will depend on how you connect it. But it isn't any different from driving any other led.

wouldn't this cause every pin to be considered "low"? I am sorry if this is a nooby question, I am quite familiar with circuitry but am a novice in coding haha

Decoding the contacts looks like an example of where a switch statement could be used.
See the following fragment. This assumes a low on the contact means it is on.




//
// shift inputs
//
const int CONTACT1 = 5;   //  example - someInPutPin
const int CONTACT2 = 6;   //  example - someInPutPin
const int CONTACT3 = 7;   //  example - someInPutPin
//
// Decode for contacts
// We use the shift input contacts to generate a 3 bit number to represent
// the current state of the gearbox.
// 
// Gear      contact3 contact2 contact1    value
// neutral      0        1        1          3   << same as gear4 one of them is wrong
// 1            1        1        1          7
// 2            1        0        1          5
// 3            1        0        0          4
// 4            0        1        1          3 
// 5            0        1        0          2
//
//const uint8_t NEUTRAL = ??;
const uint8_t  GEAR5 = 2;
const uint8_t  GEAR4 = 3;
const uint8_t  GEAR3 = 4;
const uint8_t  GEAR2 = 5;
const uint8_t  GEAR1 = 7;

//  need to add neutral 


void setup() {
  // Set serial output for debug
  Serial.begin(9600); 
  pinMode(CONTACT1,INPUT_PULLUP); 
  pinMode(CONTACT2,INPUT_PULLUP);
  pinMode(CONTACT3,INPUT_PULLUP); 

}


void loop() {

  // declarations and assorted code



  uint8_t currentGear;   // declare currentGear for use is switch

  // the following code reads the contacts and ORs the bits together to get the current state
  currentGear = (digitalRead(CONTACT1) == LOW) ? B00000001:0; // encode contact 1
  currentGear = currentGear | (digitalRead(CONTACT2) == LOW) ? B00000010:0; // encode contact 2
  currentGear = currentGear | (digitalRead(CONTACT3) == LOW) ? B00000100:0; // encode contact 3

  switch (currentGear){
 /*   Need to define NEUTRAL
     case NEUTRAL: {
      // do stuff for neutral
      break;
    }
 */   
    case GEAR1: {
      // do stuff for gear1
      break;
    }
    case GEAR2: {
      // do stuff for gear2
      break;
    }
    case GEAR3: {
      // do stuff for gear3
      break;
    }
    case GEAR4: {
      // do stuff for gear4
      break;
    }
    case GEAR5: {
      // do stuff for gear5
      break;
    }
    default: 
      // invalid state -- indicate error
      break;
    }  
    
    // possibly more code
    
 }

Wouldn't what cause what pins to read low.

No. The pins that are pulled to ground read low. The others read high.

This is a circuitry issue. If you were going to measure with a multimeter the three inputs. You'd put one probe to ground and then put your red probe to them one at a time. If you put them to three separate digital inputs and make sure that the ground is connected to the Arduino ground then that's the same thing.

Reading them in code is a single line. digtalRead. You don't need much expertise to use it.

That is not a schematic...............
The problem with long drawn out explanations is they can be interpreted in several different ways....draw a diagram.
Another point to consider is Arduino cannot be used where safety is a concern (life threatening etc.) and your fiddling could cause this to come about.

Aah okay I get it. Thank you very much!

Wow thank you! This is really helpful. Will be playing around a bit with this!

I'm sorry, english is not my native language so my apologies for getting the term wrong. And no, this is not a safety concern, I ride myself and I take safety seriously. Getting into a crash or injuring anyone is not a concern as the only thing I am interested in is getting the bike to work as intended only with some more up to date digital information clusters. So no, my fiddling won't cause life threatingen situations.

@GJ_Hoogeveen
Forget the Arduino, software, relays, etc
All you need is a 3 to 8 decoder (16 pin DIP IC) some resistors and a few transistors

2 Likes

The code I showed is sort of a software equivalent of a 74LS138 3 to 8 decoder.

Thank you very much! This indeed seems like a better option. Got a bit of tunnelvision that I forgot to look any further haha. Will need to figure out what ohms the resistors should be and whatnot but this should make it a lot easier

Plus I don't think an arduino will survive the temperature extremes.
Mounted underneath the seat out in the hot sun near a hot engine

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.