1. Do not share user accounts! Any account that is shared by another person will be blocked and closed. This means: we will close not only the account that is shared, but also the main account of the user who uses another person's account. We have the ability to detect account sharing, so please do not try to cheat the system. This action will take place on 04/18/2023. Read all forum rules.
    Dismiss Notice
  2. For downloading SimTools plugins you need a Download Package. Get it with virtual coins that you receive for forum activity or Buy Download Package - We have a zero Spam tolerance so read our forum rules first.

    Buy Now a Download Plan!
  3. Do not try to cheat our system and do not post an unnecessary amount of useless posts only to earn credits here. We have a zero spam tolerance policy and this will cause a ban of your user account. Otherwise we wish you a pleasant stay here! Read the forum rules
  4. We have a few rules which you need to read and accept before posting anything here! Following these rules will keep the forum clean and your stay pleasant. Do not follow these rules can lead to permanent exclusion from this website: Read the forum rules.
    Are you a company? Read our company rules

Tutorial DIY load cell brake pedal (short tuto)

Discussion in 'DIY peripherals' started by RacingMat, Nov 26, 2014.

  1. graz

    graz New Member Gold Contributor

    Joined:
    Aug 19, 2014
    Messages:
    25
    Occupation:
    mechanic
    Location:
    melbourne australia
    Balance:
    - 28Coins
    Ratings:
    +21 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    just thought I'd post on here as I recently made this load cell mod for my G27 pedals. I am using the STM32 disco board as I am hoping to update to a direct drive wheel at some stage and use this board. I have used an INA126 amp as that was what i could get locally from Jaycar. When I opened game controller MMos the accelerator and clutch were working fine as the signal out from the pots increased as you pressed the pedals but the brake with the load cell was opposite, I don't know if the resistance is critical but I put a 4.7kohm resistor(what I had lying around) between pin 5 from the INA126 and ground. Now the voltage for the brake increases as you brake harder...hope this helps if anyone else has similar issues
    • Informative Informative x 2
    • Like Like x 1
  2. graz

    graz New Member Gold Contributor

    Joined:
    Aug 19, 2014
    Messages:
    25
    Occupation:
    mechanic
    Location:
    melbourne australia
    Balance:
    - 28Coins
    Ratings:
    +21 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, JRK
    I have attached the pcb I made for this project, there are 6 pins where the load cells attach, I used similar load cells to @RacingMat I just put 6 screw terminal block on the board pcb load cell.png
    • Like Like x 4
  3. donovan

    donovan New Member

    Joined:
    Apr 7, 2014
    Messages:
    22
    Balance:
    169Coins
    Ratings:
    +8 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, Arduino
    Really cool :)
  4. jakeschaff

    jakeschaff New Member

    Joined:
    Feb 26, 2018
    Messages:
    1
    Location:
    Perth Australia
    Balance:
    186Coins
    Ratings:
    +2 / 0 / -0
    Hi guys, to anyone looking into this, I just built one and it's awesome, had dramas using the wii-fit load cell but using same cells as racingmat worked first time, as for the difference it makes, was doing 1:00 around Barbagallo in a Huracan GT3 , same car same track now consistently on the high 57s so about 2 seconds a lap, major difference.

    Thankyou racingmat for your post and information
    • Like Like x 2
  5. fimowolu

    fimowolu New Member

    Joined:
    Aug 19, 2018
    Messages:
    2
    Balance:
    100Coins
    Ratings:
    +0 / 0 / -0
    Can somebody explain why these INA chips are so expensive? They seem to be £3-4 each just for the chip. I have a full multimeter (LCD screen, plastic case, probes etc) from China that cost something like £15 that can measure mv so how did they do that so cheaply?

    I see the ricmotech loadcell kit at a whopping $130 managed to use a MCP6231 at one point, that chip costs £0.24. I am unsure if they still use that chip as they seem to have revised the PCB. Is this chip suitable?

    I managed to buy one of these loadcells very cheap and am unsure what chip I should buy https://www.omega.co.uk/pptst/LCFL.html could anyone advise? What are the important parameters, input voltage/excite voltage and output mv/v? Plugging these details in rs-compoents Instrumentation Amplifiers section has me going in circles.
  6. fimowolu

    fimowolu New Member

    Joined:
    Aug 19, 2018
    Messages:
    2
    Balance:
    100Coins
    Ratings:
    +0 / 0 / -0
    Would the INA129 be a suitable chip? There is a cheap module (£2.50-£3.50) with the name of "CJMCU-29" which has a small trim pot plus the INA129 but not much else. Can't seem to DIY anything for less than double the cost.
  7. MarcoMade

    MarcoMade Active Member

    Joined:
    Jan 3, 2018
    Messages:
    150
    Occupation:
    Tecnico pc hardware/software MadeFix
    Location:
    italy
    Balance:
    157Coins
    Ratings:
    +63 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    Hello.
    and since a little time I try different configurations for my brake pedal, from 20kg cell with ina 125, to the biggest 200kg cell with hx711, of this last I would like to make hx711 adjustable in sensitivity as you can do with ina125.
    I already know the change from 10 to 80hz, but I can not make the brake heavy, with about 40kg of thrust already goes to 100% what I did not want, I took the big cell to have weight margin.
    do you have any idea? I would not use ina125 because of the offset I have to adjust often ..
  8. Trigen

    Trigen Active Member

    Joined:
    Nov 25, 2018
    Messages:
    484
    Balance:
    2,872Coins
    Ratings:
    +178 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    Anyone happen to have some finished ardunio code for the HX711 sensor? Its such a shame that people rarely put it up.
    Last edited: Mar 9, 2019
  9. ahoenksiluman

    ahoenksiluman Member

    Joined:
    Nov 13, 2017
    Messages:
    91
    Location:
    indonesia
    Balance:
    89Coins
    Ratings:
    +47 / 0 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, Motion platform
    do someone have other option other than ina122 or ina125..??? (also analog output)
    its hard and expensive in my place...
    Last edited: Mar 10, 2019
  10. Trigen

    Trigen Active Member

    Joined:
    Nov 25, 2018
    Messages:
    484
    Balance:
    2,872Coins
    Ratings:
    +178 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    Got my Uno working with HX711 clone and Unojoy.
    You will need to do some soldering to get the clone into 80 hz mode. The default 10hz lags for the axis
    Lift pin 15. Add a 10k resistor and route it to Vcc 5v (could probably do it another way too but i dont know)

    Threw in the code. Ill be adding for Ard Leo/micro once it arrives.

    Attached Files:

    • Like Like x 3
    • Informative Informative x 1
  11. Trigen

    Trigen Active Member

    Joined:
    Nov 25, 2018
    Messages:
    484
    Balance:
    2,872Coins
    Ratings:
    +178 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    Code for HX711 loadcell and 2 analog axis. Ardunio leonardo/micro Need joystick lib and HX711 lib Based on JensSimPedals

    Edit:

    Ive been having and issue with the pedals waking up the computer and after some support we figured out it was the setAXIS calls. I have updated the code to include an if statement so that the call to set Axis only happens when its not equal to resting pedal. Its important that you use the println to check what your pot numbers are and input the correct ones in the
    Code:
    int lastBrakeValue = 0; 
    and so on

    https://github.com/MHeironimus/ArduinoJoystickLibrary
    https://github.com/bogde/HX711

    Code:
    #include <HX711.h>
    #include <Joystick.h>
    #define calibration_factor -2300 // Do your calibration first. default 2300
    #define DOUT  3
    #define CLK  2
    HX711 scale;
    /*
    For the true false flags, use this list. Its all in  Joystick.h
        bool includeXAxis = true,
        bool includeYAxis = true,
        bool includeZAxis = true,
        bool includeRxAxis = true,
        bool includeRyAxis = true,
        bool includeRzAxis = true,
        bool includeRudder = true,
        bool includeThrottle = true,
        bool includeAccelerator = true,
        bool includeBrake = true,
        bool includeSteering = true);
      */
    Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,
      JOYSTICK_TYPE_MULTI_AXIS, 4, 3,
      false, false, true, false, false, false,
      false, true, true, true, false);
     
     
    // Variable
    int throttle = A0;
    // int brake = 2; / no need for this as we read directly from scale
    int clutch = A1;
    
    // **** INPUT YOUR VALUES HERE **********
    int brake = 0;
    int lastBrakeValue = 0;
    
    int throttleValue = 0;
    int lastThrottleValue = 270;
    
    int clutchValue = 0;
    int lastClutchvalue = 180;
    
    // init joystick libary
    void setup() {
      // Ranges are 1023 by default
       Joystick.setBrakeRange(0, 1023);
      Joystick.setThrottleRange(0, 1023);
      //Joystick.setZAxisRange(0, 1023);
     
      Joystick.begin();
      Serial.begin(38400);
     
      scale.begin(DOUT, CLK);
      scale.set_scale(calibration_factor);
      scale.tare();
    }
    void loop() {
    
    // ***** USE THESE TO CHECK YOUR POT VALUES IN SERIAL MONITOR ****
    
        //Serial.println (brake);
        //Serial.println (throttleValue);
        //Serial.println (clutchValue);
    
    
    // For the if else if statements below. Set these to match your numbers as instructed.
    // If the value starts below 0 set it to 0. Or if its above 10 set it to 0
    
    
    // ******** THROTTLE ***************
    
      throttleValue = analogRead(throttle);
     
         if (throttleValue > 666) {
        throttleValue = 670;
      }
        else if (throttleValue < 273) {
        throttleValue = 270;
      }
        if (lastThrottleValue != throttleValue) {
         Joystick.setThrottle(throttleValue);
         lastThrottleValue = throttleValue;
      }
       delay(1);
     
    // *********  BRAKE **************
    
    brake = scale.get_units(); // if the value is inverted put a - sign in front like -scale.get
     
       if (brake < 0 or brake < 8) {
        brake = 0;
      }
     
       if (lastBrakeValue != brake) {
         Joystick.setBrake(brake);
         lastBrakeValue = brake;
      }
      delay(1);
     
    // ********** CLUTCH *************
    
       clutchValue = analogRead(clutch);
     
         if (clutchValue < 185) {
        clutchValue = 180;
      }
        if (lastClutchvalue != clutchValue) {
         Joystick.setZAxis(clutchValue);
         lastClutchvalue = clutchValue;
      }
      delay(1);
    }
    
    • Like Like x 3
    Last edited: Apr 19, 2020
  12. Trigen

    Trigen Active Member

    Joined:
    Nov 25, 2018
    Messages:
    484
    Balance:
    2,872Coins
    Ratings:
    +178 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    3 HX711 setup using the HX711-Multi lib https://github.com/compugician/hx711-multi

    Edit. Possbily this needs a lot of tweaking. I know one person was doing this but has not given any more information on the project.


    Few items to note: For reading input values uncomment these. You will also need to use these values to check for the correct numbers in the AXIS CONFIG IF OR statements for the channels to set a HW DZ to avoid spiking close to 0

    Code:
    // uncomment for debug in serial monitor. Set serial monitor baud to 38400
    //Serial.print ("Throttle: \t"); (throttle);
    //Serial.print ("brake: \t"); (brake);
    //Serial.print ("Clutch: \t"); (clutch);
    
    If your numbers are inverted add a - sign in front of all results[] in the AXIS CONFIG

    I needed - for my setup but this code is set to the without any inversion as default

    When you have the correct numbers remove the uncommented (remove /* and */) if else statements and input your numbers in the AXIS CONFIG

    Example when uncommented.

    Code:
      throttle = results[0] / throttleDiv ;
     if (throttle < 0 or throttle < 5) {
        throttle = 0;
      }
        else
        throttle = results[0] / throttleDiv ;
      Joystick.setThrottle(throttle);
      delay(1);
    

    Code:
    #include <Joystick.h>
    #include "HX711-multi.h"
    // Pins to the load cell amp
    #define CLK 2      // clock pin to the load cell amp
    #define DOUT1 3    // data pin to the first lca
    #define DOUT2 4    // data pin to the second lca
    #define DOUT3 5    // data pin to the third lca
    
    #define TARE_TIMEOUT_SECONDS 4
    byte DOUTS[3] = {DOUT1, DOUT2, DOUT3};
    #define CHANNEL_COUNT sizeof(DOUTS)/sizeof(byte)
    long int results[CHANNEL_COUNT];
    HX711MULTI scales(CHANNEL_COUNT, DOUTS, CLK);
    
    /*
    For the true false flags, use this list. Its all in  Joystick.h
       bool includeXAxis = true,
       bool includeYAxis = true,
       bool includeZAxis = true,
       bool includeRxAxis = true,
       bool includeRyAxis = true,
       bool includeRzAxis = true,
       bool includeRudder = true,
       bool includeThrottle = true,
       bool includeAccelerator = true,
       bool includeBrake = true,
       bool includeSteering = true);
      */
    
    Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,
      JOYSTICK_TYPE_MULTI_AXIS, 4, 3,
      false, false, true, false, false, false,
      false, true, true, true, false);
    
    
    // Variable
    int throttle = 0;
    int brake = 0;
    int clutch = 0;
    
    
    // Divides the large scale number to smaller so you keep the number less than 1024. Depending on what force you put on the pedal. Check in serial monitor by uncommenting the Serial.print above the statements.
    
    
    int throttleDiv = 200; // check this in serial as its likely to high
    int brakeDiv = 200;
    int clutchDiv = 200;
    // init joystick libary
    void setup() {
      // Ranges are 1023 by default
      // Joystick.setBrakeRange(-300, 10230);
      //Joystick.setThrottleRange(0, 1023);
      //Joystick.setZAxisRange(0, 255);
      Joystick.begin();
      Serial.begin(115200);
      Serial.flush();
      pinMode(11,OUTPUT);
      tare();
    }
    
    void tare() {
      bool tareSuccessful = false;
      unsigned long tareStartTime = millis();
      while (!tareSuccessful && millis()<(tareStartTime+TARE_TIMEOUT_SECONDS*1000)) {
       tareSuccessful = scales.tare(20,10000);  //reject 'tare' if still ringing
      }
    }
    void sendRawData() {
      scales.read(results);
    }
    
    void loop() {
      sendRawData(); //this is for sending raw data, for where everything else is done in processing
      //on serial data (any data) re-tare
      if (Serial.available()>0) {
       while (Serial.available()) {
         Serial.read();
       }
       tare();
      }
    
    
    //        README!
    // If inverted add  - to the channel results.
    // Do this to All results in axis config
    // Fks: throttle = results[0] / throttleDiv ;
    // to  throttle = -results[0] / throttleDiv ;
    // uncomment for debug in serial monitor. Set serial monitor baud to 38400
    Serial.print ("Throttle: ");
    Serial.println (throttle);
    Serial.print ("brake: ");
    Serial.println (clutch);
    Serial.print ("Clutch: ");
    Serial.println (clutch);
    //
    //
    // Its important that you check the values (using the unncomment for debug above.) on your setup and adjust the range of the HW deadzone here. Your numbers could be different
    // If the throttle value starts below 0 set it to 0. Or if its above 5 set it to 0
    // This fixes the slight drift and sets it to 0 if it starts below 0
    //comment out the if and else statements to remove and see pure values in serial monitor, then //set your numbers for HW DZ in the IF statement
    
    // Example
    /*  throttle = results[0] / throttleDiv ;
      if (throttle < 0 or throttle < 5) {
       throttle = 0;
      }
       else
       throttle = results[0] / throttleDiv ;
      Joystick.setThrottle(throttle);
      delay(1);
    */
    
    
    //****** AXIS CONFIG*****
    // Throttle
      throttle = -results[0] / throttleDiv ;
      if (throttle < 0 or throttle < 5) {
       throttle = 0;
      }
       else
       throttle = -results[0] / throttleDiv ;
      Joystick.setThrottle(throttle);
      delay(1);
    // Brake
      brake = -results[1] / brakeDiv ;
      if (brake < 0 or brake < 5) {
       brake = 0;
      }
       else
       clutch = -results[1] / brakeDiv ;
      Joystick.setBrake((brake));
       delay(1);
    // Clutch
      clutch = -results[2] / clutchDiv ;
      if (clutch < 0 or clutch < 5) {
       clutch = 0;
      }
       else
       clutch =  -results[2] / clutchDiv ;
      Joystick.setZAxis((clutch));
       delay(1);
    }
    
    • Like Like x 2
    • Informative Informative x 1
    Last edited: Jan 12, 2020
  13. Huan Nguyen

    Huan Nguyen New Member

    Joined:
    Oct 15, 2018
    Messages:
    5
    Balance:
    43Coins
    Ratings:
    +0 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, AC motor, SCN5, SCN6, SimAxe, Arduino, JRK, Joyrider, SimforceGT, Motion platform, 4DOF, 6DOF
    @Trigen Can i use hx711 with Arduino Pro Micro + your code
  14. Trigen

    Trigen Active Member

    Joined:
    Nov 25, 2018
    Messages:
    484
    Balance:
    2,872Coins
    Ratings:
    +178 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    • Like Like x 1
  15. DesmoGiec

    DesmoGiec New Member

    Joined:
    May 7, 2019
    Messages:
    2
    Balance:
    23Coins
    Ratings:
    +0 / 0 / -0
    I've bought an ina125 amplifier..
    Any hints on how to cable it?
    First post shows how to do the work with a 122, which has 8 pins instead of 16 of the 125.
    Thanks in advance!
  16. Pino Pistolidas

    Pino Pistolidas New Member

    Joined:
    Mar 16, 2018
    Messages:
    22
    Location:
    Netherlands nijkerk
    Balance:
    184Coins
    Ratings:
    +18 / 0 / -0
    My Motion Simulator:
    3DOF, DC motor, Arduino
    @Trigen I would like to use your code for a load cell brake with a HX711 and an Arduino pro micro. Would you be able to help me with the connections between de HX711 and the pro micro? And which of your codes I could use best?
  17. Pastrana

    Pastrana Member

    Joined:
    Oct 30, 2015
    Messages:
    97
    Location:
    Argentina
    Balance:
    165Coins
    Ratings:
    +45 / 0 / -0
    My Motion Simulator:
    2DOF
    [USUARIO 31790]@Trigen[/USUARIO]
    Me uno a la orden, ¿tiene un esquema de conexión con Arduino micro?
    Last edited: Jan 11, 2020
  18. Trigen

    Trigen Active Member

    Joined:
    Nov 25, 2018
    Messages:
    484
    Balance:
    2,872Coins
    Ratings:
    +178 / 1 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino
    Sorry but i dont understand you.
  19. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    21,141
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    148,541Coins
    Ratings:
    +10,902 / 54 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
  20. Pastrana

    Pastrana Member

    Joined:
    Oct 30, 2015
    Messages:
    97
    Location:
    Argentina
    Balance:
    165Coins
    Ratings:
    +45 / 0 / -0
    My Motion Simulator:
    2DOF
    Sorry I had the autotraductor activated.
    I was wondering if I had the arduino micro and load cell and hx711 wiring
    • Like Like x 1