What code is necessary to make a potentionmeter work like a clutch?

Hey guys,

I'm building a steering wheel for my T300 and i'm missing the paddle clutch on the wheel.
Currently I have this sketch on my arduino nano:

_____

byte wheelState [8]; // local push-buttons state saved here
volatile byte pos;

void setup (void) {
DDRB &= B11110000; // digital pins 8,9,11 used as inputs. 10 - SS also input
PORTB |= B00001011; // 8,9,11 - pull-up to +VCC via internal 100k resistors.

DDRC &= B11000000; // pins 14-19 (A0 - A5) also used as digital inputs
PORTC |= B00111111; // pulled-up to +VCC via internal 100k resistors

DDRD &= B00100000; // digital pins 0,1,3,4,6,7 are inputs for buttons. 2 - also input - for external interrupt 0
PORTD |= B11011011; // 0,1,3,4,6,7 pulled-up to +VCC via internal 100k resistors

wheelState[0] = B11010001; // T300 PS wheel first data byte
wheelState[1] = B11111111; // second data byte - buttons
wheelState[2] = B11111111; // third data byte - buttons
wheelState[3] = B11111111; // this and below - not used, but wheelbase reads all 8 bytes...
wheelState[4] = B11111111;
wheelState[5] = B11111111;
wheelState[6] = B11111111;
wheelState[7] = B11111111;

//Serial.begin(9600); // Arduino debug console - occupies pins RX (0) and TX (1) on Uno
pinMode(MISO, OUTPUT); // arduino is a slave device
SPCR |= _BV(SPE); // Enables the SPI when 1
SPCR |= _BV(SPIE); // Enables the SPI interrupt when 1

// interrupt for SS rising edge. Arduino Uno Pin10 must be connected to Pin2!!!
attachInterrupt (0, ss_rising, RISING);

}

// Interrupt0 (external, pin 2) - prepare to start the transfer
void ss_rising () {
SPDR = wheelState[0]; // load first byte into SPI data register
pos = 1;
}

// SPI interrupt routine
ISR (SPI_STC_vect) {
SPDR = wheelState[pos++]; // load the next byte to SPI output register and return.
}

void loop() {
// scan the button presses and save that to wheelState array. Data transfer to wheelbase is interrupt-driven above.
//wheelState[0] - always constant for T300 PS wheel
wheelState[1] = ((PIND & B11000000) >> 1) | ((PINB & B00000010) << 3) | ((PIND & B00000001) << 3) | ((PINB & B00000001) << 2) | ((PINB & B00001000) >> 2) | ((PIND & B00010000) >> 4) | B10000000;
wheelState[2] = ((PIND & B00000010) << 6) | ((PINC & B00100000) << 1) | ((PINC & B00001000) << 2) | ((PIND & B00001000) << 1) | ((PINC & B00000111) << 1) | ((PINC & B00010000) >> 4);
}

_____

Since I'm pretty new to arduino, I don't know what code I should put to make my potentionmeter work like a clutch.

I've been looking for sometime and I found this code to make a potentionmeter work, but I'm not sure if this will work with the code on top:
_____

#include <Joystick.h>

Joystick_ Joystick;

int Throttle_ = 0;

const bool initAutoSendState = true;

void setup()
{
Joystick.begin();
}

void loop(){

Throttle_ = analogRead(A4);
Throttle_ = map(Throttle_,1023,0,255,0);
Joystick.setThrottle(Throttle_);

delay (50);
}

_____

Can somebody help me with this?
Thank you.
 
I don't have a T300, but it looks like you are sending 8 bytes of data to the wheel base via SPI, is this correct?

If so, then you will probably need to send the clutch data in one (or more) of those bytes. Reading the value is easy enough, just pick a free A pin (the example you used above is reading A4). You don't need the joystick module, that is purely for exposing the values as a joystick axis via USB when the Arduino is connected directly to the PC.

The trick then is that the value will be 10 bits, so you need to figure out what value range the wheel base will accept (if anything) and manipulate it as required.

My first question is, do you know what the other bytes do? If not, I'd recommend first noting down the values you see in something like diview and then changing the fixed values to some specific for each byte and seeing how the values change in diview and if there is an axis you can use.
 
I noticed some other things in the code last night.

You are setting some of the A pins to digital, so you need to make sure you are not using them for the clutch:
DDRC &= B11000000; // pins 14-19 (A0 - A5) also used as digital inputs

The first byte in the payload seems to tell the wheel base what wheel is attached:
wheelState[0] = B11010001; // T300 PS wheel first data byte
My guess would be that if that wheel type doesn't normally have a clutch, then you might find that none of the other bytes are going to be used by the wheel base and you will need to find a way to determine the ID of one that does. Can the wheels on a T300 be hot swapped? If so, a brute force approach would be to create a sketch that increments the first byte with a button press and slowly go through all 256 permutations.
 
But only works with buttons I think.
Yeah, I suspect the first byte determines the wheel type and if it's not got an axis then all bets are off. Do any of the wheels have a clutch or something like that though?

The article you linked to has some other code to emulate a different wheel and the ID is different, so if there is a wheel with an axis, there is some hope.

This was the other article:


And here was the ID used
wheelState[0] = B11000001; // 458 Italia Wheel first data byte
vs
wheelState[0] = B11010001; // T300 PS wheel first data byte

It might mean starting from scratch on the button mappings though, so depends how important the clutch is
 
Last edited:
Do you communicate through this plug in the middle of the wheel hub?
If so I would assume that a axis is nit possible.
Or is it a nano that is used as a separate "joystick" on the PC?

You know of this guy?
Smart approach, always wanted to test, but no time left to do so in the past. But only works with buttons I think.
Yes, i connect it through the plug din 6 pin and my wheel was made by following that article
Yeah, I suspect the first byte determines the wheel type and if it's not got an axis then all bets are off. Do any of the wheels have a clutch or something like that though?

The article you linked to has some other code to emulate a different wheel and the ID is different, so if there is a wheel with an axis, there is some hope.

This was the other article:


And here was the ID used

vs


It might mean starting from scratch on the button mappings though, so depends how important the clutch is

Yes, thats exactly the article that I used to build my wheel, and from what you are saying maybe it would be easier to just make the clutch a separated thing if I really want it.

I don't know of a thrustmaster wheel that has an axis on the wheel.
Just Buttons.
Yes there's this one: https://www.thrustmaster.com/pt-br/products/formula-wheel-add-on-ferrari-sf1000-edition/ but i cant find a lot about it.

In another forum someone recommended to try make it like it was the clutch from the t300 pedals because it works the same way
 
Last edited:
Ok, that is promising as it clearly states the wheel has two configurable analogue paddles.

The tricky bit now is how to determine the ID. As mentioned before, you might be able to brute force it as there are only 254 more to go (we already know two of them), but would that be something you want to do? I'd create a simple sketch that increments the ID on a button press and then see what the thrustmaster software status says is connected after each press.

The alternative (assuming you are on PC only) is to simply have the wheel directly connect to the PC via USB. This would give you a lot more flexibility not only for the buttons/paddles on the wheel, but also If you wanted to add displays etc...
 
Last edited:

Latest News

Back
Top