MHeironimus / ArduinoJoystickLibrary

An Arduino library that adds one or more joysticks to the list of HID devices an Arduino Leonardo or Arduino Micro can support.
GNU Lesser General Public License v3.0
2.06k stars 403 forks source link

16 bit support #246

Open astrolivier76 opened 1 year ago

astrolivier76 commented 1 year ago

Hi,

I made a new yoke to use with FS 2020. I would like to use the yoke with 16 bit. How to do beacause the arduino pro has only a 10 bit ADC? I read that if I use an ADS1115, the reading speed was very loo, so, is it a problem with a flight simulator or not?

lot of people map the analogread (for example A0) to 1023 to 255 for smooth. What do you think ?

thanks a lot

Olivier

MarquisedeMonsas commented 1 year ago

Hi. I am not absolutely sure what you are after, but I give this a try anyway. You want a 16bit samples with ADC? Yes you need different hardware than atmega32u4, because it only has 10bit ADC. But why? Is the 10 bit ADC not precise enough? What sample rate are you using? As the choppiness/smoothnessis is not only dictated by the ADC sample preciseness (number of bit's) but also by the number of samples taken in given time (sample rate). Also the quality of potentiometer/HAL sensor is a key factor here. Mainly the consistency of the readings. Bad potentiometers/HAL sensors may lack the accurancy and consistency needed for smooth operation.

I.E. maximum sample rate of ADS1115 is 0.86 kSPS so it can take up to 860 samples per second. This should be enough for most joystick applications also to my understanding the I2C protocol can handle the data tranfer rate needed with ease.

For mapping Arduino default analog read precision from 0-1023 to 0-255, imho there are two main reasons. 0-255 is only one byte, where 0-1023 needs two. With limited resources of Atmega MCU's this makes sense in most cases and the accuracy is good enough, especially when usin cheap potentiometers. Also the mapping kind of smooths the readings and some what eliminates the stick wandering, even thoug there are way better and in some degree more correct ways to do it, but in most user cases for DIY joystics it's good enough.

I hope this shed some light to the matter you where pondering on. Also I am in no way a expert in this subject and there are people way more knowledgeable on the subject than me, but this is how I have understood how ADC's work in general.

Here is a good tutorial on ADC basics if you are interested and need to know more. https://www.electronics-tutorials.ws/combination/analogue-to-digital-converter.html.