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.

Did you not see a warning when you posted that code improperly?

Read the forum guidelines to see how to properly post code and some good information on making a good post.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

Please go back and fix your original post.

What does that mean? How would a pot act like a clutch? What is the pot to do?

The Joystick library requires an Arduino with native USB like a Leonardo or Micro. It won't work on a Nano without external hardware (USB host shield or equivalent).

For us old timers who haven't kept up with modern automotive driveline technology:
What is a paddle clutch?

I think it's like the F1 cars used to use yonks ago.
Bit like a windscreen washer lever.
These days all that is automatic, paddle or the latest equivilent, (buttons) are now used to change gears up or down with auto clutching.

So, just a switch that tells the transmission to shift up or down (with the permission of the "driveline computer")?

After thinking about it for a while and with the previous answers in mind, maybe buttons or paddles are used to switch gears up and down with an automatic clutch. The clutch paddle would only be used at the standing start to get the vehicle moving? And using a pot instead of a switch would allow the smooth "feathering" of power to the wheels to mitigate wheel spin.

1 Like

From what I know (not much :roll_eyes:) "paddle shift" is used on those "continuous variable ratio" Xmissions to allow overriding "auto" but only in fixed steps, 5 ~ 8 speeds. I honestly don't know exactly how they work.

I've fixed it, thank you.

Right in the beggining of this video it shows what I would like to do, and how it works:

Yes thats exactly how it works!

Think you'll find the gearboxes are constant mesh, much like the motorbike systems.
So, as you say, once in motion, no requirement for the clutch.

Just to answer the question, assuming that you want nothing to happen as you start moving the pot until you reach a certain position and then everything happens, what you need to do is to read an analogue voltage from the pot and compare it with a threshold - if above the threshold do something. If you had the pot operated by a lever and depending which way you move it different things happen once you get beyond certain points, then you just need 2 thresholds, upper and lower. So if for example the pot voltage was +2.5V at the centre position you might set the thresholds at +1.5 and +3.5 volts. Implementing in code is easy and an "exercise for the reader"! You might also want to put in some "hysteresis".

2 Likes

One can do stages by counting button presses.
Long or short also can make a different outcome.
Lever can be connected to pot in such a way as to copy the turning of the pot shaft if that is required.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.