Motorcycle. DIY Quickshifter using Arduino.

Discussion in 'Automotive Electronics' started by David Schofield, Oct 13, 2016.

  1. David Schofield

    Thread Starter New Member

    Sep 1, 2016
    13
    0
    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
     
  2. tcmtech

    Well-Known Member

    Nov 4, 2013
    2,033
    1,622
    It looks like a way overly complicated way of doing what could easily be done with a simple 555 or even a Op-Amp IC and a few resistors and capacitors.
     
  3. David Schofield

    Thread Starter New Member

    Sep 1, 2016
    13
    0
    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
     
  4. tcmtech

    Well-Known Member

    Nov 4, 2013
    2,033
    1,622

    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.
     
  5. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,793
    829
    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?
     
  6. David Schofield

    Thread Starter New Member

    Sep 1, 2016
    13
    0
    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.
     
  7. joeqsmith

    New Member

    Oct 15, 2016
    10
    0
    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.
     
  8. David Schofield

    Thread Starter New Member

    Sep 1, 2016
    13
    0
    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.
    Code (C):
    1.  
    2. // ONE_SHOT. Fast motorcycle gearchange, gear change is punched through and motor is killed for selected milliseconds as soon as gear
    3. //lever moves from rest position as detected by a microswitch or proximity sensor
    4.  
    5. #define SwitchReaderPin 2    //read foot switch pin
    6. #define HoldoffTime 100      // Once a switch change is detected pulse is sent to FET, so don't allow another pulse until gearchange is made
    7. #define  PulseOutPin 11      //switch the MOSFET
    8. #define OneShotMillis 60     //pulse length of one shot
    9.  
    10. //these three for holdoff timing,
    11. unsigned long timer;
    12. long elapsed_time;
    13. long wait_time;
    14.  
    15. // LEDs
    16. int green = 7;
    17. int red = 8;
    18.  
    19. void setup()
    20. {
    21.   pinMode(PulseOutPin, OUTPUT);             //setup the pin for switching MOSFET
    22.   pinMode(SwitchReaderPin, INPUT);          //setup the pin for the gear linkage ssensor
    23.   pinMode(green, OUTPUT);
    24.   pinMode(red, OUTPUT);
    25.   digitalWrite(PulseOutPin,LOW);            // TURN ON THE MOSFET or engine won't start!
    26.   digitalWrite(green,HIGH);
    27.   digitalWrite(red,LOW);
    28.   timer = millis();       // this puts amount of milliseconds since turn on into variable "timer"
    29. }
    30.  
    31. void loop()
    32. {
    33.   while ( digitalRead(SwitchReaderPin) == HIGH ) //we continually poll the switch, always high with pull up resistor. loop away doing NIX until pin goes LOW
    34.   {      //do  nix just now
    35.   }
    36.  
    37.   //gone low, so now do the one-shot
    38.    cut_ignition();
    39.  
    40.   //holdoff is effectively debouncing contacts. A simple fixed delay may work just as well here
    41.   elapsed_time = millis() - timer;      //time elapsed since last read
    42.   wait_time = HoldoffTime - elapsed_time;   // are there any extra milliseconds to go before chosen holdoff time is past.
    43.   if (wait_time > 0 )
    44.   {
    45.       delay(wait_time); //wait those extra millis
    46.   }
    47.   timer = millis();
    48.  
    49.   ///Next is safety check. Dont move on until switch is released.
    50.   //stops continuous engine kill if gear lever rests against switch, eg, guarantee a one-shot.
    51.   //also stops a second one shot as switch bounces on release
    52.   while ( digitalRead(SwitchReaderPin) == LOW ) //we continually poll the switch,always high with pull up resistor.
    53.    {
    54.       //loop away doing NIX until pin goes HIGH again
    55.    }
    56.    delay(30);
    57. }
    58.  
    59. void ignition_on() {
    60.    digitalWrite(PulseOutPin,LOW);   // Ignition on
    61.    digitalWrite(red,LOW);
    62.    digitalWrite(green,HIGH);
    63. }
    64.  
    65. void ignition_off() {
    66.    digitalWrite(PulseOutPin,HIGH);  // Ignition off
    67.    digitalWrite(green,LOW);
    68.    digitalWrite(red,HIGH);
    69. }
    70.  
    71. void cut_ignition() {
    72.    ignition_off();
    73.    delay(OneShotMillis);
    74.    ignition_on();
    75. }
    76. ///////////////////////////////////////////////////////////////////////////////////////////////
    Mod edit: code tags
     
    Last edited by a moderator: Oct 16, 2016
  9. tcmtech

    Well-Known Member

    Nov 4, 2013
    2,033
    1,622
    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:
     
    shortbus likes this.
  10. joeqsmith

    New Member

    Oct 15, 2016
    10
    0
    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.
     
  11. David Schofield

    Thread Starter New Member

    Sep 1, 2016
    13
    0
    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).
     
  12. shortbus

    AAC Fanatic!

    Sep 30, 2009
    4,003
    1,518
    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.
     
  13. joeqsmith

    New Member

    Oct 15, 2016
    10
    0
    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?
     
  14. tcmtech

    Well-Known Member

    Nov 4, 2013
    2,033
    1,622
    Re read what I said and how it worked. :rolleyes:

    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.
     
    Robert Murphy and shortbus like this.
  15. tcmtech

    Well-Known Member

    Nov 4, 2013
    2,033
    1,622
    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.
     
  16. joeqsmith

    New Member

    Oct 15, 2016
    10
    0
    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.
     
  17. tcmtech

    Well-Known Member

    Nov 4, 2013
    2,033
    1,622
    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.
     
  18. Sensacell

    Well-Known Member

    Jun 19, 2012
    1,127
    266
    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.
     
  19. joeqsmith

    New Member

    Oct 15, 2016
    10
    0
    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.

    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...
     
  20. joeqsmith

    New Member

    Oct 15, 2016
    10
    0
    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?
     
Loading...