Pedal & Button Controller (eng)

During building my pedals, I decided to make my own pedal controller using cheep and affordable components. Already having some  experience with Arduino boards, I know their capabilities and decided to route a STM32 way this time (mostly to learn something new though).

Here is the comparision of Arduino Leonardo (which is a most likely candidate for our goal) and STM32F103C8T6 (which I used)

Arduino Leonardo STM32F103C8T6
Flash 32KB 64KB
Architecture 8-bit ATMEL AVR 32-bit ARM CORTEX-M3
Frequency 16MHz up to 72MHz
GPIO pins 20 26
PWM 7 12
Timers 1x 16-bit, 2x 8-bit 3x 16-bit, 1x pwm
Peripheral 10-bit ADC (6 channels)
1x I2C
1x SPI
2 x 12-bit, 1 μs A/D converters (7 channels)
7-channel DMA controller
2x I2C
2x SPI

As you can see, specs for stm32f103c8 are not so bad. And it’s cheaper than Leonardo!

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.



I bought both items on, search for «STM32F103C8T6 Minimum System Development Board» and «ST-Link v2 mini», for example this and this. Also there is another version of the board called BlackPill — link. It has less available pins, but has mounting holes.

Schematics for the dev board: STM32Mini

Or here in pdf

Pinout in pdf — The-Generic-STM32F103-Pinout-Diagram


So, after some time, I programmed simracing-oriented firmware for the device.

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

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.

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

	- |3VB		 +3.3V| -
  	- |C13		   GND| -
  COL1	- |C14		   +5V| - 
  COL2	- |C15		    B9| - ROW6
  ADC0 	- |A0		    B8| - ROW5
  ADC1 	- |A1		    B7| - ROW4
  ADC2	- |A2		    B6| - ROW3
  ADC3	- |A3		    B5| - ROW2
  ADC4	- |A4		    B4| - ROW1
  ADC5	- |A5		    B3| - COL4
  ADC6	- |A6		   A15| - ROT11
  COL5	- |A7		   A12| - 
  ROT1	- |B0		   A11| - 
  ROT2	- |B1		   A10| - ROT8
  ROTA	- |B10		    A9| - ROT7
  ROTB	- |B11		    A8| - ROT6
	- |R		   B15| - ROT5
	- |+3.3V	   B14| - ROT4
	- |GND		   B13| - ROT3
	- |GND		   B12| - COL3

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»:




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:

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


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.


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.



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.



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


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


Rotary Switches

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



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.




Beginning with 0.15 version there is a more advanced possibility to map analog iinputs to buttons. You can configure up to 10 analog inputs and each of them can be mapped up to 10 buttons (keep in mind though total number of buttons is still 64). You can define it in the Analog2Buttons tab



Tuning Tab

You can tune such parameters as:

  • «Your identifier for the device» — unique identifier for the board, if you have for example few boards, you can assign different idetigiers to them — «pedals», «buttonsbox», etc
  • «USB polling interval» — means interval between USB packets, i.e. 1ms means 1kHz USB exchange frequency. For high performance devices you can try decrease this down to 1ms, for anything else default 16ms probably is enough.
  • «Amount of time a button will be pressed when Rotary Encoder position changed» — virtual button will appear as pressed during this time, for encoders
  • «Amount of time a button will be pressed when Rotary Switch position changed» -virtual button will appear as pressed during this time, for rotary switches
  • «Amount of time a button will be pressed when Analog Input position changed» -virtual button will appear as pressed during this time, for analog2buttons inputs
  • «Time since previous Rotary Switch change» — if you change rotary switch position in less time than the parameter then buttons presses will not be registered. So if you rotate switch fast enough then intermediate positions will not be registered.
  • «Time since previous Analog Input position change» — same as previous one, but for Analog2Buttons types
  • «Debounce time for Rotary Encoders» and «Debounce time for Buttons» — try to increase it if you have problem with phantom presses




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

Source code in my github project.

Available firmware + OSHStudio app:

Version 0.15 — More stable USB operations, more advanced Analog2Buttons type

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


Pedal & Button Controller (eng): 145 комментариев

  1. Hi,

    I’ve managed to flash the firmware (tried versions 0.1 to 0.4) but I’m having some trouble with OSHStudio. When I click «Get Config From Device» the application hangs and I have to force close it.

    Any ideas?



    1. Hi
      The 1st rule is always use same versions of FW and app.
      The 2nd try to make full chip erase (through st-link utility) and reflash FW. It makes default FW config — maybe it’ll help
      And the 3rd it seems there is some bug with USB communications. Some people reports the app is closing as far as a board is connected. I’m investigating it currently. Anyway, it seems newer versions of windows have fewer problems, so try to use win10 if you can


      1. Hi,

        Thanks for the reply. I’ve tried all versions of the application, always with the correct firmware / OSHStudio combination. I always erase the whole chip before flashing.

        I am using Windows 10 64-bit. I have tried with Anti-Virus enabled and disabled.

        I might have a hardware problem so am going to try ordering a different unit. My final design will use a blackpill, rather than bluepill, so I might as well order one now.

        Does OSHStudio write any kind of log file that might show where the problem lies? I was going to try building the QT Creator project and debug from there but if there is already some logging present I won’t bother.

        I’ll report back.



      2. There are not so much to log, from sniffing USB traffic I noticed that the app doesn’t catch every USB packet send to host. So in that «hang» moments the app just waiting USB packet while MCU sending them diligently.
        As a last resort I can make FW with your custom default config, so you’ll not need to configure it at all


      3. hi,
        is it possible to use an A1302 hall sensor, instead of the potentiometer, without editing your firmware?
        I want to use the hall sensor for the pedal control.

        thanks in advance 🙂


      4. Yes, I think it should works. Try to power it by +3.3V at first, if it will not work or axis will not show full range, then try to power from +5V.
        In general, any analog sensor can be used, MCU doesn’t bother (or even know) the type of device signal is coming from

        Нравится 1 человек

    2. @opensimharware.

      That is very kind of you to offer. I’m going to try the new Black Pill units when they arrive. If that doesn’t work then I’m fairly confident I can hex edit the flash file to do what I need. I can see that the default button configurations are in: and

      and I can see the corresponding entries at the end of the flashed image. I could probably get away with the default config but I’d like to switch off the unused pins, as you recommend. Changing the pintype to 0 for each unused pin should do that, yes?

      I’ve also started setting up the development environment, just in case hex editing doesn’t work or I need to make more changes. Is the project fairly easy to build with the default environment?

      Thanks for all your help by the way. I’ll make sure to put something into your donation jar!



      1. >>Changing the pintype to 0 for each unused pin should do that, yes?
        Yes, exactly!

        >>Is the project fairly easy to build with the default environment?
        I’m using Atollic TrueStudio, so I believe if you install it then the project should build without any issues

        >>I’ll make sure to put something into your donation jar!
        Thanks you very much, very appreciated! 🙂


      2. I have the project building in TrueStudio now, it worked pretty much out of the box. A comparison of the source build and the released 0.4 hex shows they are different but I assume that is because you’ve made changes since the release.

        My blackpills should arrive tomorrow so I’m going to test them first. If that doesn’t work I’ll create my own build with the settings how I want. Out of interest, do you use 32-bit or 64-bit Windows? I’m wondering if that is a factor somehow.



      3. Hi,

        I’ve decided to have another go at debugging the USB issue. Can you tell me what environment you used to build the OSHStudio App please? I’m guessing it is QT Creator but not sure on what version, etc.




    3. Thanks. I’ve got the environment up and running.

      The first thing I’ve noticed is that the hanging I’m seeing happens in the getConfig_Slot() function. There are several lines like:

      } while ((buf[0] != 4) || j 100. In my case, buf[0] is never 4, and so j just keeps going up and up. the second half of the || is never evaluated.

      I tried changing this to && instead, which I think makes more sense. The program doesn’t hang now, but the results are not correct. I suspect whatever is needed to make buf[0] == 4 is not happening and this is causing things to get out of step.

      I hope this makes sense. I’m not a c++ programmer so it’s painfully slow for me.



      1. >> whatever is needed to make buf[0] == 4 is not happening
        TBH Its my suspicious also. It seems the app can’t catch sometimes USB packets with configuration. So I have to implement some attribute and send only config packets when host requests (now joystick and config packets are sent mixed)


  2. Ok, I found something on german Amazon. Peaople are saying that often there is a missing pull-up resistor for the reset (or a wrong one). You fix it bu using a 1 to 1.5K resistor otherwise the board gets stuck in reset mode permanetly.
    Maybe this can help. You have to google «STM32 missing resistor» or wrong resistor.


    1. Thanks for that suggestion. I’ll take a look.
      I’m not sure my board is stuck in Reset though, as I can connect to the board in OSHStudio, I just can’t get or set the configuration from it. I’ve ordered a couple of Black Pill units from a different vendor, just to see if they behave differently.


    1. Hi, I didn’t try this switch yet, but for what I see from datasheet it doesn’t required any special support from the fw, because its basically some combination of rotary encoders and buttons. Anyway I’m going to buy this switch and play with it, so I’ll say more specifically about it


      1. Hi!
        Dont get my hands on it yet, but according to switch’s specs it looks like normal behaviour. «Output relation chart between lever position and on position» states PUSH-COM is also ON when A, B, C, D are ON. Its how hardware works, so if we want central click to work independently we have to add some fw support for it, catching central clicks only if side clicks are OFF in this moment. I’ll add this feature to the to-do list


  3. Hello

    Congratulations for your project, it’s fantastic

    I have a little problem with the encoders. I program them well, but for some reason that I do not know, they are very late.
    There is some solution for this ….


  4. Hi, That’s a really good project. I’ve got a really quick question about OSH software I’m struggling to understand how to run it. Could you give more info about it? Which file do I have t run and how to. Thanks a lot


    1. Tried in all USB ports, and another pc and nothing. The only thing that works well are the push buttons

      A while back with version 0.10 went well, but it seems that something is wrong with the STM32 that I currently have.

      Can you recommend a store to buy?



      1. I almost always bought in the store I already linked in the article. BTW, can you try to reflash old 0.10 version to the board and see how encoders will behave? Maybe something wrong with encoders but not MCU. Also if you have some kind of EMI generator (like OSW) its always good idea to ground everything and hang ferrite core filters at USB cables.


      1. Can’t say anything about AC, better to ask on AC forums how to calibrate/use 3rd party controllers. From windows point of view its just some type of joystick, so if AC is able to support 3rd party joysticks (I think it should) then it should be standard process


  5. Hi

    Can you add a delay function to rotary switches? So that it ignores the change for 1 second before activating, this way if you want to move more than one places without activating buttons in between, this can be done.



  6. hi,

    I flashed the 0.14 .hex version on my stm32 board, using stlink. then I connected the stm32 board with usb cable but OSHStudio didn’t see the board.
    what is the problem?



    1. Hi!
      Short answer is such load cell amplifiers based on hx711 (or similar producing digital output) are not supported yet. I can consider it for adding such support in future releases. You can however make simple amplifier based on ina125 (look here for example, so you can connect analog output of this amplifier as standard analog input for the board


  7. Thanks for your answer and link . After further researchs, I’m going to try to scale the load cell/hx711 on the input of an analog pin of an arduino and then use the output of the arduino to control the potentiometer of my brake pedal. I’m a noob in arduino code but I’m gonna try.


    1. I’m not sure how you are going to control the pot of brake pedal. Usually when doing load cell mods people replaced that pot by load cell + amp. So you should make some construction when your brake pedal will push against load cell. Then (one of variants) you can connect output of amp and pots from 2 other pedals to the stm32 board as analog inputs. In such way you completely replaced you original pedal controller by the board and your pedals will be standalone device in PC. However you can loose console support this way.
      Another variant just replace brake pedal’s pot by load cell + amp, but keep your original controller. In this way you should just connect output of amp instead of brake pot to your controller. But there is no guarantee this will work because it depends how original controller was developed.


  8. Hi!
    I guess it was not very clear 😉 but I start with electronic, code and it’s not so easy.
    First, it’s obvious I need to mod the brake pedal in order to place the loadcell nicely to bend the loadcell correctly when I push on it.
    Example : (

    Secondly, I would like to use the loadcell and HX711 to send signal to my arduino. After a good calibration of the loadcell in the arduino , the idea is to send an Arduino output between 0V and 5V to the original potentiometer wiring of the brake pedal. So, I don’t have extra USB device but my pedal send a signal which come from the loadcell and not the pot anymore.

    Does it seem right to think like that?




    1. Hi!
      Yes, it’s possible. You can define custom part of device name in the Tuning tab. For example you can define «rim1» for one board and «rim2» for another and they will be shown as OSH PB Controller (rim1) and OSH PB Controller (rim2) in the devices and printers. Every board has its own unique serial number, so windows can distinguish them by s/n

      Нравится 1 человек

  9. Hi, I’ve managed to make it works and I was wondering if is possible to also use it to control 8 rgb less for the rpm though Simhub or if I need an external arduino to do that and if so is there anyway I can connect the arduino to the stm32 and use just one cable?


  10. hi 🙂

    can I use PA5 and PA6 as Rotary Enc PINA/PINB and set pins from PB9 to PB13 as Rotary Enc 1/1?
    (the others pins are used for button row/COLUMN and potentiometer (PA1, PA2, PA3, PA4))

    and then, what is the difference between 1/1, 1/2 and 1/4?

    thanks in advance 🙂

    Нравится 1 человек

    1. Hi!
      Sure, you can configure pins like this.
      1/1, 1/2, 1/4 are here for different encoders types — full step, half step and quorter step. If you don’t know exactly what type your encoders are, you can start with 1/4 and then if you need 4 detents/clicks for «press» button -its full step, if 2 detents/clicks — its half step )


      1. ahhh okay, it is now clear 🙂

        unfortunatelly, the encoders don’t work… no with my setup described in the previously post, no with your default setup. I tried all the combinations 1/1, 1/2, 1/4 but nothink. I have also reflashed the firmware. all the rest works correctly.


  11. sorry for the update, man
    I think there is a buf in OSH_Studio. if I restore default config, all works fine, even if I change the configuration, but if I reset all pin (or firstly set as not used) and configure them manually, the encoders don’t work.


  12. good morning man… sorry for the other reply…

    I think there is another bug in OSH Studio. I set combined axis, but after some «save config to device», the axis stops working 😦

    so… can you tell me what is the bit mask corresponding to chd rot enc 1/4 and combined axis (plus min/max calibration)? if yes, I edit your firmware (github) and bypass OSH Studio until you solve the issue.




        this is my config.
        1. (already reported) if I reset all pin or firstly set as not used and configure them manually, the encoders don’t work.
        2. if I change the calibration of axis six (combined) and I save config to the device, the calibration values change and after some re-calibraion/re-save, the axis stop working.
        3. (more debug is needed) I set enc 1/4 because of I have that encoder, but when I turn the enc, I see two button presses at the same time.

        thanks 🙂


      2. 2. What do you mean by «calibration values change»? Also usually you don’t need to calibrate combined axis itself. If you calibrate your A3 & A4 inputs, then combined axis probably will be correct already.
        3. two presses ot the same button or different? if same try another encoder type — 1/2 for example


  13. 2. actually, this is a real issue. anyway, if I set combined axis, and then set a minCal and maxCal, after three or four times (save to device), the axis stop working. probably, this is not a issue… I don’t know.

    3. I tested 14 encoders 1/4 and all have the problem. the only one 1/1 that I tested, works correctly.
    why this issue? tomorrow I’ll buy a new set of encoder, but I’d like to know why that encoders don’t work.

    let me clarify what I mean with «two pression at the same time».

    — optimal right encoder rotation corresponding to btt_1 pression
    — optimal left rotation corresponding to btt_2 pression.

    in my case, instead, if I turn encoder to the right, I see (on OSH Studio Button panel) btt_1 and btt_2 leads on. idem if I turn to the left. idem in Assetto Corsa… so I can’t use the encoder 😦


      1. 2. yes, I tried to calibrate axis but after I combined it. I save several tims because the after the first calibration, the axis values have changed, so I recalibrated… than have changed again. at the third «save config»… axis k.o.
        sorry, my english is not very well, so I can’t explain specifically the issue

        3. *_* I’ve done and now it’s much more precise. sometimes there are randomize pressions (other button) but at least I can use this 14 encoders that I’ve already bought. have you other tuning advice in order to improve further the accuracy?
        my tuning values (ms): 100 — 100 — 300 — 50

        thanks man!


      2. 2. If you want to make combined axis, first calibrate your inputs (A3 and A4), because they probably not work for full range and you can’t remove theit dead zones with overall axis6 calibration.
        And is it possible you make such calibration after that axis doesnt’ registered any values? Maybe you can make some video explaining the problem
        3. if sudden opposite rotations are registered maybe even more increase debounce time, but flaw of this that fast movements will not be registered

        Нравится 1 человек

  14. 2. mmm okay, I was wrong the process because I calibrated only the combined axis6. a new test is needed… if I don’t resolve, I’ll record you a video of the issue 🙂
    3. increasing the debounce time, the sudden opposite rotation, seems to be resolved. the only issue is that each time, is recognised another button… not the corresponding button of the left/right rotation of encoder (ex.) A, but the button corresponding to the (ex.) encoder B.
    I can record a video, if you want, but tomorrow I’ll buy a new encoder, just for test 🙂


      1. I rotate one encoder and it registered that encoder but also another. it is sporadically, but not so much.
        something different? for example?


  15. Well, I tested a new wirings and a new encoder. there are fewer interferences, but I think that the problem is the encoder type.

    as for as the calibration’s problem, I didn’t find a solution. maybe I should send you a video to explain the issue.

    but all that said, can I set:
    — encoder type 1/4
    — min/max potentiometer calibration
    — combined axis
    directly in the firmware, without use ohs studio?

    I’ve seen your firmware on github and I found the starting configuration, but I didn’t know how set 1/4 and other point of the list.
    so, please, can you give me more informations about that?



    1. Yes, if you can make some video, it’ll help in explaining
      Default config is defined in pin_conf pins[USEDPINS] array in periph_init.c
      Pin’s type is the 1st column. Pin types are defined in pintype enum in periph_init.h, so, for 1/4 encoder you should use Single_Rotary_PINA_4/Single_Rotary_PINB_4
      Calibrations are stored in axises[ADC_BUFF_SIZE] array of axis_conf struct
      Combined axis stuff (like AxisCombEnabled) is defined in the beginnings of periph_init.c


  16. hello 🙂

    first part:!OZcTFTrS!uDUuwmrUxCQbKRa9HKENA-bNF5ctnWIoYvZm48zIJuA
    second part:!fAFUFJBR!Ndvcng2rFYr6K7g5mtuVdstNimfZWPBS_VlqtO4mH18

    as you can see in the video, there is a problem with combined axis calibration (in reality, I don’t need this function, I would only report you what seems to me to be a OSH Studio bug).
    I started OSH Studio with default configuration and I disabled all unused analog pin.
    I combined two axis and I calibrate min and max values. as soon as I save to device, the read values changed. I recalibrated and I resaved… and again, they changed. so I recalibrated and this time, the axis go down… it was freezing. by remooving the calibration, they started functioning.

    I tried to calibrate separatelly the two axis and then combined it, but the calibration wasn’t correct. I tried also to calibrate the two axis in Combined Axis box with the same result.

    is this a bug or I’m a noob and my procedure is completely wrong?

    thanks for your support,


    1. Hi!
      OK, I saw your vids and I couldn’t say that something is completely wrong.

      Let me explain how calibration (in my FW) works.

      Analog sensor — pot, hall, etc — outputs voltage range from 0V to 3.3V. This signal converted by board’s ADC to some digit from 0 to 4095, where 0 is for 0V and 4095 is for 3.3V.
      In perfect world there is no need for calibration at all — you rotate your pot and a board send corresponding digit to PC. But in pedals (for example) a pot is used not for full range, but only for small range of its rotation and in such case you see it as for example 500 — 1000 (500 for minimum and 1000 for maximum) range for axis instead of full 0 — 4095.
      So with calibration we can «tell» to board what our actual min and max are. In our example we can set 500 as min calib value and 1000 as max calib value. And then the board will «map» actual values from 500 — 1000 sensor range to 0 — 4095 range of axis values. PC will still think his receiving 4095 distinct values, but actually its only «digital zoom» of 500 actual values to 4095
      This is why you see changed axis values after saving calibration — the board already changed values according to your calibration. In the case when your axis reported nothing — I think you chose such interval when your sensor reported nothing.

      So its how I think one should make calibration:
      1) make full movement of your input — pedal, paddle, etc. Remember showed min and max values of axis.
      2) Set min calib to what your axis ever reported as minimum and max calib — to ever reported as maximum. Add some deadzones if needed
      3) Click save and check the result. Again make full movement for your input — axis should report full range from 0 to 4095. Adjust your calibration settings if needed

      Нравится 1 человек

  17. Hello

    I have seen that in the OSHStudio you can put an analog to the button.

    what would be the correct connection for an analog type ps4 joystick.

    I currently have it functioning as an axis but if I can put it as a push button it would be perfect.



  18. hello and thanks for this awesome stuff. as i look into the USB type..this is supplimental to change it to pure primary joystick?…as not all games (example : motogp17 not supported by the board program)


  19. Hello!
    can you give me your email for a technical question about stm32 and usb hid?
    I saw that in your fw, you use very well the usb hid 🙂

    I’m not familiar with WordPress, so I don’t know how contact you in private or how you can send me your email without post it publically, so… it’s up tu you.


  20. Good day, Can you please assist as I cannot seem to get the OSH software to comunicate with the board.
    I have tried to swap the jumper wires like you said in a previous reply but still no luck.


      1. I have flashed it already but windows does not seem to pick it up as a game controller.

        The «get config from device» is grayed out and cannot be clicked.


  21. hi,

    I use the chd rotary encoder scheme but I need to stabilise the response of all encoder in order to remove the mechanical noise. I have already increased the debounce time from 10ms to 150ms but it isn’t enough.
    can I add some capacitors on chd pin a and chd pin b? 100nF for example. if yes, how I put the capacitors?

    thanks 🙂


    1. Hi!
      Which type of encoders are you using? 1/4 and 1/2 types have embedded debounce logic and usually its enough, but 1/1 have some problem. I don’t know for now how fight with it else then increase denounce time. I didn’t try capacitors, if you will have some good results with them please let me know 🙂


      1. 1/4… I have the same problem desctipted by bcclsn in one of his post:

        «3. I tested 14 encoders 1/4 and all have the problem. the only one 1/1 that I tested, works correctly.
        why this issue? tomorrow I’ll buy a new set of encoder, but I’d like to know why that encoders don’t work.

        let me clarify what I mean with «two pression at the same time».

        — optimal right encoder rotation corresponding to btt_1 pression
        — optimal left rotation corresponding to btt_2 pression.

        in my case, instead, if I turn encoder to the right, I see (on OSH Studio Button panel) btt_1 and btt_2 leads on. idem if I turn to the left. idem in Assetto Corsa… so I can’t use the encoder 😦»

        I have already increased the debounce time but isn’t enough. how I can connect the capacitors? from chd pin a/b and… gnd? I don’t know what are chd pin a/b, so I don’t know how connect the capacitors :/


      2. Sorry, I made mistake — denounce logic have full-step and half-step (1/1 & 1/2) encoders, but not quarter step (1/4)
        I’m not sure about capacitors — didn’t test them. Let’s try connect them between chd pin a/b an dGND and let’s look if it helps or not


  22. unfortunately a couple of 100nF capacitors between chd rot a/b and gnd, does not resolve the issue. I put a 2.2k resistor between the middle pin of the rotary encoder and the corresponding 1/4 pin of the stm32, debounce time set to 100ms, and the situation seems to have improved. better than that I can’t…
    do you have further advice?


      1. yes, however no more than 150ms. if I increased too much the debounce time, then the encoder became too slow, so I found a compromise 🙂


  23. Hi, Thank you so much for this documentation and software!
    I have one error. As soon as I set atleast one rotary switch pole or rotary switch wire, the button matrix stops working. And when I use 3 rotary switches(chained), 1 stops working when I set a button matrix.
    This even happens when all pins are set to unused and I use 4 pins for: Rotary switch pole, rotary switch wire, button matrix row and button matrix column.
    For clarification:
    When button matrix is not selected, the rotary switches work just fine. But when I set 1 button matrix row and column, 1 rotary switch stops working as I said.
    When no rotary switches are selected, then the button matrix works.
    What can I do to fix this?
    Here is an image of the settings:


      1. Thank you for the reply and taking a look. Trying out this board has got me curious about its options. Locking toggle switches can be made useful when using the rotary switch options.


    1. I completed my button box, only bugs I have is that the controller doesn’t always get detected. When I plug it in again, it will get detected.
      And most of the time the rotary encoders don’t work. But after a little while they do work again.
      This is my second STM board, but still the same problem.
      I used the 0,15 FW with the fix you provided.
      What can I do?

      Btw, I made a little donation.


      1. Hi Jesper, thanks for donate! 🙂
        >>controller doesn’t always get detected
        Are there any of windows errors like «USB descriptor request failed» or something or just silence? If the device doesnt get detected then it hangs somewhere during boot stage. Really strange, didnt hear about such problems yet. Did you try full chip erase just to be sure there is no any garbage in memory?
        What encoders type are you using? can you please show your whole config, I’ll check it on my side


      2. Well sometimes it works, sometimes I plug it in the same USB port and I hear the sound of an USB connecting, but the controller is not recognized by anything. The OSH studio doesn’t even recognize it then. But sometimes it does get recognized.
        The encoders are EC11, i have 4 of them connected in chain, I am just thinking now about the fact that they have PIN A and B in common, I will try to look at that first.

        My setup:
        C14 and C15 are a on/off toggle switch.
        You can also contact me via email.


      3. OK, I don’t see any problems in your config. But anyway, can you try make very simple config with just one simple button for example and test it for reproducing the issue?
        And do you have any chance to try another PC?


  24. No exact measurement, it was just evident by simple pushing a button and observing response on the screen in OSH. I have tested the simpliest config — 1 row by1 column. I had flashed twice FW 0.14 and 0.15 because i could not believe it, but it was evident. Finally I flashed back fw 0.14 and I am fine with it.


  25. Hi, today fw 015 — behaves normaly, I dont know what was wrong yesterday, sorry for troubles; I also did semi-exact measurement via 60fps camera, comparing led diode versus STM32 button highlighted in driver triggered both by one double switch; average delay is 5-7 frames in fw 014 and 6-9 in fw 015; these ~2 frames difference (33ms) IMHO isn´t noticeable by human sense.


      1. I know about it and also played with debounce&push duration to tune system, some impact is there, but almost negligible for reasonable debounce values (0-25).
        To me is a bit unclear parameter «USB pooling interval…».
        Can You in short describe what is expected impact when changing default (16ms) value?


      2. This is time between two USB packets. So if you decrease it then you can expect less latency. Default value of 16ms means 60Hz exchange rate, and if you set it to 1ms it’ll mean 1kHz rate. You can save about 15ms of lag here but for more load on your PC


  26. Hi, I am just about to try this. It looks really good and thanks for all the work on this!

    Just curious if you got the RKJXT1F42001 working? I have a couple coming soon 🙂

    Anyway thanks for the great work!


      1. you´re welcome… 🙂
        Is there any (future) possibility to implement a kind of LUT? The reason is to correct non-linear source for analog axes. Even simple “gamma” value would help; but let´s say 16 or 32 values LUT would be great


  27. I want to make a Fightstick. I don’t need an analog input. Analog 2 Buttons are not for me.
    Want to increase the switching input mode D-PAD and Vision Helmet mode Use PA0-PA3 only need to switch on the Fightstick by pressing a button


  28. Hello and happy new year to all!… I use OSH PB controller to Windows 7 and Windows 10 and works perfect.When i use it to windows 8.1 cannot install drivers and appears a message for unknown controller…What can i do for this please?



      1. Problem is MSI H97 Gaming 3 motherboard…I do a fresh install on windows 10 PRO and the same problem…Controller not recognized witn error 43…Usb Descriptor request failed….
        We don’t know what to do….


Добавить комментарий

Заполните поля или щелкните по значку, чтобы оставить свой комментарий:


Для комментария используется ваша учётная запись Выход /  Изменить )

Google+ photo

Для комментария используется ваша учётная запись Google+. Выход /  Изменить )

Фотография Twitter

Для комментария используется ваша учётная запись Twitter. Выход /  Изменить )

Фотография Facebook

Для комментария используется ваша учётная запись Facebook. Выход /  Изменить )

Connecting to %s