I am on a team and we're working on a car. Our car has a motorcycle engine and its gear-shift mechanism is electronic, controlled by a microcontroller. Now, we are figuring how can we make the microcontroller know which gear the engine is on. We thought about calculating the ratio between engine's rpm and wheel speed, but this method can be imprecise in some situations. Is there any more accurate method?
If the engine had a gear position sensor or you were considering installing one, i'd assume you wouldn't be asking this question. Anyhow, still , if you can install one, that'd be your easiest option, - the sensor is a rotary potentiometer. Or you can use any other rotary encoders you please.
The method you mention can be made pretty accurate, though, i'd still like to know your worries. Compare the Engine RPM with your front or rear sprocket rotation to estimate the gear. Doing this before the differential removes any iffy conditions. You can use VR sensors or hall effect sensors for the same.
You need to account for clutching transitions in your code. Since it's an electronic system that's changing the gears, you already know when to check (when the ecu initiates a gear change) and which gear to expect. You should be able to get all this to work with rudimentary logic. I'l expand on this answer if needed. Please comment
I am not sure how you will make this work but you could keep track of the shift fork position or you could measure the angle of the shift drum.
Maybe you could install proximity sensors?