Jump to content
WG_Magners

FreeJoy. OpenSource joystick controller on STM32

Recommended Posts

Hello!
I want to share my work on opensource joystick controller with flexible configuration. It is based on cheap BluePill board available for about 1$:
 

Скрытый текст

ST32Duino-1-324x324.jpg

 

This controller supports following features:

  • Up to 8 analog axes (12 bit resolution)
  • Up to 128 buttons
  • Incremental encoders
  • TLE5010/5011 sensors
  • Shift registers 74HC165 and CD4021
  • Axes to buttons (12 buttons per axis)
  • Buttons/encoders to axes
  • 4 POV hats
  • Push buttons, toggle switches, inverted buttons, etc.
  • PWM channels for LED lightning
  • LEDs mapping to logical buttons

 

All this options can be configured by user-friendly configurator tool:

Скрытый текст

image.thumb.png.fae6ce523bf1636a252d3caad43bda25.png

 

For flashing firmware to the device ST-LINK v2 programmer is required (or USB-UART converter). Instructions how to flash firmware and configure your device can be found on github wiki repository

Source code can be found on github:

FreeJoy
FreeJoyConfigurator

 

Links to the latest releases:
https://github.com/vostrenkov/FreeJoy/releases

https://github.com/vostrenkov/FreeJoyConfigurator/releases

I hope this will be useful for your DIY or commercial projects.  I will be glad if you guys test it and leave your feedback. Let's make this project better together :)

 

Edited by WG_Magners
  • Like 5
  • Thanks 6

Share this post


Link to post
Share on other sites

Wow, excellent work Magners! I can't wait to give this a try. 

 

Out of curiosity, do you plan to charge a license fee of some sort for commercial use? I have several upcoming projects in which your program could be very useful; some of them for my own personal use, and some that I may sell to others in the sim community. 

 

Share this post


Link to post
Share on other sites
1 час назад, vonrickenbecker сказал:

Wow, excellent work Magners! I can't wait to give this a try. 

 

Out of curiosity, do you plan to charge a license fee of some sort for commercial use? I have several upcoming projects in which your program could be very useful; some of them for my own personal use, and some that I may sell to others in the sim community. 

 

 

I released FreeJoy under GPL3.0 license, so you can use it in your commercial projects for free :)

The only thing i want is to keep the code open even in commercial use

Edited by WG_Magners
  • Like 1

Share this post


Link to post
Share on other sites

Thanks for making such a great tool available to the community! I'll definitely try it out soon. Cheers!

Share this post


Link to post
Share on other sites

Here is new release v1.3.3b2

 

Features:

  • Migration to SPL to reduce program size and improve performance
  • Splitting buttons to physical and logical
  • Widely configurable shift modification for buttons (5 shifts maximum)
  • Optimizing serial devices reading algorithms (like using DMA for SPI)
  • New axes configuration logic
  • Combined axes function
  • Buttons/encoders to axes
  • Encoders maximum number was decreased to 16 for optimization
  • Improved encoders algorithm
  • Radio buttons functionality
  • Shift registers pull up and pull down selecting

Fixes:

  • Axes to buttons errors
  • Magnet offset function added to all axes
  • Optimization of HID

Link to configurator: https://github.com/vostrenkov/FreeJoyConfigurator/releases/tag/1.3.3b2
Link to firmware: https://github.com/vostrenkov/FreeJoy/releases/tag/v1.3.3b2

Edited by WG_Magners

Share this post


Link to post
Share on other sites

Repositories for the project were moved to github organisation page created for this project. Actual links are here:

Organisation: https://github.com/FreeJoy-Team
Firmware: https://github.com/FreeJoy-Team/FreeJoy/releases
Configurator: https://github.com/FreeJoy-Team/FreeJoyConfigurator/releases

Latest release of firmware is v.1.3.3b3. Firmware for this version must be flashed by ST-Link programmer

Edited by WG_Magners
  • Like 1
  • Upvote 1

Share this post


Link to post
Share on other sites

Check releases page for hotfix v1.3.3b4.

 

Fixed non-atomic access to joystick data variables that could cause buttons bouncing at long pressing

Share this post


Link to post
Share on other sites

Hello,

Really nice project.I have some questions about adding some extra features for my need(FFB Steering Wheel) like serial communication and pressing buttons programmaticaly.What is the best way to contact you?Github Issues?Am email perhaps?I need some guidance since it's my first time programming the STM32(have dabbled around with arduino)

Thank you

Share this post


Link to post
Share on other sites
2 часа назад, celicaraptor сказал:

Hello,

Really nice project.I have some questions about adding some extra features for my need(FFB Steering Wheel) like serial communication and pressing buttons programmaticaly.What is the best way to contact you?Github Issues?Am email perhaps?I need some guidance since it's my first time programming the STM32(have dabbled around with arduino)

Thank you

 

Thanks!

We can start at personal messages here. And move somewhere else if needed.

Edited by WG_Magners

Share this post


Link to post
Share on other sites

Release v1.3.4:

 

Firmware: https://github.com/FreeJoy-Team/FreeJoy/releases

Configurator: https://github.com/FreeJoy-Team/FreeJoyConfigurator/releases

 

Changes:

  • Added dynamic HID config option. All unused buttons and axes will not be shown in system if checked
  • PID changing option
  • Added 4th (highest) level of filtration for axes
  • Encoders connection to button matrix (common pin to Button_Row)
  • Rows and Columns are swapped:
    Скрытый текст

    68747470733a2f2f632e726164696b616c2e7275

  • Pressed shifts indication in configurator GUI

PID changing is only needed if several devices with different config (pedals, throttle and stick for example) are meant to be connected to same PC. There is no need to change PID if devices with same config (two identical button-boxes for example) will be connected to same PC.

 

If you are using dynamic HID config option it is possible that button numbers will be shifted in the system (if some shift modificators, POVs or buttons to axes are defined). To prevent this you should define logical buttons that are "hidden" (POVs, shift modificators and buttons to axes) after logical buttons that should be visible in the system.

 

If you have troubles will reading/writing config to your device try to increase USB exchange period. For most of applications 5ms is the best choice.

Share this post


Link to post
Share on other sites

WG_Magners.

 

How about support for external ADC, e.g.  MCP32x, like in MMjoy2 firmware.

 

Argument about STM32 internal ADC:

 

"The nominal resolution of an ADC is not the only metric you need to look at. There is also sample rate & SNR of the ADCs. Said bluntly, the two internal ADCs are really cheap. There is so much noise, that your effective resolution will be more like 8-9 Bit.

If you have your axis in idle at an ideally steady voltage output, the digital read out of the ADC will still fluctuate quite a lot. Let's be optimistic and say you can't differentiate +-1 digits of your nominal value because of ADC noise. That means of your nominal 12 Bit resolution (4096 points), you can effectively only differentiate ~1365 absolute points. This means you have an effective resolution of only about 10,4 Bit. One solution is digitally averaging the input while sacrificing output sample rate."

Share this post


Link to post
Share on other sites
8 часов назад, Sokol1 сказал:

 

Argument about STM32 internal ADC:

 

To be honest this is not argument about STM32 MCU itself but about such boards as BluePill. They dont have any filtering components for analog supply circuits tho it is strongly recommended.

 

I can add support for external ADC but i need more requests from the community to understand it is really necessary. I have quite good feedback about using digital filtering with internal ADC channels now. And only a few people asked me about external ADC (most of them have not even try with internal ones).

 

I will try to make some tests with internal ADC soon to show how much (or not) we can get with digital filtering. For now you can take a look at my transient response tests below:

Скрытый текст

2020-02-21_12-24-40.thumb.png.d2c534b261f112f5da15dba4e1af69af.png

Скрытый текст

2020-02-21_12-33-52.thumb.png.702fd873d0fbf5536cfb24f4a700864b.png

Скрытый текст

2020-02-21_12-44-22.thumb.png.1a6bf9787c70e3006b0a18cb09c44f04.png

Скрытый текст

2020-02-21_12-48-04.thumb.png.a2cbea34244ba93a189c004708b862d6.png

 

Edited by WG_Magners
  • Upvote 1

Share this post


Link to post
Share on other sites
On 2/23/2020 at 8:29 PM, WG_Magners said:

 

Thanks!

We can start at personal messages here. And move somewhere else if needed.

Thanks for answering.I have moved my back to my studio for studies so i do not have access to my workshop.Once i get back to my parents house.I will have access to the blue pill again.On my free time i will have a look at your firmware and gather some questions.

Best regards

Share this post


Link to post
Share on other sites

Release v1.4.1

 

Configurator
Firmware

Changes:

  • Added dynamic deadband
  • Added sequential buttons (several logic buttons mapped to same physical and pressed sequentially)
  • Influence of microcontroller periphery to ADC conversion reduced (especially if TLE sensors are used)
  • Improved timings for shift registers
  • More flexible filters (7 levels of filtration)
  • Angle setting for axis offset (step 15 degrees)
  • 3 PWM pins for LED lightning
  • Up to 24 LEDs mappable to logical buttons states
  • Optimization for small wide displays
  • Device name is set to config name while saving by default
  • Indication of pins/buttons config errors

This version should improve ADC results (especially if TLE sensors are used in configuration). 
Dynamic deadband detects movements of axis and holds axis output if no movement is detected. Hold threshold is configurable.

3 PWM channels allow you to make configurable RGB lightning. Connection LEDs through transistors is recommended for lightning.

Share this post


Link to post
Share on other sites
Posted (edited)

I promised you guy some tests of analog axes with internal ADC. Here is what we have now:

Скрытый текст

This is input from potentiometer, fullscale is from -32767 to 32767. Gray is raw input, blue is filtered with 1st level filter (no way you will be able to feel it). So raw input gives us about 8 bits of effective resolution, filter of 1st level gives us 9 bits of effective resolution

 

2020-03-06_15-40-40.thumb.png.e0295a0dd2b137795541f74e21c111bb.png

 

Edited by WG_Magners

Share this post


Link to post
Share on other sites
Posted (edited)
1 час назад, [_FLAPS_]Dirt_Merchant сказал:

@WG_Magners How can we support this work?

You can star repos at github.

I didnt think about donates.. If i will decide to make a patreon page i will integrate link to configurator

Edited by WG_Magners

Share this post


Link to post
Share on other sites
11 minutes ago, WG_Magners said:

You can star repos at github.

I didnt think about donates.. If i will decide to make a patrion page i will integrate link to configurator

 

Please do a patreon!

Share this post


Link to post
Share on other sites
24 минуты назад, [_FLAPS_]Dirt_Merchant сказал:

 

Please do a patreon!

The best stimulus for me to keep going on is your feedback guys. I really need to know this project is needed and which problems you face this it

Share this post


Link to post
Share on other sites

Well - my feedback is this: WEEEE this is sorely needed, the HOTAS DIY community needs you so badly for this. I am especially interested in the external ADC support that has been mentioned elsewhere;)

 

The community of DIYers is tiny and we very much appreciate the work you're doing!

 

As my own projects come towards maturity I'll be sure to keep you posted on functionality:)

Share this post


Link to post
Share on other sites

External ADC support is expected in next release. 

Its a pity but english-speaking community isn't very active. You can find a lot of information and tests in russian forum: FreeJoy russian thread. You can get most of information with google translator, but if something is unclear you can ask me here

  • Upvote 2

Share this post


Link to post
Share on other sites
Posted (edited)
16 hours ago, WG_Magners said:

Its a pity but english-speaking community isn't very active. 

 

Yes, I post about your work in 4 forums (DCS, SimHQ, ATAG, Gavca) and Reddit, few comments. :( 

 

I am not a Discord user, but this (confuse) platform have DIY treads, may there is a good place for post.

Edited by Sokol1

Share this post


Link to post
Share on other sites
51 минуту назад, Sokol1 сказал:

 

Yes, I post about your work in 4 forums (DCS, SimHQ, ATAG, Gavca) and Reddit, few comments. :( 

Thank you for sharing!

Share this post


Link to post
Share on other sites
Posted (edited)
On 3/6/2020 at 11:21 PM, WG_Magners said:

External ADC support is expected in next release. 

Its a pity but english-speaking community isn't very active. You can find a lot of information and tests in russian forum: FreeJoy russian thread. You can get most of information with google translator, but if something is unclear you can ask me here

 

Hi WG_Magners!

many thanks for sharing your effort!

If it counts, I also vote for external ADC support, and if possible multiple ADCs, meaning not only  MCP3204  but also 4xMCP3201 for example.

The reason is to keep wires with analog signal as short as possible, important especially in case, when analog sources are not close each other.


I have build my button box with 6 analog axes based on bluepill in the past, namely this project:

https://opensimhardware.wordpress.com/pedal-button-controller/


It is working, but I was really suprised how noisy is the internal ADC. At least "middle" filtering is necessairy. I have also played with LC filtering, but the improvement was only partial. It is noisy even with resistor divider soldered directly between 3,3 and GND pins. 😞

To be honest, I have not experimented with any external low noise voltage reference, like REF3033 or something similar. Did You try any?
So again, I vote for external ADCs support.👍

Thanks in advance

 

 

Edited by wju

Share this post


Link to post
Share on other sites
Posted (edited)
10 часов назад, wju сказал:

 

Hi WG_Magners!

many thanks for sharing your effort!

If it counts, I also vote for external ADC support, and if possible multiple ADCs, meaning not only  MCP3204  but also 4xMCP3201 for example.

The reason is to keep wires with analog signal as short as possible, important especially in case, when analog sources are not close each other.


I have build my button box with 6 analog axes based on bluepill in the past, namely this project:

https://opensimhardware.wordpress.com/pedal-button-controller/


It is working, but I was really suprised how noisy is the internal ADC. At least "middle" filtering is necessairy. I have also played with LC filtering, but the improvement was only partial. It is noisy even with resistor divider soldered directly between 3,3 and GND pins. 😞

To be honest, I have not experimented with any external low noise voltage reference, like REF3033 or something similar. Did You try any?
So again, I vote for external ADCs support.👍

Thanks in advance

 

 

 

You will be glad to know i am working at support of whole MCP320x family and MLX90393 sensor now.

Have you tried the last version (v1.4.1b5) of FreeJoy? You will be surprised with internal ADC performance, i managed to achieve about 10 bits of effective resolution (11 bits with very fast filter):

Скрытый текст

Red is raw input, blue is 1st level (of 7 levels) of filter. Fullscale is from -32767 to 32767 (16 bits)

2020-03-07_21-04-02.thumb.png.487f8bd4c57f25364ed247a399b32deb.png

 

Edited by WG_Magners
  • Thanks 1

Share this post


Link to post
Share on other sites

working on external ADC support?  good news! 🙂

yep, the MLX90393 is the real beast!


May I kindly ask You about multiple ADCs support?

Is it in your pipeline? Is it even possible to have separate ADCs? The reason, why I am asking is in my previous post, hope it is obvious.

 

My Russian knowledge is very limited so cannot read whole ru thread version, my bad..

well,  I am playing with your last fw just now - so far i am impressed!  🙂

I have noticed your project this morning, and as I have some spare bluepills in my drawer, I flashed firmware and this is my first test:

simple stupid one single pot between 3.3V and gnd - see the picture.

Really not bad for zero filter!

Looking forward for external ADCs support!

😉

BP__first_test.thumb.jpg.b3146401e4487807bae17fbc6aac4141.jpg

 

  • Like 1

Share this post


Link to post
Share on other sites
Posted (edited)
21 час назад, wju сказал:

multiple ADCs support

Yes, of course it will be implemented. It will be possible to combine internal and external ADCs, TLE5011, MLX90393 sensors and even "buttons-to-axis" function if needed

Edited by WG_Magners
  • Like 1
  • Upvote 2

Share this post


Link to post
Share on other sites
1 hour ago, WG_Magners said:

Yes, of course it will be implemented. It will be possible to combine internal and external ADCs, TLE501, MLX90393 sensors and even "buttons-to-axis" function if needed

 

Great!  I am looking forward. 🙂

Share this post


Link to post
Share on other sites
On 12/3/2020 at 10:55, wju said:

 

Ciao WG_Magners!

molte grazie per aver condiviso i tuoi sforzi!

Se conta, voto anche per il supporto ADC esterno e, se possibile, più ADC, il che significa non solo MCP3204 ma anche 4xMCP3201 per esempio.

Il motivo è mantenere i cavi con segnale analogico il più corti possibile, importante soprattutto nel caso in cui le fonti analogiche non si avvicinino.


Ho costruito la mia scatola di pulsanti con 6 assi analogici basati su bluepill in passato, in particolare questo progetto:

https://opensimhardware.wordpress.com/pedal-button-controller/


Funziona, ma sono rimasto davvero sorpreso dal rumore dell'ADC interno. È necessario almeno un filtro "intermedio". Ho anche giocato con il filtro LC, ma il miglioramento è stato solo parziale. È rumoroso anche con il divisore della resistenza saldato direttamente tra i piedini 3,3 e GND. 😞

Ad essere sincero, non ho sperimentato alcun riferimento di tensione a basso rumore esterno, come REF3033 o qualcosa di simile. Ne hai provato qualcuno?
Di nuovo, voto per il supporto di ADC esterni. 👍

Grazie in anticipo

 

 

The problem of the internal ADC is also attributable to the circuit and the pcb of the bluepill board.
If done more carefully there should be far fewer noise problems.
The same thing happened with arduino but when I made a decent pcb and an anti noise circuitry on the adc power supply and also an external vref the noise disappeared.
If I make a decent pcb I will do these tests to verify adc.
Great job however.

Last night after a hard test of the arm compiler configuration I managed to compile the firmware source. ;-)

 

 

 

Share this post


Link to post
Share on other sites

I have checked the management of the encoders in the encoder.c file and if I have not misunderstood it is a software polling reading and not a detection of the movements with the hardware present in the stm32f103.

 

Is there no possibility of losing data if using high resolution encoders (1000 steps or more)?

 

It would not be bad to use the hardware present for this type of reading as it is possible to use interrupts that only occur when the reg counter overflows, I think it can be set even if I don't remember well but in my project I used it and it worked very well and does not commit not at all the mcu.

Share this post


Link to post
Share on other sites
Posted (edited)
01.04.2020 в 19:10, Tistructor сказал:

I have checked the management of the encoders in the encoder.c file and if I have not misunderstood it is a software polling reading and not a detection of the movements with the hardware present in the stm32f103.

 

Is there no possibility of losing data if using high resolution encoders (1000 steps or more)?

 

It would not be bad to use the hardware present for this type of reading as it is possible to use interrupts that only occur when the reg counter overflows, I think it can be set even if I don't remember well but in my project I used it and it worked very well and does not commit not at all the mcu.

 

The reason is flexibility of the application - there are a lot of people who want to connect encoders to shift registers or button matrix. These encoders are read by 1kHz polling, so high resolution encoders may have problems here.

I had some thoughts about adding another type of encoder that use hardware features of controller or very fast polling with interrupts. Maybe later.

 

01.04.2020 в 18:55, Tistructor сказал:

The problem of the internal ADC is also attributable to the circuit and the pcb of the bluepill board.

I can proudly say that since last version of firmware there are no problems with internal ADC performance. Even with poor bluepill pcb layout. 

You can see my tests several posts before.

Adding proper filter circuits for analog supply surely will make it better but for most applications is it "overkill".

Edited by WG_Magners

Share this post


Link to post
Share on other sites

True I did the test with a multiturn potentiometer that I connected and the noise is contained.

Share this post


Link to post
Share on other sites
Posted (edited)
On 4/2/2020 at 10:09 PM, WG_Magners said:

 

I can proudly say that since last version of firmware there are no problems with internal ADC performance. Even with poor bluepill pcb layout.

 

this is true, your SW implementation is very good;   but still, external ADC will be improvement; I hope, we will have it.. 😉

 

I can also add my own measurement:

simple switch on from zero to cca half of the max

overview:

BP_AXIST_TEST.thumb.jpg.4513e002adb4bc92ab8cd284f4f61a0f.jpg

 

zoom at the beginning, one can see that blue pill refreshes value every 2ms: ( with 1ms USB exchange period  )

BP_AXIST_TEST_zoom.thumb.jpg.00bbcc34417bb34057c47a5eb8222c25.jpg

 

zoom at the end

 

BP_AXIST_TEST_zoom_far_end.thumb.jpg.5da6eed71e73a79d94e72eba038da1b9.jpg

 

nice thing is, that all eight channels are within three LSB (12bit resolution, i.e. within 32 on 16bit scale);

unfiltered channel alters 3 bits, filter no1  2-3bits, last three (strongest) filters do not.

Configuration was as simple as possible, wires directly on the board, very short.

 

I have also played with TLE5011 which works flawlessly. Good job!

🙂

 

Edited by wju
  • Like 1

Share this post


Link to post
Share on other sites
2 часа назад, wju сказал:

I hope, we will have it.. 😉

Software for external ADCs is almost done (/dev branch on github). Now i'm waiting for shipping of the hardware to check it.

  • Like 2

Share this post


Link to post
Share on other sites

So, following this with great interest.

 

Is the bluepill board the only board to be supported, or did you plan to add arduino pro micro, teensy, leo bodnar or other of the common boards used in joystick building? 

 

Also, pls join (if you are not allready) the HOTAS discord. The DIY section is an active community with lots of peeps building their controllers. 

Share this post


Link to post
Share on other sites
Posted (edited)
2 часа назад, -FISTN-Ugly_Eric сказал:

Is the bluepill board the only board to be supported, or did you plan to add arduino pro micro, teensy, leo bodnar or other of the common boards used in joystick building? 

 

Target MCU for this project is STM32. It would be quite hard to add cross-platforming (even impossible with arduino boards). So i'm not working on it and there are no plans to add other MCU support. 

However i'm going to trace my own PCB (compatible with most common periphery for joystick building) in the future.

2 часа назад, -FISTN-Ugly_Eric сказал:

Also, pls join (if you are not allready) the HOTAS discord. The DIY section is an active community with lots of peeps building their controllers.

Joined. I didn't know about this channel, thanks

Edited by WG_Magners

Share this post


Link to post
Share on other sites
1 hour ago, WG_Magners said:

Joined. I didn't know about this channel, thanks

If you talk with ddrake, i suppose you might get yer own subchannel with project like this

Share this post


Link to post
Share on other sites

Very impressive, will definately use it in a future project! Thanks a lot for sharing!

Share this post


Link to post
Share on other sites
On 4/3/2020 at 6:06 PM, WG_Magners said:

Software for external ADCs is almost done (/dev branch on github). Now i'm waiting for shipping of the hardware to check it.

Excellent news! I have ordered an MLX90393 in anticipation :) 

Share this post


Link to post
Share on other sites
On 4/6/2020 at 5:53 AM, -FISTN-Ugly_Eric said:

Also, pls join (if you are not allready) the HOTAS discord. The DIY section is an active community with lots of peeps building their controllers. 

 

could you pls post the link? 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...