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. 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
    Its the same ports on the Micro.

    https://www.google.com/search?q=hx7...YKHZ_eDdYQ9QEwAXoECAgQIw#imgrc=5zpwLhZPCXaJLM:
  2. Pastrana

    Pastrana Member

    Joined:
    Oct 30, 2015
    Messages:
    96
    Location:
    Argentina
    Balance:
    159Coins
    Ratings:
    +45 / 0 / -0
    My Motion Simulator:
    2DOF
  3. 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
    Just as the picture but connect all 3 cells to the same GND and 5v. Then all cells to port 2 CLK . After that connect one cell to 3 one to 4 and one to port 5

    #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


    Just to mention it, this can be difficult to get working so its important that you learn and understand the code. Its a long time ago now but there was some changes and bugs in the libraries it relies on but hopefully its working fine now.

    For debugging uncomment these lines (remove //) and use serial monitor


    void setup() {
    // Ranges are 1023 by default
    // Joystick.setBrakeRange(-300, 10230);
    //Joystick.setThrottleRange(0, 1023);
    //Joystick.setZAxisRange(0, 255);

    Also if you just get 0 remove the - before each result[0] it inverts the numbers. If that dont work, something else is going on.

    throttle = -results[0] / throttleDiv ;
    • Informative Informative x 1
    Last edited: Jan 13, 2020
  4. Gadget999

    Gadget999 Well-Known Member

    Joined:
    Dec 27, 2015
    Messages:
    1,935
    Location:
    London
    Balance:
    11,838Coins
    Ratings:
    +472 / 9 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, 6DOF
    Has anyone used a peizo sensor to measure force ?

    The resistance drops the harder you press
  5. Snowracer

    Snowracer New Member

    Joined:
    Feb 16, 2019
    Messages:
    3
    Balance:
    23Coins
    Ratings:
    +0 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino
    @Trigen
    Hello and thank you for sharing your code, I have gotten various other hx711 and joystick libraries to work on my loadcell brake only. I have tried your code 2 analog and 1 hx711 with bodge hx711 with no success. The code loads fine and I am able to see the serial print showing 0's but the arduino does not load up as a joystick game controller so that i can calibrate it in windows. Am I supposed to remove any /* or // to activate the library. I am new to coding so sorry in advance and thanks!
  6. 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
    I dont have this setup anymore but i tested it on a new Ardunio leonardo and it worked fine right out of the box for me. Perhaps a library or library version issue. I havent seen any version changes lately though but id have a look at that first.
  7. Snowracer

    Snowracer New Member

    Joined:
    Feb 16, 2019
    Messages:
    3
    Balance:
    23Coins
    Ratings:
    +0 / 0 / -0
    My Motion Simulator:
    DC motor, Arduino
    Thanks for replying, so when you load your Arduino does it load up as a game controller? In which windows sees it as a joystick and you can calibrate it. Mine also loads fine but it doesn't show up as a game controller.
  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
    Yes, It showed right up as a controller. Didnt have any issues. Maybe the developer of the library got some insight on it
  9. TonyASh

    TonyASh New Member

    Joined:
    May 17, 2020
    Messages:
    2
    Balance:
    53Coins
    Ratings:
    +0 / 0 / -0
    Hello guys! I have some problems.... I connect my pedals to fanatec clubsport 2.5 and brake pedal is inverted... How i can fix it?
    If I change pins V+ V- tenzosensor not working.
  10. yellofella

    yellofella Member

    Joined:
    Aug 8, 2011
    Messages:
    94
    Occupation:
    builder
    Location:
    UK
    Balance:
    743Coins
    Ratings:
    +84 / 0 / -0
    My Motion Simulator:
    3DOF, SimforceGT
    Hi guys
    just read the previous posts on this load cell problem and thought id offer an opinion. Ive solved this problem for all u guys out there that want to use it and have tested it working on both my pc/laptop. Its probably not the cheapest way to do it or the best way but its the way I did it for my needs.
    I wanted a load cell for my G27 pedals and chose the FC22 25kg loadcell, much the same as supplied with the ricmotech kit and installed it as per there instructions. As many have mentioned the polarity is reversed and wont work at all reversed biased due to internal diodes in the loadcell itself.
    I also wanted 12bit resolution on the brake pedal as most high end pedals use this resolution so what to use
    The ricmotech mod i think uses an op amp in inverting mode to reverse the polarity of the load cell so it will work but I found that being the loadcells voltage is 0-4.5v not 0-5v due to its internal components diodes/ caps etc the effect was the brakes were either left slightly on all the time or wouldn't achieve full brakes. ( one or the other I cant remember now but not ideal). Added to that even if I used a rail to rail op amp I couldn't solve it this way.
    Maybe an Arduino would do the job, well it will but is only 8 bit no good for my needs but were getting there
    I finally settled on the Arduino blue pill STM32F103C8t6. It has a 12 bit ADC as well as a 16 bit DAC, it can be programmed from the Arduino ide, and its a small pcb so it will fit inside the pedal enclosure. the down side is that it is 3.3v but I can deal with that
    So we need to convert load cell signal from 0-4.5v down to 0- 3.3v linear using a voltage divider then input the signal to the Arduino stm32, Write some code to read the signal then invert it and allow for the 0.5v voltage drop on the loadcell and allow for any pre load in the spring of the pedal. Output that signal using pwm and use a logic level converter mosfet to revert the level back up to 0-5v pwm then run that signal through a RC filter to achieve an inverted true analogue signal to use as our output.
    Now I have designed a simple pcb that you can make at home that is single sided and uses 24mil traces so is fairly easy to make if you have some basic pcb making and soldering skills. Ill enclose a picture of it and the etchable pdf to etch it as well as the very simple code for Arduino ide. You could probably make this circuit on a perf board as well if you are not able to etch but I haven't tried.

    Parts needed
    3 x 10k resistors 0805 smd
    1 x 1.9k resistor tht
    1 x 3.3k resistor tht
    1 x 100nf capacitor 0805smd
    1 x 1uf capacitor 0805 smd
    2 x 20 pin 2.54mm female pin header
    1 x 4 pin jst 2mm female header
    1 x 4 pin jst 2mm plug
    4 x 28awg connector pins
    1 x n channel mosfet (d pak case)
    For those that want to build this by other means ill explain how to here in the 3 parts as I cant upload a circuit schematic for some reason buts its a simple circuit
    1 / voltage divider

    Connect loadcell signal wire to a 1.9k resistor then connect the other side to A0 on the blue pill. Then put a 3.3k resistor from A0 on the blue pill to ground. Then put a 100nf capacitor between A0 and ground to smooth the loadcell signal slightly
    2 / logic level converter
    Connect A8 of the blue pill to the source pin of the mosfet then connect a 10k resistor to A8 and the other side to 3.3v
    . Connect the drain pin of the mosfet to a 10k resistor then the other side of the resistor to 5v
    Connect the Gate pin directly to 3.3v
    3 / Rc filter
    Connect the drain pin of the mosfet to a 10k resistor then the other side of the resistor is the output
    Connect a 1uf capacitor between the output and ground

    The output then connects to the white wire on the brake pedal potentiometer
    Connect the red wires on the brake pedal potentiometer and the red loadcell wire to 5v on the blue pill
    Connect the black wires on brake pedal potentiometer and the black load cell wire to ground on the blue pill
    Remove all wires from the brake pedal potentiometer
    There are various tutorials on the net that go into setting up the Arduino blue pill so im not going into it now but once you can upload code to it paste this code in a blank sketch and upload
    If you made the pcb then you can plug a usb to serial converter into the pcb to upload code rather than having to unplug the blue pill and put it onto a breadboard ect

    const int analogInPin = PA0; // Analog input pin that the loadcell signal wire is attached to
    const int analogOutPin = PA8; // Analog output pin PWM
    int sensorValue = 0; // value read from the loadcell
    int outputValue = 0; // value output to the PWM (analog out)
    void setup() {
    //Serial.begin(9600); // connects to serial.. uncoment all lines to use
    pinMode(analogOutPin, PWM);
    }
    void loop() {
    sensorValue = analogRead(analogInPin);
    outputValue = map(sensorValue, 500, 3800, 65535, 0); // may have to change the values 500, 3800 to the min max of sensor
    sensorValue = constrain(sensorValue, 500, 3800); // adjust these values to match above values
    pwmWrite(analogOutPin, outputValue);

    //Serial.print("sensor = ");
    //Serial.println(sensorValue); // prints the min max loadcell value to serial monitor
    //Serial.print("\t output = ");
    //Serial.println(outputValue); // shows the 16 bit output value
    delay(10); // change to 50 if using serial monitor to get values
    }

    you need to tune the max min value of the load cell yourself as all diy setups will be different from mine. Open the serial monitor to get the values and change the values in the code to match then upload . The wheel base should now see it as just another potentiometer so you can plug it into that but will only be 8 bit as that's all the wheel base will allow, I used a Bodnar cable and plugged the pedals directly into the pc via usb and had full 12bit resolution on the brake pedal and 16bit on the acc/clutch. you should be able to use it on ps4 as well but I haven't tested due to not owning one.
    You just need to mount the electronics inside the pedal housing and your finished. I 3d printed a mount and glued it to the pedal base using hot melt glue
    Ive tried to keep everything as simple as I can so anyone can use it but im sure improvements could be made but this worked well for me
    I don't own the g27 anymore as ive upgraded to OSW direct drive and simcraft pedals but i hope this helps any of you guys stuck on this and if you have any questions please ask and ill help if I can.
    IMG_0062.JPG G27 load cell_pcb.jpg

    Attached Files:

    • Like Like x 2
    • Informative Informative x 1
  11. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    21,020
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    147,824Coins
    Ratings:
    +10,876 / 54 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    Thanks for sharing your work, I have added it to the FAQs here, with credit to yourself: https://www.xsimulator.net/community/faq/pedals-and-buttons.337/
  12. Qc_Ricky_13

    Qc_Ricky_13 New Member

    Joined:
    Jun 12, 2020
    Messages:
    1
    Balance:
    16Coins
    Ratings:
    +0 / 0 / -0
    Did you make it work properly with 3 load cells?
  13. 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
    Never heard from the person trying it so i dont know.
  14. JayZ83

    JayZ83 New Member

    Joined:
    May 25, 2020
    Messages:
    23
    Balance:
    152Coins
    Ratings:
    +5 / 0 / -0
    My Motion Simulator:
    Arduino
    Hi ,
    I was able to follow your guide and make a INA122p 3 wires x2 50kgs load cell working.
    For witch could output 0-5V , works perfect with G29 PS4.

    But i had no luck with the 4 wires one with the same INA122 setup.
    4wires.jpg

    Try various connection /sweep pin .. but had no luck.
    I was getting 5V- 0 output for which is an inverted. no way to set any Invert channels on PS4..

    Thank you .
  15. Erik Middeldorp

    Erik Middeldorp Member

    Joined:
    Sep 15, 2018
    Messages:
    50
    Occupation:
    sheet metal worker
    Location:
    Auckland, New Zealand
    Balance:
    623Coins
    Ratings:
    +46 / 0 / -0
  16. JayZ83

    JayZ83 New Member

    Joined:
    May 25, 2020
    Messages:
    23
    Balance:
    152Coins
    Ratings:
    +5 / 0 / -0
    My Motion Simulator:
    Arduino
    hi Erik
    Thanks for your prompt reply.
    Just download and rewires . It’s s very simply sweep 5BDD1EDA-2595-4951-BEE2-71D76344735F.jpeg

    For which I had no luck again.
    got a constant 1.6V Output. No various upon and weight load.

    By disconnect cell +ve and -ve , check there is working fine load cell.
    By rest all wires. I could get a 5-0V .

    which means .. I have no luck again.

    thank you. don’t know if you have any idea on it.
  17. Erik Middeldorp

    Erik Middeldorp Member

    Joined:
    Sep 15, 2018
    Messages:
    50
    Occupation:
    sheet metal worker
    Location:
    Auckland, New Zealand
    Balance:
    623Coins
    Ratings:
    +46 / 0 / -0
    can you post a link to the load cell you're using? A data sheet or something? I don't know much about electronics but could have a look.
    Does it work to reverse the 50kg load cells you mentioned?
  18. JayZ83

    JayZ83 New Member

    Joined:
    May 25, 2020
    Messages:
    23
    Balance:
    152Coins
    Ratings:
    +5 / 0 / -0
    My Motion Simulator:
    Arduino
    Thanks for your suggest. I try with the old circuit and it works perfectly with the new 4 wires load cell.
    By then I try all my new INA122PA , all failed as what mentioned before .
    Try every means but no luck , by then I realized that was not our problem. I had complained to the seller . And he will send me some new chips with same as my working models.
    cant believe this ..

    thanks again and hope they do send some new working one.
    • Like Like x 1
  19. TonyASh

    TonyASh New Member

    Joined:
    May 17, 2020
    Messages:
    2
    Balance:
    53Coins
    Ratings:
    +0 / 0 / -0
    Hello Guys! I need some help. I was built my first amplifier board for loadcell using IPA122P. It's work perfectly. Later, I bought 10pcs of the same ina122p for aliexpress but the seller sent me not iIPA122P but IPA122PA and now the load cell amplifier does not work at all. If you put IPA122P on this scheme, then everything works correctly!

    Perhaps someone will tell you what needs to be done so that the amplifier works correctly on the INA122PA chip
  20. JayZ83

    JayZ83 New Member

    Joined:
    May 25, 2020
    Messages:
    23
    Balance:
    152Coins
    Ratings:
    +5 / 0 / -0
    My Motion Simulator:
    Arduino
    hi Erik .
    Here with some good news . After changing all the chips to a new one . All working perfectly.
    with your diagram which could make my reverse voltage for the G29.
    Thanks again.
    • Like Like x 2