1. 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!
  2. 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
  3. 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

Question DIY Pedals arduino leonardo + load cell.

Discussion in 'DIY peripherals' started by Alecont, Mar 17, 2021.

  1. Alecont

    Alecont New Member

    Joined:
    Mar 17, 2021
    Messages:
    14
    Balance:
    121Coins
    Ratings:
    +1 / 0 / -0
    Hello good afternoon, i from Argentina, first of all apologies for my English.
    I make this post looking for help to carry out my project, I have an Arduino leonardo + HX711 + load cell 50kg board. My intentions to acquire other lower kg load cells for accelerator and clutch. But I am not sure how to perform its operation, programming, etc. I would really appreciate it very much if through this post you can guide me a little, I have all the materials to start its construction.
    Again thank you very much and apologies for my English.
  2. Ads Master

    Ads Master

    Balance:
    Coins
    Ratings:
    +0 / 0 / -0
  3. yellofella

    yellofella Member

    Joined:
    Aug 8, 2011
    Messages:
    94
    Occupation:
    builder
    Location:
    UK
    Balance:
    740Coins
    Ratings:
    +82 / 0 / -0
    My Motion Simulator:
    3DOF, SimforceGT
    Hi buddy and welcome to the community.
    If you are looking at building your own pedal set then there are much better ways to do it than use an Arduino Leonardo. The problems you are going to have are resolution at only 8bit and writing the Arduino code. You may find an example in the FAQ's on this site if you really want to go with the Leonardo but i personally think you would do better with this
    BU0836-LC Load Cell Joystick Controller [BU0836-LC] - 30.00GBP : Leo Bodnar, Simulator Electronics
    This board is designed to be used in sim pedal setups. It has a dedicated load cell input for the brake pedal and 7 potentiometer inputs although you only need 2 for the accelerator and clutch pedals as these do NOT use load cells. It is 12bit on all inputs and as a bonus allows you to add 32 buttons or 16 rotary encoders or a mix of each if you like for a button box and no need to write any Arduino code at all.
    It is the same controller that is on my simcraft high end pedals that cost me over £1000.
    Just connect your potentiometers and load cell, plug in the usb cable, open the di view software to setup and your done.
    hope this helps buddy.
    • Agree Agree x 1
  4. Alecont

    Alecont New Member

    Joined:
    Mar 17, 2021
    Messages:
    14
    Balance:
    121Coins
    Ratings:
    +1 / 0 / -0

    Thank you very much for your response, I went to Arduino because it is very difficult to find in Argentina another like Leo Bodnar, and importing at this time is not viable in my country. Because I'm looking for the best possible alternative to be able to do it with Arduino.
  5. Gadget999

    Gadget999 Well-Known Member

    Joined:
    Dec 27, 2015
    Messages:
    1,377
    Location:
    London
    Balance:
    9,260Coins
    Ratings:
    +307 / 8 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, 6DOF
    "The problems you are going to have are resolution at only 8bit and writing the Arduino code."

    that is incorrect

    a standard arduino / avr board has 10 bit resolution on analogue read (0-1024 steps) the analogue write has 8 bit (255 steps)

    plenty of compatible boards have resolutions of 8195 steps and higher

    there is example code here - https://learn.sparkfun.com/tutorials/load-cell-amplifier-hx711-breakout-hookup-guide/all


    an arduino leonardo or a pro micro can be configured to work as a joystick controller and it makes them very suitable
  6. yellofella

    yellofella Member

    Joined:
    Aug 8, 2011
    Messages:
    94
    Occupation:
    builder
    Location:
    UK
    Balance:
    740Coins
    Ratings:
    +82 / 0 / -0
    My Motion Simulator:
    3DOF, SimforceGT
    Hi guys. @Gadget999 you are correct the Arduino does have a 10bit ADC and not 8bit as i previously mentioned. However the greater point i was trying to make was that there is better hardware available than an Arduino to control pedals for sim racing at a low cost. I included the link to the Bodnar controller as most high end pedals use this interface board. My simcraft pedals that i purchased 5 years ago use it and if you bought the pedals today they still use it. I think they are probably the best pedal set that you can buy for sim racing but at a high cost. Here is a link to them
    www.simcraft.com/sim-racing-pedals-racing-simulator-pedals-tilton-three-pedal-set/
    I was just trying to point a new member to the best hardware for his needs and that you can buy the controller separately without the massive cost. To try to avoid him getting bogged down in code or wasting money on hardware only to find out later that there was a better way. All this is just advice as @Alecont mentioned in his post that he has the hardware and is ready to build so the arduino route it is for now at least.
  7. Alecont

    Alecont New Member

    Joined:
    Mar 17, 2021
    Messages:
    14
    Balance:
    121Coins
    Ratings:
    +1 / 0 / -0
    @Gadget999 @yellofella Thank you very much for your answers, for the moment I will experiment with Arduino, I will also consider for the future leo Bodnar board.
  8. Alecont

    Alecont New Member

    Joined:
    Mar 17, 2021
    Messages:
    14
    Balance:
    121Coins
    Ratings:
    +1 / 0 / -0
    @Gadget999 Hi. Get the load cell and potentiometers to work. But in separate sketches, I can't make them work in the same sketch, could you help me ?? I would appreciate it as it is the last thing I need to finish my set of 3 pedals.
  9. Gadget999

    Gadget999 Well-Known Member

    Joined:
    Dec 27, 2015
    Messages:
    1,377
    Location:
    London
    Balance:
    9,260Coins
    Ratings:
    +307 / 8 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, 6DOF
    Here are 2 sketches I put together for Alecont

    it will allow you to use potentiometers and a loadcell brake together

    noorbeast - might be worth saving the code for future reference


    ----------------------------------------------------------




    #include <Joystick.h>
    #include <HX711.h>
    #define calibration_factor 28000 // Change this value to give accurate reading with your known mass.
    #define DOUT 1
    #define CLK 0


    Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID,
    JOYSTICK_TYPE_MULTI_AXIS, 4, 3,
    false, false, true, false, false, false,
    false, true, true, true, false);

    HX711 scale;

    int brake = 0;
    int lastBrakeValue = 0;
    int RotzAxis_ = 0;
    int Throttle_ = 0;

    const bool initAutoSendState = true;


    void setup() {
    // put your setup code here, to run once:
    Joystick.setBrakeRange(0, 1023);


    Joystick.begin();
    Serial.begin(38400);

    scale.begin(DOUT, CLK);
    scale.set_scale(calibration_factor);
    scale.tare();
    }

    void loop() {
    // put your main code here, to run repeatedly:
    Serial.println (brake);
    brake = scale.get_units(); // if the value is inverted put a - sign in front like -scale.get

    if (brake < 0 or brake < 1) {
    brake = 0;
    }

    if (lastBrakeValue != brake) {
    Joystick.setBrake(brake);
    lastBrakeValue = brake;
    }


    RotzAxis_ = analogRead(A1);
    RotzAxis_ = map(RotzAxis_,1023,0,255,0);
    Joystick.setRzAxis(RotzAxis_);

    Throttle_ = analogRead(A0);
    Throttle_ = map(Throttle_,1023,0,255,0);
    Joystick.setThrottle(Throttle_);

    Serial.println(Throttle_);


    }
    • Like Like x 2
  10. Alecont

    Alecont New Member

    Joined:
    Mar 17, 2021
    Messages:
    14
    Balance:
    121Coins
    Ratings:
    +1 / 0 / -0
    Thank you very much for helping me put my 2 codes together in the same sketch.

    And whoever needs to use Arduino recommend the tutorials GP Race Simulation on youtube, its sketches and so on. It can be used for anyone who can't access Leo Bodnar boards as in my case.
  11. noorbeast

    noorbeast VR Tassie Devil Staff Member Moderator Race Director

    Joined:
    Jul 13, 2014
    Messages:
    17,085
    Occupation:
    Innovative tech specialist for NGOs
    Location:
    St Helens, Tasmania, Australia
    Balance:
    124,042Coins
    Ratings:
    +9,720 / 47 / -2
    My Motion Simulator:
    3DOF, DC motor, JRK
    Thanks for sharing your work, added o the FAQs with credit to yourself: https://www.xsimulator.net/community/faq/potentiomenter-and-load-cell-code.388/
    • Winner Winner x 1
  12. Alecont

    Alecont New Member

    Joined:
    Mar 17, 2021
    Messages:
    14
    Balance:
    121Coins
    Ratings:
    +1 / 0 / -0
    • Agree Agree x 1
  13. hiihoo

    hiihoo New Member

    Joined:
    Apr 4, 2021
    Messages:
    3
    Balance:
    10Coins
    Ratings:
    +1 / 0 / -0
    Sorry to bother, which of millions of joystick-librarys does this use?
    And, I suppose one can add another loadcell also, for handbrake?

    HX711 has two channels, not yet digged deeper, every example just uses one. :)
  14. hiihoo

    hiihoo New Member

    Joined:
    Apr 4, 2021
    Messages:
    3
    Balance:
    10Coins
    Ratings:
    +1 / 0 / -0
    Could not edit my recent post, so just noticed that hx711 librarys are also millions... :)
    Everybody wants to invent wheel again, someday, given enough time, we will have square wheels again...
  15. Gadget999

    Gadget999 Well-Known Member

    Joined:
    Dec 27, 2015
    Messages:
    1,377
    Location:
    London
    Balance:
    9,260Coins
    Ratings:
    +307 / 8 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino, 6DOF
    download one and try - if it doesn't compile download another
  16. hiihoo

    hiihoo New Member

    Joined:
    Apr 4, 2021
    Messages:
    3
    Balance:
    10Coins
    Ratings:
    +1 / 0 / -0
    :)

    So I did, now works. If I didn't be so adhd I might be able to tell which one they were, but..
    The first ofcourse don't work, so try another..

    Also, if somebody else is doing this and installing hardware to diffucult to get place, check the 10hz/80hz jumpers first. :)
    • Agree Agree x 1