Joystick jitters

Hi all,
I've setup a joystick using 10K slide pots, an Arduino pro micro and utilizing the Joystick 2.0 Library, by MHeironimus.
While it all works fine in the simulator, when I calibrate it within Windows it shows lots of spurious movements. I just wondered if there's something I'm missing like some sort of smoothing circuit. The pots are connected to analogue pins, also ground and five volts on the pro micro.

Do any of you knowledgeable people have any idea what's happening?

Thanks.

Is the joystick connected to the Pc?

Read this link for tipps how to post questions: How to get the best out of this forum - Using Arduino / Installation & Troubleshooting - Arduino Forum

Make all grounds common (touch).

Without any circuit diagram, photos or code...?? Nope..

1 Like

My guess is that your wiring is picking up noise/mains hum.

Show us a photograph showing how you have connected the joystick to the Arduino.

Thanks but all ground are connected.

Yes it is.

Thanks, this is the code Below.
All grounds are connected together, and all positive are connected to the on board 5volt supply. The signal pins are connected to pins A0 - A1 - A2 on the Pro MIcro. There is nothing else connected to the Arduino.

//Arduino Joystick 2.0 Library, by MHeironimus (https://github.com/MHeironimus)
//Beginners Guide, by Daniel Cantore
//Example Code (Oct 2020), with in-depth commenting 

//Initial Definitions and Setup
//Libary Inclusion
#include <Joystick.h>

//Define and Allocate Input Pins to memorable names
//#define joyX A0
#define joyRY A0
#define joyRX A1
#define joyThrottle A2

//Initializing Axis as Integers, at a 0 default value
int rxAxis_ = 0;
int ryAxis_ = 0;
int throttle_ = 0;

//Setting up Buttons
//Updating a static variable gives greater stability than reading directly from the digital pin.
//Giving Default Values to the Buttons for later use
  int lastButton1State = 0;
  int lastButton2State = 0;
  int lastButton3State = 0;

//Defining the Joystick
//The Joystick is defined in the following setup:
//Joystick(Joystick HID ID, Joystick Type, Button Count, Hat Switch Count, Include X, Include Y, Include Z, Include Rx, Include Ry, Include Rz, Include Rudder, Include Throttle, Include Accelerator, Include Brake, Include Steering
//Joystick HID ID: A Hex value identifier for HID Device Recognition (default: 0x03). DO NOT USE 0x01 or 0x02
//Joystick type: Define the type of joystick from the types supported. Types: DEFAULT Joystick (0x04 or JOYSTICK_TYPE_JOYSTICK), Gamepad (0x05 or JOYSTICK_TYPE_GAMEPAD), Multi-Axis Controller (0x08 or JOYSTICK_TYPE_MULTI_AXIS)
//Button Count: Number of Buttons shown to HID system (default: 32)
//Hat Switch Count: Number of Hat Switches, max 2. (default:2)
//Include X Axis: Determines whether the X axis is avalible for used by the HID system, defined as a bool value (default:true)
//Include Y Axis: Determines whether the Y axis is avalible for used by the HID system, defined as a bool value (default:true)
//Include Z Axis: Determines whether the Z axis is avalible for used by the HID system, defined as a bool value (default:true)
//Include Rx Axis: Determines whether the X Rotational axis is avalible for used by the HID system, defined as a bool value (default:true)
//Include Ry Axis: Determines whether the Y Rotational axis is avalible for used by the HID system, defined as a bool value (default:true)
//Include Rz Axis: Determines whether the Z Rotational axis is avalible for used by the HID system, defined as a bool value (default:true)
//Include Rudder: Determines whether a Rudder axis is avalible for used by the HID system, defined as a bool value (default:true)
//Include Throttle: Determines whether a Throttle axis is avalible for used by the HID system, defined as a bool value (default:true)
//Include Accelerator: Determines whether an Accelerator axis is avalible for used by the HID system, defined as a bool value (default:true)
//Include Brake: Determines whether a Brake axis is avalible for used by the HID system, defined as a bool value (default:true)
//Include Steering: Determines whether a Steering axis is avalible for used by the HID system, defined as a bool value (default:true)

Joystick_ Joystick(0x12, JOYSTICK_TYPE_JOYSTICK, 0, 0,false,false,false,true,true,false,false,true,false,false,false);

//Set Auto Send State
//Enables Auto Sending, allowing the controller to send information to the HID system, rather than waiting to be asked.
const bool initAutoSendState = true;

void setup() {
  //Initialize Buttons
  //Buttons set up between Digital Pin and Ground, following pin allocations from earlier on
  //pinMode(joyButton1, INPUT_PULLUP);
  //pinMode(joyButton2, INPUT_PULLUP);
  //pinMode(joyButton3, INPUT_PULLUP);

  //Start Joystick - Needed to start the Joystick function libary
  Joystick.begin();
}

void loop() {
  
  //Axis Reading during Runtime
  //Setting Read functions for each axis and parsing correctly. The X axis will be used as an example for explanation

  //Reading the X Axis analog pin to the xAxis_ variable for processing
  rxAxis_ = analogRead(joyRX);
  //Mapping the X Axis data from a 0-1023 to 0-255 range for a smoother action
  rxAxis_ = map(rxAxis_,0,1023,0,255);
  //Set the Joystick X Axis value as the new, smoother, value
  Joystick.setRxAxis(rxAxis_);

  ryAxis_ = analogRead(joyRY);
  ryAxis_ = map(ryAxis_,0,1023,0,255);
  Joystick.setRyAxis(ryAxis_);

  throttle_ = analogRead(joyThrottle);
  throttle_ = map(throttle_,0,1023,0,255);
  Joystick.setThrottle(throttle_);
  
  //Button Reading during Runtime
  //Setting Read functions for each button, using a state value for memory. Button 1 will be used as an example for explanation

  //Reading the current Button digital pin to the Current Button State for processing
  
//Pole Delay/Debounce
//To reduce unessecary processing, the frequency of the reading loop is delayed. The value(in ms) can be changed to match requirement
delay(10);

What is the Arduino then used for if the joystick pots are connected to the Pc?
Schematics would explain...

Please elaborate. Do you mean it reports values that differ randomly but are nearly the correct value? Or are you saying the values are all over the map wild?

Have you tried just reading the analog values and directly printing those, doing nothing else?

Set that up and narrow your focus. You should be able to get reasonably consistent values, that you are not would point to a hardware issue. Look there first, use a simple sketch to help with that.

a7

Do you really want help? Heed the multiple requests for photos and/or wiring diagram.

There is no wiring diagram. It's just three pots directly attached to the promicro. I have posted the code I used and explained the way it's wired. it's designed to control the Throttle, Prop Pitch and Mixture in flight simulator, and it works fine. I'm just interested to find out why it reacts so wildly in the Widows calibration dialogue.
The grounds are connected together, as are the 5 volt lines, and the signal pins are connected to A0 - A1 - and A2.
The symptoms only occur in the Windows calibration. I have captured a few seconds of video to
Video.zip (97.7 KB)
show the effect.

Thanks everyone for your patience.

I'm asking you for one. Please follow the forum guidelines and make one. You can use pen and paper, and upload a photo. Also photos of your hardware are even easier to produce. Don't post videos that simply serve as a substitute for those. Please read:

Thanks everyone for your patience.

That will not last long unless you follow the rules.

Thank you, I'll investigate further.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.