1. Hundreds of coffees, endless nights of debugging and coding, and countless feedback by our beta testers led to this new major release. SimTools 2.4 is probably the version with the most upgrades and improvements in a single release ever. Look at everything Dustin has included:
    SimTools 2.4 all features.
    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 Download Package Now!
  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 here. Do not following these rules will lead to permanent exclusion from this website: Read the forum rules.

Tutorial DIY load cell brake pedal (short tuto)

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

  1. Alexandre Kostik

    Alexandre Kostik Member

    Joined:
    Jul 2, 2014
    Messages:
    42
    Occupation:
    realtor
    Location:
    Brasil
    Balance:
    321Coins
    Ratings:
    +17 / 1 / -0
    My Motion Simulator:
    2DOF
    Hello @RacingMat !! Does INA125 or INA128 also work? I can not find the INA122 in Brazil ....
    Tks!!!
    Sorry, English, google translate
  2. graz

    graz New Member Gold Contributor

    Joined:
    Aug 19, 2014
    Messages:
    25
    Occupation:
    mechanic
    Location:
    melbourne australia
    Balance:
    2Coins
    Ratings:
    +15 / 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
  3. graz

    graz New Member Gold Contributor

    Joined:
    Aug 19, 2014
    Messages:
    25
    Occupation:
    mechanic
    Location:
    melbourne australia
    Balance:
    2Coins
    Ratings:
    +15 / 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 2
  4. donovan

    donovan New Member

    Joined:
    Apr 7, 2014
    Messages:
    24
    Balance:
    87Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, Arduino
    Really cool :)
  5. jakeschaff

    jakeschaff New Member

    Joined:
    Feb 26, 2018
    Messages:
    1
    Location:
    Perth Australia
    Balance:
    94Coins
    Ratings:
    +1 / 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 1
  6. fimowolu

    fimowolu New Member

    Joined:
    Aug 19, 2018
    Messages:
    2
    Balance:
    55Coins
    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.
  7. fimowolu

    fimowolu New Member

    Joined:
    Aug 19, 2018
    Messages:
    2
    Balance:
    55Coins
    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.
  8. MarcoMade

    MarcoMade Active Member

    Joined:
    Jan 3, 2018
    Messages:
    118
    Occupation:
    Tecnico pc hardware/software C/O PcCorner.it
    Location:
    italy
    Balance:
    51Coins
    Ratings:
    +45 / 0 / -0
    My Motion Simulator:
    2DOF, 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 ..
  9. Trigen

    Trigen Active Member Gold Contributor

    Joined:
    Nov 25, 2018
    Messages:
    131
    Balance:
    970Coins
    Ratings:
    +36 / 0 / -0
    My Motion Simulator:
    2DOF
    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
  10. ahoenksiluman

    ahoenksiluman Member

    Joined:
    Nov 13, 2017
    Messages:
    42
    Location:
    indonesia
    Balance:
    358Coins
    Ratings:
    +24 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino
    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
  11. Trigen

    Trigen Active Member Gold Contributor

    Joined:
    Nov 25, 2018
    Messages:
    131
    Balance:
    970Coins
    Ratings:
    +36 / 0 / -0
    My Motion Simulator:
    2DOF
    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:

    • Informative Informative x 1
  12. Trigen

    Trigen Active Member Gold Contributor

    Joined:
    Nov 25, 2018
    Messages:
    131
    Balance:
    970Coins
    Ratings:
    +36 / 0 / -0
    My Motion Simulator:
    2DOF
    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 <AnalogSmooth.h>
    #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 2
    Last edited: Jul 4, 2019
  13. Trigen

    Trigen Active Member Gold Contributor

    Joined:
    Nov 25, 2018
    Messages:
    131
    Balance:
    970Coins
    Ratings:
    +36 / 0 / -0
    My Motion Simulator:
    2DOF
    3 HX711 setup using the HX711-Multi lib https://github.com/compugician/hx711-multi


    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 1
    Last edited: Jul 6, 2019
  14. Huan Nguyen

    Huan Nguyen New Member

    Joined:
    Oct 15, 2018
    Messages:
    4
    Balance:
    - 3Coins
    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
  15. Trigen

    Trigen Active Member Gold Contributor

    Joined:
    Nov 25, 2018
    Messages:
    131
    Balance:
    970Coins
    Ratings:
    +36 / 0 / -0
    My Motion Simulator:
    2DOF
    • Like Like x 1
  16. 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!