DIY G25 shifter interface with H-pattern, sequential and handbrake modes
20 20

211 posts in this topic

15 hours ago, depor said:

Trying the same thing, with the exact same sketch but somehow its not working for me....can get the gears to work besides the 6th, when i put into 6th or 7th, it always presses button 7...all the other buttons are always pressed. tried to debug, have been watching the code for hours but i cant figure what is happening. Do i need some kind of resistors? cause i got all connect directly to the board.

After alot of time lost, just realized that the pins 0 and 1 on the arduino are switched, tought it starts 0, 1, 2 etc, but its 1, 0, 2 etc...im not at home but im sure thats the problem. Feel such a noob ;)

Share this post


Link to post
Share on other sites

Yeah, I used this schematic: 523a1765757b7f5c6e8b4567.png

 

Let me know if it worked. For pedals and shifter you need some places which are already occupied for either one, so you need to solder some wires together. I thought it were a few 5V lines that I needed to combine.

I suggest you first try it out on a breadboard, and then make it final.

Share this post


Link to post
Share on other sites
On 2-11-2016 at 1:13 PM, depor said:

After alot of time lost, just realized that the pins 0 and 1 on the arduino are switched, tought it starts 0, 1, 2 etc, but its 1, 0, 2 etc...im not at home but im sure thats the problem. Feel such a noob ;)

And did it work out?

Share this post


Link to post
Share on other sites

Hey Guys!

Is it possible, to make it work with this board? Arduino copy

I already have this, so that would be great. I'm not a programmer, but I guess if I change the pin number in the code to the correct ones, then this will work too. I hope I'm not wrong. I just got a G29, and I can't use my G25 shifter anymore.

Share this post


Link to post
Share on other sites
My g27 does not have the original cable so I connected the cables of the x, y and z axes separately. I do not want to use the buttons, just the shifter. Can someone help me ?

I tried to put the code straight but it appears that a variable has not been declared .

 

In my connection the x-axis stayed with the red wire, the y-axis with the brown and the reverse gear button turned orange

 

123.PNG

1.jpg

2.jpg

3.jpg

Share this post


Link to post
Share on other sites

Hi Guys,

Newb to coding and I am running into major issue.  I have the Pro Mini 5v by Inland (this guy) and when I try to paste the code over I get an error while compiling:

"Arduino: 1.8.1 (Windows 7), Board: "Arduino Pro or Pro Mini, ATmega328 (5V, 16 MHz)"

C:\Users\TIM_DE~1\AppData\Local\Temp\arduino_modified_sketch_776978\G27_Pedals_and_Shifter.ino:8:36: fatal error: ./lib/G27PedalsShifter.h: No such file or directory

 #include "./lib/G27PedalsShifter.h"

                                    ^
compilation terminated.

exit status 1
Error compiling for board Arduino Pro or Pro Mini."

 

Do I just copy and paste the code?  compile?  or do i need to file in the:

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

 

Also, soldiering the wires on, do I use the power and grounding points from the write up, then just adjust the code for my pin out?  Any help would be very appreciated! 

 

 

Arduino Pro Mini copy.png

Edited by Dinkpit

Share this post


Link to post
Share on other sites

Hi Dinkpit.

You have to copy G27_Pedals_and_Shifter.ino:  file to an exact place. Maybe under the projects folder. Then open it with arduino.

But Aruino pro mini doesn't have usb port. So you can not use for usb joy. It will not work.

Share this post


Link to post
Share on other sites
On 4/22/2014 at 5:40 AM, pascalh said:

A few weeks ago my son switched from his old G25 wheel/shifter combo to a brand new Thrustmaster TX + F1 addon wheel. In the process he lost the G25 shifter that he used mainly for Nascar and MX5 racing. To get a working shifter, there were several choices:

We chose the latter option to have the best possible control on the gear shifting logic: the stock G25 shifting logic is somewhat buggy, leading to quite frequent mis-shifts. Having full control of the software also allows adding some new functions: a handbrake mode seems the most obvious as the G25 shifter has all the necessary hardware.

In the following posts I will explain all the steps required to build a G25 shifter to USB interface, based on a Teensy 2.0 board. This writeup is split into 5 chapters, each chapter being one post:

Hello I need some help. I did the g25 shifter mod to Teensy usb and it works good. I want add on a pressure sensor to Teensy usb for the add on hand brake as on this DIY http://www.isrtv.com/forums/topic/13770-diy-hydraulic-handbrake/http://www.isrtv.com/forums/topic/13770-diy-hydraulic-handbrake/ What wires from the pressure sensor 5v, ground, and signal to the teensy board pin outs,and how to add to the program. I'm new to his and still leaning. Thank you!

Share this post


Link to post
Share on other sites
On 22/03/2017 at 0:13 AM, evoalf said:

Hello I need some help. I did the g25 shifter mod to Teensy usb and it works good. I want add on a pressure sensor to Teensy usb for the add on hand brake as on this DIY http://www.isrtv.com/forums/topic/13770-diy-hydraulic-handbrake/http://www.isrtv.com/forums/topic/13770-diy-hydraulic-handbrake/ What wires from the pressure sensor 5v, ground, and signal to the teensy board pin outs,and how to add to the program. I'm new to his and still leaning. Thank you!

It is not very difficult:

Hardware: from what I read the sensor needs GND, VCC and signal connection (3 wires). The signal output needs to be connected to an analog input of the Teensy board. The first unused pin is A5 (pin 16).

Software:

//
//  G25 shifter to USB interface
//  based on a Teensy 2.0
//
//  3 operating modes
//  - H-pattern shifter
//  - Sequential shifter
//  - Analog handrake
//

//
//  G25 shifter pinout
//
//  DB9  Color    Shifter Description       Teensy
//  1    Black    1       +5V               +5V
//  2    Grey     7       Button Data       pin 17
//  3    Yellow   5       Button !CS & !PL  pin 18
//  4    Orange   3       Shifter X axis    pin 21 (A0)
//  5    Red      2       SPI input 
//  6    White    8       GND               GND
//  7    Purple   6       Button Clock      pin 19
//  8    Green    4       Shifter Y axis    pin 20 (A1)
//  9    Black    1       +5V

// Teensy pin definitions
#define LED_PIN            11
#define DATA_IN_PIN        17
#define MODE_PIN           18
#define CLOCK_PIN          19
#define X_AXIS_PIN         20
#define Y_AXIS_PIN         21
#define HANDBRAKE_PIN      16

// H-shifter mode analog axis thresholds
#define HS_XAXIS_12        400
#define HS_XAXIS_56        600
#define HS_YAXIS_135       800
#define HS_YAXIS_246       300

// Sequential shifter mode analog axis thresholds
#define SS_UPSHIFT_BEGIN   670
#define SS_UPSHIFT_END     600
#define SS_DOWNSHIFT_BEGIN 430
#define SS_DOWNSHIFT_END   500

// Handbrake mode analog axis limits
#define HB_MAXIMUM         530
#define HB_MINIMUM         400
#define HB_RANGE           (HB_MAXIMUM-HB_MINIMUM)

// Digital inputs definitions
#define DI_REVERSE         1
#define DI_MODE            3
#define DI_RED_CENTERRIGHT 4
#define DI_RED_CENTERLEFT  5
#define DI_RED_RIGHT       6
#define DI_RED_LEFT        7
#define DI_BLACK_TOP       8
#define DI_BLACK_RIGHT     9
#define DI_BLACK_LEFT      10
#define DI_BLACK_BOTTOM    11
#define DI_DPAD_RIGHT      12
#define DI_DPAD_LEFT       13
#define DI_DPAD_BOTTOM     14
#define DI_DPAD_TOP        15

// Shifter state
#define DOWN_SHIFT         -1
#define NO_SHIFT           0
#define UP_SHIFT           1

// Shifter mode
#define SHIFTER_MODE       0
#define HANDBRAKE_MODE     1

// LED blink counter
int led=0;

// Shifter state
int shift=NO_SHIFT;

// Handbrake mode
int mode=SHIFTER_MODE;

// Called at startup
// Must initialize hardware and software modules
void setup()
{
  // G25 shifter analog inputs configuration 
  pinMode(X_AXIS_PIN, INPUT_PULLUP);    // X axis
  pinMode(Y_AXIS_PIN, INPUT_PULLUP);    // Y axis

  // Handbrake analog input
  pinMode(HANDBRAKE_PIN, INPUT_PULLUP); // Handbrake
  
  // G25 shift register interface configuration 
  pinMode(DATA_IN_PIN, INPUT);         // Data in
  pinMode(MODE_PIN, OUTPUT);           // Parallel/serial mode
  pinMode(CLOCK_PIN, OUTPUT);          // Clock
  
  // LED output mode configuration 
  pinMode(LED_PIN, OUTPUT);            // LED
  
  // Virtual joystick configuration 
  Joystick.useManualSend(true);        // Joystick output is synchronized
  
  // Virtual serial interface configuration 
  Serial.begin(38400);
  
  // Virtual joystick initialization 
  Joystick.X(0);
  Joystick.Y(0);
  Joystick.Z(0);
  Joystick.Zrotate(0);
  Joystick.sliderLeft(0);
  Joystick.sliderRight(0);
  
  // Digital outputs initialization
  digitalWrite(LED_PIN, LOW);
  digitalWrite(MODE_PIN, HIGH);
  digitalWrite(CLOCK_PIN, HIGH); 
}

// Called in a loop after initialization
void loop() 
{
  // Reading of button states from G25 shift register
  int b[16];
  
  digitalWrite(MODE_PIN, LOW);         // Parallel mode: inputs are read into shift register
  delayMicroseconds(10);               // Wait for signal to settle
  digitalWrite(MODE_PIN, HIGH);        // Serial mode: data bits are output on clock falling edge
  
  for(int i=0; i<16; i++)              // Iteration over both 8 bit registers
  {
    digitalWrite(CLOCK_PIN, LOW);      // Generate clock falling edge
    delayMicroseconds(10);             // Wait for signal to settle
  
    b[i]=digitalRead(DATA_IN_PIN);     // Read data bit and store it into bit array
    
    digitalWrite(CLOCK_PIN, HIGH);     // Generate clock rising edge
    delayMicroseconds(10);             // Wait for signal to settle
  }

  // Reading of shifter position
  int x=analogRead(0);                 // X axis
  int y=analogRead(1);                 // Y axis

  // Reading of handbrake pressure
  int z=analogRead(5);                 // Handbrake

  // Handbrake output
  Joystick.Y(z*4);                     // Coefficient must be adjusted 
  
  // Handbrake mode logic
  if(b[DI_RED_CENTERLEFT]!=0)          // Is left center red button depressed?
  {
    if(b[DI_RED_CENTERRIGHT]!=0)       // Is right center red button also depressed?
    {
      if(b[DI_RED_RIGHT]!=0)           // Is rightmost red button also depressed?
      {
        mode=HANDBRAKE_MODE;           // Handbrake mode is activated if the 3 rightmost 
      }                                // red buttons are depressed
      if(b[DI_RED_LEFT]!=0)            // Is leftmost red button also depressed?
      {
        mode=SHIFTER_MODE;             // Handbrake mode is deactivated if the 3 leftmost
      }                                // red buttons are depressed
    }
  }
  
  // Current gear calculation
  int gear=0;                          // Default value is neutral

  if(b[DI_MODE]==0)                    // H-shifter mode?
  {
    if(x<HS_XAXIS_12)                  // Shifter on the left?
    {
      if(y>HS_YAXIS_135) gear=1;       // 1st gear
      if(y<HS_YAXIS_246) gear=2;       // 2nd gear
    }
    else if(x>HS_XAXIS_56)             // Shifter on the right?
    {
      if(y>HS_YAXIS_135) gear=5;       // 5th gear
      if(y<HS_YAXIS_246) gear=6;       // 6th gear
    }
    else                               // Shifter is in the middle
    {
      if(y>HS_YAXIS_135) gear=3;       // 3rd gear
      if(y<HS_YAXIS_246) gear=4;       // 4th gear
    }
  }
  else                                 // Sequential mode 
  {
    if(mode==SHIFTER_MODE)             // Shifter mode?
    {
      Joystick.X(0);
      if(shift==NO_SHIFT)              // Current state: no shift
      {
        if(y>SS_UPSHIFT_BEGIN)         // Shifter to the front?
        {
          gear=1;                      // Shift-up
          shift=UP_SHIFT;              // New state: up-shift
        }
        if(y<SS_DOWNSHIFT_BEGIN)       // Shifter to the rear?
        {
          gear=2;                      // Shift-down
          shift=DOWN_SHIFT;            // New state: down-shift
        }
      }
      if(shift==UP_SHIFT)              // Current state: up-shift?
      {
        if(y>SS_UPSHIFT_END) gear=1;   // Beyond lower up-shift threshold: up-shift
        else shift=NO_SHIFT;           // Else new state: no shift
      }
      if(shift==DOWN_SHIFT)            // Current state: down-shift
      {
        if(y<SS_DOWNSHIFT_END) gear=2; // Below higher down-shift threshold: down-shift
        else shift=0;                  // Else new state: no shift
      }
    }
    else                               // Handbrake mode
    {
      if(y<HB_MINIMUM) y=HB_MINIMUM;   // Clip minimum position
      if(y>HB_MAXIMUM) y=HB_MAXIMUM;   // Clip maximum position
      
      long offset=(long)y-HB_MINIMUM;
      y=(int)(offset*1023/HB_RANGE);   // Scale input between minimum and maximum clip position
      
      Joystick.X(y);                   // Set handbrake analog output
      gear=0;                          // No gear engaged: neutral
    }
  }
  
  if(gear!=6) b[DI_REVERSE]=0;         // Reverse gear is allowed only on 6th gear position
  if(b[DI_REVERSE]==1) gear=0;         // 6th gear is deactivated if reverse gear is engaged
  
  // Release virtual buttons for all gears
  Joystick.button(1, LOW);
  Joystick.button(2, LOW);
  Joystick.button(3, LOW);
  Joystick.button(4, LOW);
  Joystick.button(5, LOW);
  Joystick.button(6, LOW);
  
  // Depress virtual button for current gear
  if(gear>0) Joystick.button(gear, HIGH);
  
  // Set state of virtual buttons for all the physical buttons (including reverse)
  for(int i=0; i<16; i++) Joystick.button(7+i, b[i]);
  
  // Write new virtual joystick state
  Joystick.send_now();
  
  // Write inputs and outputs (remove comments to debug)
  /*
  Serial.print(" X axis: ");
  Serial.print(x);
  Serial.print(" Y axis: ");
  Serial.print(y);
  Serial.print(" Digital inputs: ");
  for(int i=0; i<16; i++)Serial.print(b[i]);
  Serial.print(" ");
  Serial.print(" Gear: ");
  Serial.print(gear);
  Serial.print(" Mode: ");
  Serial.print(mode);
  Serial.print(" Shift: ");
  Serial.println(shift);
  */

  // Blink the on-board LED
  if(++led==100) led=0;                     // Period is 100 cycles * 10ms = 1s
  if(led==0) digitalWrite(LED_PIN, LOW);    // LED is off for 50 cycles
  if(led==50) digitalWrite(LED_PIN, HIGH);  // LED is on for 50 cycles 
  
  // Wait
  delay(10);                                // Wait for 10ms
}

Haven't tested the code but it should work.

Please let us know ;)

Share this post


Link to post
Share on other sites
9 hours ago, Traction said:

Hi, I just stumbled on this thread, really impressed as I have a g25 shifter sat idle, I have a Teensy 2,0 ++ as shown here.

http://www.ebay.co.uk/itm/131912334361?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

can I use this board and do I use the same pins as the 2.0, 

thx for any advise. 

Mal

It will work with a Teensy 2.0++ using the same pins (the pin numbers will be different). However make sure your board is really a Teensy and not a knock-off advertised as a Teensy: the Teensyduino environment will usually not work with those boards.

Share this post


Link to post
Share on other sites

Thx for the quick reply, just to confirm which pins to use. Do I use use the pin number eg, B1 = B1,  F0 =F0 regardless of their position etc       OR do I use the pin location eg, left hand side 3rd pin regardless of its number, Thx again. I'll let you know how  get on.

regards Mal

Share this post


Link to post
Share on other sites
10 hours ago, Traction said:

Thx for the quick reply, just to confirm which pins to use. Do I use use the pin number eg, B1 = B1,  F0 =F0 regardless of their position etc       OR do I use the pin location eg, left hand side 3rd pin regardless of its number, Thx again. I'll let you know how  get on.

regards Mal

Use same pin names (A0 - A5). This will avoid having to change the software. 

Share this post


Link to post
Share on other sites
On 3/28/2017 at 1:30 AM, Traction said:

Thx for the quick reply, just to confirm which pins to use. Do I use use the pin number eg, B1 = B1,  F0 =F0 regardless of their position etc       OR do I use the pin location eg, left hand side 3rd pin regardless of its number, Thx again. I'll let you know how  get on.

regards Mal

Let me know if you get a clone teensy to load the program . I got a teensy 2.0 clone from ebay and cant get the program to load. The real teensy works and  clone don't. 

Share this post


Link to post
Share on other sites
On 3/30/2017 at 0:54 AM, Traction said:

Hopefully at the weekend I will get time to try,  I will post results here.. :)

not much success here, the H shifter works (no reverse) and the sequential shift works (on button 3-4 same as gears 3 and 4) :) 

 I have no buttons at all, :(

I had no Dsub on my g25 so I used the wire colours as per the code, 

 Color    Shifter Description       Teensy
 Black    1       +5V               +5V
 Grey     7       Button Data       pin 17
 Yellow   5       Button !CS & !PL  pin 18
 Orange   3       Shifter X axis    pin 21 (A0)

 White    8       GND               GND
 Purple   6       Button Clock      pin 19
 Green    4       Shifter Y axis    pin 20 (A1)
 

also the teensy led does not flash after upload. if I use the G27-en then the led flashes correctly but i get same results but still no buttons.

what have I done wrong ....?

thx for any advise. regards Mal

 

 

Edited by Traction

Share this post


Link to post
Share on other sites
On 06/04/2017 at 11:56 AM, Traction said:

not much success here, the H shifter works (no reverse) and the sequential shift works (on button 3-4 same as gears 3 and 4) :) 

 I have no buttons at all, :(

I had no Dsub on my g25 so I used the wire colours as per the code, 

 Color    Shifter Description       Teensy
 Black    1       +5V               +5V
 Grey     7       Button Data       pin 17
 Yellow   5       Button !CS & !PL  pin 18
 Orange   3       Shifter X axis    pin 21 (A0)

 White    8       GND               GND
 Purple   6       Button Clock      pin 19
 Green    4       Shifter Y axis    pin 20 (A1)
 

also the teensy led does not flash after upload. if I use the G27-en then the led flashes correctly but i get same results but still no buttons.

what have I done wrong ....?

thx for any advise. regards Mal

 

 

The shifter is using analog inputs only (X axis, Y axis, GND, +5V): if it is working we can assume this part of the wiring is correct. GND and +5V could be inverted though: what are the exact button numbers for each gear?

Buttons and H pattern/sequential switch are digital: double check the Data, !CS/!PL and Clock wires. If the wiring is correct then your shifter or your Teensy is toast.

Share this post


Link to post
Share on other sites
3 hours ago, pascalh said:

The shifter is using analog inputs only (X axis, Y axis, GND, +5V): if it is working we can assume this part of the wiring is correct. GND and +5V could be inverted though: what are the exact button numbers for each gear?

Buttons and H pattern/sequential switch are digital: double check the Data, !CS/!PL and Clock wires. If the wiring is correct then your shifter or your Teensy is toast.

In H-pattern gears 1-6 use buttons 1-6, no reverse or any other buttons. In seq fwd gives button3 and rev button 4, as you said just using analogue x,y axis. I will check + and gnd , also data, clock.

btw this G25 shifter had been previously modified to use with a G27 wheel. It worked perfectly.

Thx for your help.

regards mal 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
20 20