Aliexpress handbrake without software.

Hi folks!

I made a tarrible mistake, I accidentally uploaded an Arduino script to the handbrake instead of the Arduino board in question, can someone help me to get the handbrake working again?

I tried the script what I found on the internet and here in the racedepartment forum but without results..

Greetings Rodney
 
That's a hassle, and I fully sympathise; no way of write protecting the arduino in question, and worse still no way of reverse reading an existing unit

The units use hall effect sensors, so the sketch can't be too complex, but the missing bit will be how the pc reads the unit as an HID. I suggest going over to the DCS home cockpits forum, there are some really spectacular guys on there that are so conversant with arduinos that I'm sure they can help. And unlike the Arduino forum you won't be made to feel stupid asking them a question

Cheers

Les
 
Upvote 0
Ok, that uses a linear potentiometer, but essentially it will be the same.

I found this Arduino sketch on Thingiverse, you can try and see if this works

Code:
//Hall-effect sensor handbrake
//CPO 2021-10-18 REV3 to simulate load cell response or work with soft stop washers
//#define DEBUG 1  //Uncomment to observe output in the debug terminal
#ifdef DEBUG
  #include <SoftwareSerial.h>
#endif
#include <Joystick.h>
#define joyX A3  // Pin receiving HallSensor output

//**********MUST BE ADJUSTED FOR YOUR USE CASE***************
float oil_ValidRange = 0;  //move the brake response to the last X% of the range to account for "soft stop" in oil-filled master cylinder or resistance washers
                           //0.1 look at last 10% of the range
                           //0.4 look at last 40% of the range, etc.
                           //Set to 0 for linear range
//***********************************************************

int xAxis_ = 0;
int xMin = 9999;
int xMax = 0;
int xPrev = -1;
int oilMin = 0;
int calcJoyVal = 0;
int calcJoyValPrev = 0;
int xSpan = 0;
Joystick_ Joystick(0x12, JOYSTICK_TYPE_JOYSTICK, 0, 0,true,false,false,false,false,false,false,false,false,false,false);
const bool initAutoSendState = true;

void setup() {
  Joystick.setXAxisRange(-127, 127);
  Joystick.begin();
  #ifdef DEBUG
    Serial.begin(9600);
  #endif
}

void loop() {
  xAxis_ = analogRead(joyX);  //Current raw brake value
  if (xAxis_ != xPrev) {  //Only run calculations if the raw sensor input has changed
    xPrev = xAxis_;
    if (xAxis_ > xMax) {
      xMax=xAxis_;  //Maximum value seen so far - reset known xMax value (100% braking)
    }
    else if (xAxis_ < xMin) {
      xMin = xAxis_;  //Minumum value seen so far - reset known xMin value (0% braking)
    }

    if (oil_ValidRange > 0) {  //Oil-filled only: look only at last portion of range to account for master cylinder resistance
       oilMin = xMax - (oil_ValidRange * xMax);
       if (xAxis_ >= oilMin) { //in braking range
        calcJoyVal = map(xAxis_,oilMin,xMax,-128,128); 
      }
      else {
        calcJoyVal = -128;
      }
      
    //Non-oil-filled only: linear output
    }
    else { 
      calcJoyVal = map(xAxis_,xMin,xMax,-128,128);  //Convert the arbitrary sensor span to joystick values of -127 to 127
    }
    
    calcJoyVal = constrain(calcJoyVal,-128,128);
    if (calcJoyVal != calcJoyValPrev) { //only send usb joystic value out if it has changed from previous
      Joystick.setXAxis(calcJoyVal);
      calcJoyValPrev = calcJoyVal;
    }
    
    #ifdef DEBUG
      Serial.print("  oil_ValidRange=");
      Serial.print(oil_ValidRange);
      Serial.print("  oilMin=");
      Serial.print(oilMin);
      Serial.print("  xAxis_=");
      Serial.print(xAxis_);
      Serial.print("  xPrev_=");
      Serial.print(xPrev);
      Serial.print("  xMin=");
      Serial.print(xMin);
      Serial.print("  xMax=");
      Serial.print(xMax);
      Serial.print("  calcJoyVal=");
      Serial.println(calcJoyVal);
    #endif
    
  }
  delay(50); //50ms (20 updates per second)
}

Les
 
Upvote 0
Ok, that uses a linear potentiometer, but essentially it will be the same.

I found this Arduino sketch on Thingiverse, you can try and see if this works

Code:
//Hall-effect sensor handbrake
//CPO 2021-10-18 REV3 to simulate load cell response or work with soft stop washers
//#define DEBUG 1  //Uncomment to observe output in the debug terminal
#ifdef DEBUG
  #include <SoftwareSerial.h>
#endif
#include <Joystick.h>
#define joyX A3  // Pin receiving HallSensor output

//**********MUST BE ADJUSTED FOR YOUR USE CASE***************
float oil_ValidRange = 0;  //move the brake response to the last X% of the range to account for "soft stop" in oil-filled master cylinder or resistance washers
                           //0.1 look at last 10% of the range
                           //0.4 look at last 40% of the range, etc.
                           //Set to 0 for linear range
//***********************************************************

int xAxis_ = 0;
int xMin = 9999;
int xMax = 0;
int xPrev = -1;
int oilMin = 0;
int calcJoyVal = 0;
int calcJoyValPrev = 0;
int xSpan = 0;
Joystick_ Joystick(0x12, JOYSTICK_TYPE_JOYSTICK, 0, 0,true,false,false,false,false,false,false,false,false,false,false);
const bool initAutoSendState = true;

void setup() {
  Joystick.setXAxisRange(-127, 127);
  Joystick.begin();
  #ifdef DEBUG
    Serial.begin(9600);
  #endif
}

void loop() {
  xAxis_ = analogRead(joyX);  //Current raw brake value
  if (xAxis_ != xPrev) {  //Only run calculations if the raw sensor input has changed
    xPrev = xAxis_;
    if (xAxis_ > xMax) {
      xMax=xAxis_;  //Maximum value seen so far - reset known xMax value (100% braking)
    }
    else if (xAxis_ < xMin) {
      xMin = xAxis_;  //Minumum value seen so far - reset known xMin value (0% braking)
    }

    if (oil_ValidRange > 0) {  //Oil-filled only: look only at last portion of range to account for master cylinder resistance
       oilMin = xMax - (oil_ValidRange * xMax);
       if (xAxis_ >= oilMin) { //in braking range
        calcJoyVal = map(xAxis_,oilMin,xMax,-128,128);
      }
      else {
        calcJoyVal = -128;
      }
     
    //Non-oil-filled only: linear output
    }
    else {
      calcJoyVal = map(xAxis_,xMin,xMax,-128,128);  //Convert the arbitrary sensor span to joystick values of -127 to 127
    }
   
    calcJoyVal = constrain(calcJoyVal,-128,128);
    if (calcJoyVal != calcJoyValPrev) { //only send usb joystic value out if it has changed from previous
      Joystick.setXAxis(calcJoyVal);
      calcJoyValPrev = calcJoyVal;
    }
   
    #ifdef DEBUG
      Serial.print("  oil_ValidRange=");
      Serial.print(oil_ValidRange);
      Serial.print("  oilMin=");
      Serial.print(oilMin);
      Serial.print("  xAxis_=");
      Serial.print(xAxis_);
      Serial.print("  xPrev_=");
      Serial.print(xPrev);
      Serial.print("  xMin=");
      Serial.print(xMin);
      Serial.print("  xMax=");
      Serial.print(xMax);
      Serial.print("  calcJoyVal=");
      Serial.println(calcJoyVal);
    #endif
   
  }
  delay(50); //50ms (20 updates per second)
}

Les
This gives me an error..
 
Upvote 0
Which error does it give and when - when loading the sketch or trying to use it?

Les
Arduino:1.8.13 (Windows 10), Board:"Arduino Micro"





















sketch_oct25a:25:26: error: 'JOYSTICK_TYPE_JOYSTICK' was not declared in this scope

Joystick_ Joystick(0x12, JOYSTICK_TYPE_JOYSTICK, 0, 0,true,false,false,false,false,false,false,false,false,false,false);

^~~~~~~~~~~~~~~~~~~~~~

C:\Users\rodne\AppData\Local\Temp\arduino_modified_sketch_881728\sketch_oct25a.ino: In function 'void setup()':

sketch_oct25a:29:12: error: 'class Joystick_' has no member named 'setXAxisRange'; did you mean 'setXAxis'?

Joystick.setXAxisRange(-127, 127);

^~~~~~~~~~~~~

setXAxis

exit status 1

'JOYSTICK_TYPE_JOYSTICK' was not declared in this scope



Dit rapport zou meer informatie bevatten met
"Uitgebreide uitvoer weergeven tijden compilatie"
optie aan in Bestand -> Voorkeuren.
 
Upvote 0

Latest News

Are you buying car setups?

  • Yes

  • No


Results are only viewable after voting.
Back
Top