Motorcycle. DIY Quickshifter using Arduino.

Thread Starter

David Schofield

Joined Sep 1, 2016
32
Hi,

I have been working on building a DIY ignition interrupt module for a 4 stroke motorcycle engine. The engine is mounted into a racing sidecar chassis. I have managed to create a circuit on some stripboard which will cut the ignition when a sensor is activated.

Here is a diagram of the ignition system of the motorcycle. This is not exact, just my interpretation, I cannot change this bit of the circuit anyway.

Current_Bigger.png

My circuit will connect to this circuit at point C, and also I will cut the wire between points A and B and connect them to my board.

Here is a diagram of my circuit.

Capture.PNG

The sketch on the Arduino is configured to light up a green LED, connected to pin D9. Once the Arduino detects a LOW signal on pin D2 (when the sensor has been activated), the green LED will be turned off, the red LED on pin D8 will be turned on and also a HIGH signal will be sent out of pin D11 to the MOSFET driver, this will turn off the P-Channel MOSFET and cut power to the ignition coils. After a short period of time (60 ms currently). The Arduino will put everything back to the original state (MOSFET on, RED off, Green on).

I have connected this circuit to my bike, with a 12v bulb connected between the drain and source of the MOSFET. This works as expected, the bulb is turned off for a 60ms period. Once I connect the ignition wires to the MOSEFT, I start to experience false detections. D2 is going LOW when the switch is wide open. I can tell the arduino is detecting that this is going low because the Red LED comes on.

I suspect that this is due to back EMF from the power being cut to the primary circuit of the ignition coils. What can I add to the circuit to stop the false detections? I might be very much mistaken and it could be something else causing the false detections, however, it only occours when the ignition circuit is fed via the MOSFET.

Thanks in advance for any help.
David
 

Thread Starter

David Schofield

Joined Sep 1, 2016
32
It is likely over complicated, however I wanted the delay to be precisely adjustable, this can be done with the microcontroller code.

Also, I believe a simpler circuit would still be suffering from the back-EMF I am having trouble with, as it would still be connected to the primary ignition circuit which gets interrupted every time a spark is required. I presume there is some sort of protection built into the ECU to prevent this causing problems. I need this same sort of protection for my circuit.

I have ordered some rectifier diodes. I plan to add D2 as shown below. Do you think this will help?

Capture.PNG
 

tcmtech

Joined Nov 4, 2013
2,867
It is likely over complicated, however I wanted the delay to be precisely adjustable, this can be done with the microcontroller code.

Also, I believe a simpler circuit would still be suffering from the back-EMF I am having trouble with, as it would still be connected to the primary ignition circuit which gets interrupted every time a spark is required. I presume there is some sort of protection built into the ECU to prevent this causing problems. I need this same sort of protection for my circuit.

I have ordered some rectifier diodes. I plan to add D2 as shown below. Do you think this will help?

When dealing with milliseconds durations 555 IC's are more than accurate enough plus they're easily adjusted with a simple potentiometer.

Also they can be easily protected with little more than two diodes a resistor and a capacitor and they wont glitch out if they do get a surge or dip in voltage.
 

djsfantasi

Joined Apr 11, 2010
9,156
First, can you provide more detail on the sensor? I'd like to know exactly how it switches D2 to ground.

Particularly, does its input need to be debounced

Can you attach your sketch?
 

Thread Starter

David Schofield

Joined Sep 1, 2016
32
I tersted this circuit again today, it appears that it is not suffering from back EMF as I first thought. I didn't even connect the ignition circuit to the MOSFET but I am getting constant sensor detections. This is only when the engine is running. When the engine is stopped the circuit works perfectly.
 

joeqsmith

Joined Oct 15, 2016
63
Interesting project you are working on. Maybe you need to consider the RF being generated and enclose your setup in a metal box with some feedthrough caps.
 

Thread Starter

David Schofield

Joined Sep 1, 2016
32
The sensor is an NPN proximity sensor. When it detects metal within 4mm it completes the circuit to GND. And so pulls the D2 pin LOW.

This will be mounted near the gear linkage, so that the linkage moves towards the sensor when changing up gears, and senses at the correct moment. This will likely need some fine tuning but I am not close to this point yet.

Here is my arduino sketch.
C:
// ONE_SHOT. Fast motorcycle gearchange, gear change is punched through and motor is killed for selected milliseconds as soon as gear
//lever moves from rest position as detected by a microswitch or proximity sensor

#define SwitchReaderPin 2    //read foot switch pin
#define HoldoffTime 100      // Once a switch change is detected pulse is sent to FET, so don't allow another pulse until gearchange is made
#define  PulseOutPin 11      //switch the MOSFET
#define OneShotMillis 60     //pulse length of one shot

//these three for holdoff timing,
unsigned long timer;
long elapsed_time;
long wait_time;

// LEDs
int green = 7;
int red = 8;

void setup()
{
  pinMode(PulseOutPin, OUTPUT);             //setup the pin for switching MOSFET
  pinMode(SwitchReaderPin, INPUT);          //setup the pin for the gear linkage ssensor
  pinMode(green, OUTPUT);
  pinMode(red, OUTPUT);
  digitalWrite(PulseOutPin,LOW);            // TURN ON THE MOSFET or engine won't start!
  digitalWrite(green,HIGH);
  digitalWrite(red,LOW);
  timer = millis();       // this puts amount of milliseconds since turn on into variable "timer"
}

void loop()
{
  while ( digitalRead(SwitchReaderPin) == HIGH ) //we continually poll the switch, always high with pull up resistor. loop away doing NIX until pin goes LOW
  {      //do  nix just now
  }
 
  //gone low, so now do the one-shot
   cut_ignition();
 
  //holdoff is effectively debouncing contacts. A simple fixed delay may work just as well here
  elapsed_time = millis() - timer;      //time elapsed since last read
  wait_time = HoldoffTime - elapsed_time;   // are there any extra milliseconds to go before chosen holdoff time is past.
  if (wait_time > 0 )
  {
      delay(wait_time); //wait those extra millis
  }
  timer = millis();
 
  ///Next is safety check. Dont move on until switch is released.
  //stops continuous engine kill if gear lever rests against switch, eg, guarantee a one-shot.
  //also stops a second one shot as switch bounces on release
  while ( digitalRead(SwitchReaderPin) == LOW ) //we continually poll the switch,always high with pull up resistor.
   {
      //loop away doing NIX until pin goes HIGH again
   }
   delay(30);
}

void ignition_on() {
   digitalWrite(PulseOutPin,LOW);   // Ignition on
   digitalWrite(red,LOW);
   digitalWrite(green,HIGH);
}

void ignition_off() {
   digitalWrite(PulseOutPin,HIGH);  // Ignition off
   digitalWrite(green,LOW);
   digitalWrite(red,HIGH);
}

void cut_ignition() {
   ignition_off();
   delay(OneShotMillis);
   ignition_on();
}
///////////////////////////////////////////////////////////////////////////////////////////////
Mod edit: code tags
 
Last edited by a moderator:

tcmtech

Joined Nov 4, 2013
2,867
I got to thinking more about what you are trying to do I still think you are overdoing a simple concept.

Years ago I had a coworker that was into motorcycle racing and whatnot that had a quick shift setup on one of his motorcycles. All it was was a simple sealed micro switch rigged up next to his shift linkage that had a small ramp cam that tripped the microswitch button every time he hit the shifter.

When the linkage moved one way the ramp cam pushed the micro switch button for an instant cutting the ignition power as it passed over then when it went back the differnt angle of the ramp pushed the while micro switch over to the side just a bit so that it didn't cut the ignition on the return stroke as the linkage reset itself.

No electronics, no timers, no complicated fiddly sensitive components to false trip or fail. Just two wires and a microswitch with a simple mechanical one way tripping mechanism. Apparently it worked pretty well bieng a number of his racing buddies copied his design for their machines. :cool:
 

joeqsmith

Joined Oct 15, 2016
63
The simple switch as I understand would disable the ignition the entire time the shifter was moved. With a short pulse like OP is looking for, the engine would could be turned off for less time during each shift. This may be a good thing for racing.

Without there being any filter or shield, you could try say sample the switch every 100us or something, Wait for it to be stable for at least some number of samples in a row (1ms) before you act on it.
 

Thread Starter

David Schofield

Joined Sep 1, 2016
32
Thanks for the suggestion. I have looked at the sketch and it doesn't have any safeguards against noise. I can only poll the switch as fast as the arduino loops, but I can definitely add some sort of debouncing in there.

tmctech, thanks for the advice, and this circuit is doing exactly that (cutting power to the coils when a sensor is tripped). I just wanted to cut the ignition for a precise and adjustable amount of time. I realise this can be done with a 555 monostable circuit and pot, but having a value I can change in code is much easier (for me).
 

shortbus

Joined Sep 30, 2009
10,045
You also need to unload the gears(turn off the engine) before the actual shift is made. If not done the gears will stay engaged and make the shift slower, or bend the shift forks. I've seen many doing it like tcmtech said.
 

joeqsmith

Joined Oct 15, 2016
63
Using a hall like OP or a mechanical switch, I don't see how this would effect the timing enough to make a difference as far as bending a fork.

I assumed OP was using their foot to control the lever. How about some pictures of the bike?
 

tcmtech

Joined Nov 4, 2013
2,867
The simple switch as I understand would disable the ignition the entire time the shifter was moved.
Re read what I said and how it worked. :rolleyes:

but having a value I can change in code is much easier (for me).
So hooking up a laptop or cell phone and doing code changes out in the middle of nowhere is easier than turning a potentiometer with two fingers? Do explain. o_O

My understanding of racing is you want things to be as simple, durable and rugged as possible given the condition things have t work in. I can't see how an already shown to be finicky uC based circuit that needs an external hookup to change a simple setting could possibly meet that criteria.
 

tcmtech

Joined Nov 4, 2013
2,867
You also need to unload the gears(turn off the engine) before the actual shift is made. If not done the gears will stay engaged and make the shift slower, or bend the shift forks. I've seen many doing it like tcmtech said.
I was never in racing but I had the concept explained to me enough to agree with what you are saying. There has to be a certain preload on the shifting mechanisms to make the transmission do the full jump from gear to gear cleanly in the fraction of a second engine is powered down but not so much as to force it out of gear or bend internal components while still powered up.

The guy I knew had his set up so that when the ignition would be cut was adjustable in relation to where the shifter linkages was at and the cut out time was somewhat adjustable by how much of the cam ramp was in contact with the microswitch button as it moved across.

Depending on where the microswitch was positioned the mechanical preload was adjustable and by how much of the cam ramp protrusion was traveling across the micro switch button the ignition cutout time during the gearchange was adjustable as well.

As I said before, it was a simple but rather clever design that apparently got copied quite a bit in his circle of riding buddies.
 

joeqsmith

Joined Oct 15, 2016
63
Too much coffee and skimmed it. Would be interesting to see that cam setup. Seems complex but may have been easier to copy than some simple electronics.

Once OP has a number they like, maybe they don't adjust it?

It's interesting about shift timing. I assume you could apply some pressure to lever first, then blip the throttle and it would bump in. Likewise that you could blip the throttle first then apply some pressure.
 

tcmtech

Joined Nov 4, 2013
2,867
Would be interesting to see that cam setup. Seems complex but may have been easier to copy than some simple electronics.
It was basically a small bolt that went through the shift lever linkage that had its head ground into a rounded ramp on one side so it would push on the microswitch button as it went past it and a angled flat on the other side that pushed the microswitch body out to the side just enough to keep it from hitting the button when the linkage returned to center.

Maybe 10 minutes of work with a hand file to make it and the microswitch was on a small bracket with a spring behind it so it could move a bit. Simple, elegant and apparently it worked.
 

Sensacell

Joined Jun 19, 2012
3,432
Getting an MCU to function reliably in the context of an engine ignition system is harder than you might think.

Noise coupling into the system causes major haywire.

Simple is better.
 

joeqsmith

Joined Oct 15, 2016
63
I still can't envision it. Could you attach a simple sketch?

I would think that getting the electronics to work would not be too big of a problem if proper steps are taken.

There has to be a certain preload on the shifting mechanisms to make the transmission do the full jump from gear to gear cleanly in the fraction of a second engine is powered down but not so much as to force it out of gear or bend internal components while still powered up.
I was thinking about this and wonder if maybe they cut the transmissions differently from what your friend's was. I am used to running a back cut. The gears can not be forced apart once they are under load. You have to kill the motor to get them to unlock. Attached you can see how the dogs are cut. I had a little too much power for this transmission, note all the teeth missing...
 

Attachments

joeqsmith

Joined Oct 15, 2016
63
Here half of the dogs are removed with a pretty aggressive angle. Allowed for a shorter kill time. I suspect too much backlash for what OP is doing.

OP, do the rules require you to manually shift? Do they allow for anything besides the kill?
 

Attachments

Top