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

DIY Pedals & Buttons Controller

Discussion in 'DIY peripherals' started by TOPMO3, Jul 30, 2016.

  1. TOPMO3

    TOPMO3 Active Member

    Joined:
    May 12, 2015
    Messages:
    133
    Location:
    Russia
    Balance:
    890Coins
    Ratings:
    +201 / 0 / -0
    Hi all!

    Just want to share my new project - pedals & buttons controller.
    It can be used for DIY buttons boxes, button rim plates, pedals, hand brakes, gear shifters, etc, etc — everywhere you need joystick/gamepad interface with PC.

    Device capabilities are:
    • 6x 12-bit (4096 steps) axises
    • rotary encoders support
    • rotary switches support
    • matrix buttons support
    • single buttons support
    • axises calibration
    • analog inputs as buttons
    • 1kHz exchange rate with PC, which means 1ms maximum latency for axises
    TBH, specs not so bad ;)
    For example, 4096 steps for axises if better then Logitech G27 (256 step) and Fanatec Elites (1024 steps).
    And 1kHz rate is also very good, it means 1ms latency for axises (G27 has 2ms latency, Fanatec Elites has 16ms and DSD 12 bit controller with integrated load cell has 20ms)


    For the project I choose little STM32F103C8T6 minimum development board. Its more powerfull and cheeper then Arduino. For example, here is brief comparison with Arduino Leonardo board
    post-1259-0-08612400-1469266220.png
    One big drawback is that you need additional external programmer. But its not expensive also, total price for mini board + programmer is still comparable with Arduino clones.

    Pics of these little things

    post-1259-0-24702500-1469262296.jpg post-1259-0-49304600-1469262304.jpg


    I bought both items on aliexpress.com, search for «STM32F103C8T6 Minimum System Development Board» and «ST-Link v2 mini», for example this and this.

    Schematics of the board

    Here is pinout you get after flashing the firmware first time:

    post-1259-0-00689100-1469266347.png


    Also I programmed small PC-based app named OSHStudio, which allows you to choose a function for each pin. Pins’ functions can be selected in the «Pins Configuration» tab, also here you can choose your board type. Here is how the initial pinout looks in OSHStudio, when you click «Get Config from Device»:

    [​IMG]


    Buttons

    When buttons wired in matrix, columns have to be connected to Button Matrix COLUMNS pins, rows — to Button Matrix ROWS pins. Single separate buttons (not matrix), can be connect to «Single Button +3,3V» or «Single Button GND». If you connect button to «Single Button +3.3V» than connect the other side of button to +3.3V, if you connect button to «Single Button GND» than connect it to GND. Here is an example of matrix wiring:

    [​IMG]

    You can test your buttons in the «Buttons» tab of OSHStudio:

    [​IMG]

    In this tab you can also configure POV Hat switches. When activated first Hat Switch used first 4 buttons of matrix, 2nd Hat Switch — from 2nd 4 buttons and so on.

    Also here you can tune threshold of analog inputs, after that buttons press will be registered (for Analog to Button pin types)



    Rotary Encoders

    The firmware supports full step, half step and quarter step encoders. Rotary encoders can be wired in «chained» or «single» configuration. Chained config means you wire side encoders’ pins (PINA & PINB) together and central pin become «control» pin. Central pin identified your encoder type — 1/1 (full step), 1/2 (half step) or 1/4 (quarter step). You can wire different type encoders in one chain.

    Schematics:

    [​IMG]

    Also encoders can be connected in single configuration. In this case you should configure side pins according to the type of encoder and central pin have to be connected to +3.3V.

    Schematics:

    [​IMG]


    If necessary you can remap encoders pins on the «Single Encoders Config» tab.

    [​IMG]


    Encoders can also be tested in the «Buttons» tab.



    Rotary Switches

    Virtual button is «clicked» when shaft is changing position.

    [​IMG]


    Axises

    Analog pins ADC0 — ADC6 used to connect potentiometers or other analog inputs. Also you can calibrate axises in OSHStudio, and calibration values in this case will be stored in MCU itself. After calibration an axis is «expanded» by the controller, so PC always sees axis as 4096 steps. There is also a possibility of AutoCalibration of axes.

    As you can see, there is also «Combined axis» function. It means you can combine 2 analog inputs in one axis. The function is mainly intended for rims with 2 clutch paddles. There are 2 possible modes:

    • cooperative work — in this mode results from both analog inputs are summarized. You can choose weight of each input by slider.
    • each on his own — each analog input works independently but for one axis. For example you can short calibrate an one input (paddle) for fast gear changes and an other calibrate as normal axis — for starting.

    [​IMG]


    Notes
    I recommend set to «Not used» all unused pins

    Available firmware:

    Version 0.14 — Autocalibration axes, Analog2Button pin type and combined axis added

    Version 0.13 — Single Encoders Config tab added

    Version 0.12 — Tuning tab added

    Version 0.11 — Single encoders support added

    Version 0.10 — base version

    If you wonder how to flash firmware to the board you can check this post — How to flash firmware to STM32Fx
    Project URL -https://opensimhardware.wordpress.com/pedal-button-controller/
    • Like Like x 10
    • Useful Useful x 4
    • Informative Informative x 2
    • Creative Creative x 1
    Last edited: Nov 16, 2017
  2. PiaMan

    PiaMan Active Member

    Joined:
    Aug 2, 2015
    Messages:
    192
    Location:
    Saskatchewan, CANADA
    Balance:
    607Coins
    Ratings:
    +131 / 2 / -0
    My Motion Simulator:
    3DOF, DC motor, SCN5, Arduino
    awesome project. I think i may order a board and programmer and try it out. I want to get rid of my hacked up site joystick i am currently using for my pedals to clean up aesthetics.

    thanks!
  3. TOPMO3

    TOPMO3 Active Member

    Joined:
    May 12, 2015
    Messages:
    133
    Location:
    Russia
    Balance:
    890Coins
    Ratings:
    +201 / 0 / -0
    @PiaMan, yes components are cheep enough just for try it out.

    Testing the controller with DXTweak and G27 pedals (better to watch in full screen and HD):



    forgot to leave TODO list:
    - make PC based configure app which allows to choose different number of encoders/buttons/axises
    - make PCB including integrated load-cell amplifier
    - add support of another controls like rotary switches, on/off toggles. etc
    • Like Like x 3
  4. EduardoMoreira

    EduardoMoreira Member

    Joined:
    Jul 5, 2016
    Messages:
    31
    Balance:
    113Coins
    Ratings:
    +20 / 1 / -0
    My Motion Simulator:
    AC motor, Arduino, Motion platform, 4DOF
    Great project man...thx for sharing...
    it would be possible to create a firmware that accept a pov switch?
  5. TOPMO3

    TOPMO3 Active Member

    Joined:
    May 12, 2015
    Messages:
    133
    Location:
    Russia
    Balance:
    890Coins
    Ratings:
    +201 / 0 / -0
  6. zigzag49

    zigzag49 Active Member

    Joined:
    May 27, 2014
    Messages:
    251
    Balance:
    705Coins
    Ratings:
    +220 / 3 / -0
    My Motion Simulator:
    2DOF, Arduino
    Thank you for your project.
    I can not find the Arduino code in github project, if you could tell me.
    :blush
    Thank you
  7. TOPMO3

    TOPMO3 Active Member

    Joined:
    May 12, 2015
    Messages:
    133
    Location:
    Russia
    Balance:
    890Coins
    Ratings:
    +201 / 0 / -0
    Hi @zigzag49 ,

    the firmare is not for Arduino, but for stm32f103 mini dev board. Its binary file (ready to upload), but if you would like to take a look on a the source code, you can find it github project
  8. zigzag49

    zigzag49 Active Member

    Joined:
    May 27, 2014
    Messages:
    251
    Balance:
    705Coins
    Ratings:
    +220 / 3 / -0
    My Motion Simulator:
    2DOF, Arduino
    Ok thank you I confused .
    I'll look in more detail ;)
  9. cazsan

    cazsan Member

    Joined:
    Oct 1, 2015
    Messages:
    40
    Occupation:
    Programmer
    Location:
    France
    Balance:
    444Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    Arduino
    This project look interesting, I'm following closely
  10. RacingMat

    RacingMat Well-Known Member Gold Contributor

    Joined:
    Feb 22, 2013
    Messages:
    2,234
    Location:
    Marseille - FRANCE
    Balance:
    20,890Coins
    Ratings:
    +2,083 / 21 / -2
    My Motion Simulator:
    2DOF, DC motor, Arduino
    That's new around her!
    Congrats! and thanks for sharing
  11. WowaDriver

    WowaDriver Waldemar Jost

    Joined:
    Mar 4, 2014
    Messages:
    59
    Occupation:
    Bachelor of Science and Engineering
    Location:
    Hannover
    Balance:
    1,127Coins
    Ratings:
    +42 / 0 / -0
    My Motion Simulator:
    2DOF, 3DOF, DC motor, Arduino, JRK
    Awsome news! Thanks for sharing!! I will try it out thanks a lot!
  12. razzor13bt

    razzor13bt Member

    Joined:
    Jan 10, 2017
    Messages:
    32
    Occupation:
    automotive technician, sales manager.
    Location:
    Durban, South Africa
    Balance:
    393Coins
    Ratings:
    +8 / 0 / -0
    thanks for this project. works a charm. have some buttons to replace that are not working but it was a lot easier to get working compared to the Arduino version :)
  13. TOPMO3

    TOPMO3 Active Member

    Joined:
    May 12, 2015
    Messages:
    133
    Location:
    Russia
    Balance:
    890Coins
    Ratings:
    +201 / 0 / -0
    Glad to hear it works :cheers
    Currently I'm writing app that will allow to configure a type of pins on the fly, so hopefully it will easer to use it (soon :))
    • Like Like x 1
  14. obobo

    obobo Active Member

    Joined:
    Nov 8, 2016
    Messages:
    248
    Location:
    France
    Balance:
    1,323Coins
    Ratings:
    +77 / 1 / -0
    My Motion Simulator:
    2DOF, DC motor, Arduino
    fancy 2000 don't post in every thread with "nice build" to get coins !!
    • Agree Agree x 1
  15. razzor13bt

    razzor13bt Member

    Joined:
    Jan 10, 2017
    Messages:
    32
    Occupation:
    automotive technician, sales manager.
    Location:
    Durban, South Africa
    Balance:
    393Coins
    Ratings:
    +8 / 0 / -0
    TOPMO3 i have a problem.
    I had to reassemble the button box as some buttons where not working and my supplier also mixed up a few n/c buttons in my order.
    sorted out the buttons to be all n/open and all working.
    Now my issue is none of the buttons will work :(
    The encoders work fine.
    The 2 shifter buttons are working but show the same button number in the game controller properties.
    Hope you can advise and possibly show me where i have gone wrong.
    my layout attached. Wiring_Schemeshiraz.jpg
  16. TOPMO3

    TOPMO3 Active Member

    Joined:
    May 12, 2015
    Messages:
    133
    Location:
    Russia
    Balance:
    890Coins
    Ratings:
    +201 / 0 / -0
    Hi @razzor13bt
    You know, your layout seems correct to me. Can the problem lie on a hardware side - i.e bad connection/soldering etc?
  17. razzor13bt

    razzor13bt Member

    Joined:
    Jan 10, 2017
    Messages:
    32
    Occupation:
    automotive technician, sales manager.
    Location:
    Durban, South Africa
    Balance:
    393Coins
    Ratings:
    +8 / 0 / -0
    sat late this afternoon with it.
    Resoldered with new thicker wire, not the wire breadboard jumpers the electronics shop supplied.
    also used a multimeter and checked continuity and also put it on ampmeter to use to bridge terminals on the board.
    noticed occassionally a light lit up on the game controller display, was when i bridged col6 with row1 or row2.
    Turns out its the same light that lights up when i touched the row 1 or 2 terminals. cant recall properly but it was number 27 or 29 in the game controller display.
    Will try again tomorrow evening after work.
  18. razzor13bt

    razzor13bt Member

    Joined:
    Jan 10, 2017
    Messages:
    32
    Occupation:
    automotive technician, sales manager.
    Location:
    Durban, South Africa
    Balance:
    393Coins
    Ratings:
    +8 / 0 / -0
    The ARM is being powered by a usb cable connected to a usb hub with a 2amp 5v supply.
  19. razzor13bt

    razzor13bt Member

    Joined:
    Jan 10, 2017
    Messages:
    32
    Occupation:
    automotive technician, sales manager.
    Location:
    Durban, South Africa
    Balance:
    393Coins
    Ratings:
    +8 / 0 / -0
    I had a chance today to work on it. spent last 3 hours checking everything.
    I only get the following buttons to work as per pinout pic in the 1st post.
    As mentioned before all 4 encoders work.
    I get b4-row1 working with col1-c13, col2-c14, col3-c15, col5-b3, col6-a7.
    col4-b12 does not work.
    row2, row3, row4, row5, row6 all do not work with any of the columns.

    Have to try and get off work to go and buy another board in case it is the faulty part.
  20. TOPMO3

    TOPMO3 Active Member

    Joined:
    May 12, 2015
    Messages:
    133
    Location:
    Russia
    Balance:
    890Coins
    Ratings:
    +201 / 0 / -0
    well, its really strange. If you don't use analog inputs (A0-A6), I can make firmware which will utilize them for row1 - row6 for you.