DIY Analogue Handbrake (old G25 shifter)

Discussion in 'Sim Racing Hardware' started by Tony Liddell, Dec 13, 2017.

  1. Tony Liddell

    Tony Liddell

    Messages:
    56
    Ratings:
    +10
    Hello racefans

    I've built myself an analogue handbrake using my old, dysfunctional G25 shifter, an Arduino ProMicro controller, a micro-USB cable and an AMSTUDIO YouTube video tutorial called "How to make a USB analogue handbrake." Here's how:

    I was going to buy a Driving Force Shifter and use that, but came across a pre-owned G27 shifter on a local online forum. The bottom half of the G25 and G27 shifters are identical, down to the last screwhole, so I transplanted the G25 sequential gate and microswitch onto the G27 base. The only difference is the plastic sleeve design on the shifter shaft. The very top 3mm on the G27's is held on by two screws, and this needs to be removed or else it stops the shifter from getting into 1st and 5th gear. Easy peasy. I plugged the connectors from the bottom half of the G27 shifter into the G25's top half circuit board, screwed it all together, and now have a fully-functional G25 shifter.

    [​IMG]

    On to the handbrake. I removed the metal hard-mount points from the shifter, drilled a couple of holes through the bottom of the casing, and reattached them closer to the centre of the casing with bolts from the bottom, attaching two strong springs between them and the shifter shaft using zip-ties.

    [​IMG]

    Once I'd removed the G27 cable from the casing, I removed the connector attached to the end of the wires coming from the potentiometers (pots) on the shifter shaft. The wires are different colours, so it's quite easy to tell which is coming from where. The black wire is ground, as far as I can tell. Using a multimeter, I identified the wires coming from the pot that measures the up/down movement of the shaft (the one on the right-hand side of the shaft) and soldered these to a Arduino ProMicro board using amstudio's YouTube video as a guide. DON'T NECESSARILY USE HIS WIRE COLOURS. You must solder the correct wires to the correct connectors or you will get strange (not dangerous though) results. I gather that the pots have the same range and resistance as the sliding type that AMSTUDIO uses in his video, so the code included in his video description should work without any editing.

    [​IMG]
    [​IMG]

    I tried the Arduino Web Editor without success, and therefore recommend downloading the Arduino IDE. Here's the code I ended up with (you will need to copy the DynamicHID folder and the Joystick folder to the Arduino "libraries" folder in the Arduino installation folder on your computer, as the code refers to these libraries). I can monitor the input from the pot and I've added some dead zone at either end of the range. With the help of Martin Fiala and Dave Williams here at RaceDepartment I got it to work with WRC7 too, by getting it to fake a button-press halfway through the range. See their contributions in this post.

    [​IMG]
    [​IMG]
    I have tested Assetto Corsa, Automobilista, Dirt 4, Dirt Rally, Project Cars 2, Richard Burns Rally and WRC7. Finally I have some control at the hairpins!
     
    Last edited: Dec 14, 2017
    • Like Like x 2
  2. Emil Pribanić

    Emil Pribanić

    Messages:
    309
    Ratings:
    +229
    Nice work. I did mine analogue handbrake also guided by Amstudio idea and its working perfect. Only bad is that i cant make it work in WRC 7.
     
  3. Tony Liddell

    Tony Liddell

    Messages:
    56
    Ratings:
    +10
  4. Mr. Vermeer

    Mr. Vermeer

    Messages:
    4
    Ratings:
    +4
    I was wondering why you have the DynamicHID library included in the Arduino code. Looks to me like it's not being used.
    You've also included Joystick.h twice..
     
  5. Tony Liddell

    Tony Liddell

    Messages:
    56
    Ratings:
    +10
    Ignorance! :redface:
    Please feel free to improve the code and post it here :thumbsup:
     
  6. Mr. Vermeer

    Mr. Vermeer

    Messages:
    4
    Ratings:
    +4
    Hi Tony,
    I've made some adjustments to the code:
    - removed unused inclusion
    - added check so button properly toggles between states

    IT IS UNTESTED! I don't have a test board, so do a test before implementing it.


    Code:
    #include <Joystick.h>
    
    // Last state of the buttons
    const int pinToButtonMap = A0; //UNUSED, could be removed
    int lastButtonState = 0;
    
    Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,JOYSTICK_TYPE_JOYSTICK,
      1, 0,                  // Button Count, Hat Switch Count
      true, false, false,    // X axis, but no Y and, Z
      false, false, false,   // No Rx, Ry, or Rz
      false, false,          // No rudder or throttle
      false, false, false);  // No accelerator, brake, or steering
    
    
    void setup() {
      // Initialize Pins
      pinMode(A0, INPUT);
     
      // Initialize Joystick Library
      Joystick.begin();
    }
    
    
    void loop() {
    
      int pot = analogRead(A0);
      pot = constrain(pot, 50, 750);
      int mapped = map(pot,50,750,0,255);
      Joystick.setXAxis(mapped);
    
      int currentButtonState = 0;
    
      //if more than half way along travel, set buttonState to 1.
      if (mapped >= 127) {
        currentButtonState = 1;
      }
    
    
      // make sure we only change once
      if (lastButtonState != currentButtonState) {
          Joystick.setButton(0, currentButtonState);
          lastButtonState = currentButtonState;
      }
     
    
      // can be removed, just useful for debugging
      {
        Serial.print ("XAxis:");  // prints text
        Serial.print (' ');        // prints a space
        Serial.print (pot);       // prints current byte value
        Serial.print ("\n");       // prints a newline
      }
    }
    
     
    • Like Like x 1
  7. Mr. Vermeer

    Mr. Vermeer

    Messages:
    4
    Ratings:
    +4
    So, in the last couple of days I set out to make a more advanced version of my personal shifter/handbrake combo. I haven't actually build it yet, but the microcontroller side is almost complete!

    What I wanted was:
    - A single board to interface both the shifter knobs and handbrake potentiometer
    - Create a GUI for adjusting the response of the handbrake and setting a deadzone

    The GUI was made in Processing using the ControlP5 library for easy sliders and buttons. I chose Processing to easily generate a Mac and PC version.

    The GUI talks to the Pro Micro via Serial using a custom 'command' system. Every slider and knob sends a string with a specific format to the Pro Micro. This string is parsed by the Pro Micro to change various varables.

    The command message protocol is as follows:
    Code:
    #NAME0000\n
    The hash is to define the start of a command. It's followed by a command name and than a 4 digit integer. The '\n' is to flag the end of the command.

    For example, I made a slider that changes the skew of the response curve. The slider's range is from 0 to 767 (might change the maximum for more curvier.. curves). When the slider's knob is released, a string is written over the Serial port which would look like "#SKEW0231\n".
    The Pro Micro filters on NAME and executes the relevant code.

    Pretty neat.

    As of now, the settings aren't stored by the Pro Micro, so you have to run the GUI and select the settings every time you replug the Pro Micro to the computer. I will add EEPROM storing later.

    If anybody is still reading and interested, you can check out my Github for all the source code.
    https://github.com/mohragk/Shifter_Handbrake_DIY/tree/master/New_Handbrake_update

    Have any questions, feel free to ask!
     
    • Like Like x 1
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.