DIY Arduino Slide Throttle Build Notes

Working on a instrument project or just finished a project? Show it to others!

Moderators: russ, Ralph

Post Reply
Message
Author
ericrolfe
Posts: 44
Joined: Tue Jul 28, 2020 3:13 am

DIY Arduino Slide Throttle Build Notes

#1 Post by ericrolfe »

Simmers,

I just finished a DIY slide in/out throttle project based on the Arduino Nano and a slide potentiometer.
I hope these build notes may help someone considering a similar project.
These instructions reference a CAD file for 3D printing.
Find it in attached zip file.

Comments/edits welcome.

Cheers,
Eric
Building a DIY Throttle Control.docx
(951.31 KiB) Downloaded 233 times
Throttle+Collar.zip
(6.85 KiB) Downloaded 221 times
https://www.thingiverse.com/thing:4614802
Last edited by ericrolfe on Sat Oct 10, 2020 4:39 am, edited 2 times in total.

User avatar
HughB
Posts: 64
Joined: Sun Feb 23, 2020 9:01 pm

Re: DIY Arduino Slide Throttle Build Notes

#2 Post by HughB »

Funnily enough ive just done a similar thing. Ive used an arduino pro micro instead which yopu can run as a USB HID joystick device.
Image
Attachments
IMG_2847.jpg
IMG_2847.jpg (60.76 KiB) Viewed 4160 times

ericrolfe
Posts: 44
Joined: Tue Jul 28, 2020 3:13 am

Re: DIY Arduino Slide Throttle Build Notes

#3 Post by ericrolfe »

Nice!
Care to share any details on how you built it?

User avatar
HughB
Posts: 64
Joined: Sun Feb 23, 2020 9:01 pm

Re: DIY Arduino Slide Throttle Build Notes

#4 Post by HughB »

Sure.
A friend of mine as a 13 year old who is heavily into flight sims, both rotary and fixed wing and wants to be a pilot. To help support his dreams ive built a number of items for him to go along with his sim, collective controller, helicoter pedals etc. He only flies in VR which can be a difficult in terms of operating switches and stuff but if devices are spatially arranged where they should be then they pretty much match up with the VR experience, and as such my buddy asked me if there was a way to make a throttle controller that his son can use.

For a number of years i've had a "parts bin" which consists mainly of items deemed "usefull" by me and "trash" by my wife. Occasionally when a project idea comes up i will have alook and see what i have that would fit. In this case I found an old PCB with 4 motorised potentiometers on it. They originally came from a scrap audio mixer but would be perfect for this project once i removed them and took the motors and belts off.
IMG_2848.jpg
I desoldered three pots, and then set about designing an enclosure in Fusion 360 which I 3D printed. I made a new slider top for the pots that would take a 5mm steel rod and also made some knobs and 3D printed those. I also added an extra pot to act as a trim wheel if needed.

The electronics were about as simple as it comes. I used a cheap knockoff Arduino pro micro that uses the U32 chipset (same as the Arduino Leonardo) which just happens to let you set it as a USB HID device. Then used a joystick library and some sample code and that was it. The analogue ports are only 10 bit so you only get 1024 levels but for throttles and stuff its all you need. 12bit would be better but then you move up to using somehting like the leobodnar boards and they are around £30 whereas the Arduino micro is abotu £5 https://www.amazon.co.uk/gp/product/B07 ... UTF8&psc=1
Here is the design. Its not very refined and i will probably do a better one at somepoint.
Throttle.jpg
Here is the Arduino Code

Code: Select all

// USB Joystick with hall effect sensors
// NOTE: This sketch file is for use with Arduino Leonardo and
//       Arduino Micro only.
//------------------------------------------------------------

//change these to define which pins your hall effect sensors or potentiometers are connected.
//to change button connections, scroll down to loop()
#define X_PIN A1
#define Y_PIN A2
#define R_PIN A0
#define T_PIN A3
//change these to change trim and limits. Calibrating your joystick in Windows achieves the same thing
#define X_MIN 0
#define X_MAX 1023
#define X_TRIM 0
#define X_INVERT -1
//to invert an axis, change 1 to -1
#define Y_MIN 0
#define Y_MAX 1023
#define Y_TRIM 0
#define Y_INVERT -1

#define R_MIN 0
#define R_MAX 1023
#define R_TRIM 0
#define R_INVERT 1

#define T_MIN 0
#define T_MAX 1023
#define T_TRIM 0
#define T_INVERT 1


#include <Joystick.h>

Joystick_ Joystick(0x04,JOYSTICK_TYPE_JOYSTICK,
  7, 0,                  // Button Count, Hat Switch Count
  true, true, false,     // X and Y, but no Z Axis
  false, false, false,   // No Rx, Ry, or Rz
  true, true,            // Yes rudder, yes throttle
  false, false, false);  // No accelerator, brake, or steering

void setup() {
  // Initialize Button Pins
  pinMode(2, INPUT_PULLUP);
  pinMode(3, INPUT_PULLUP);
  pinMode(4, INPUT_PULLUP);
  pinMode(5, INPUT_PULLUP);
  pinMode(6, INPUT_PULLUP);
  pinMode(7, INPUT_PULLUP);
  pinMode(8, INPUT_PULLUP);

  // Initialize Joystick Library
  Joystick.begin(false); //false = dont send automatically. We will sendState() at the end of the loop
  Joystick.setXAxisRange(-512, 512);
  Joystick.setYAxisRange(-512, 512);
  Joystick.setRudderRange(-512, 512);
  Joystick.setThrottleRange(-512, 512);
}


void loop() {
  //read buttons. Change pins and button numbers here, if you want to have different number connected to different pin
  Joystick.setButton(0, !digitalRead(3)); //pin 2 LOW means button 0 PRESSED
  Joystick.setButton(1, !digitalRead(2)); //etc.
  Joystick.setButton(2, !digitalRead(5));
  Joystick.setButton(3, !digitalRead(6));
  Joystick.setButton(4, !digitalRead(7));
  Joystick.setButton(5, !digitalRead(4));
  Joystick.setButton(6, !digitalRead(8));

  //read analog axes
  int value = map(analogRead(X_PIN) + X_TRIM , X_MIN, X_MAX, -512, 512) * X_INVERT;
  Joystick.setXAxis(value);
  value = map(analogRead(Y_PIN) + Y_TRIM , Y_MIN, Y_MAX, -512, 512) *Y_INVERT;
  Joystick.setYAxis(value);
  value = map(analogRead(R_PIN) + R_TRIM , R_MIN, R_MAX, -512, 512) * R_INVERT;
  Joystick.setRudder(value);
  value = map(analogRead(T_PIN) + T_TRIM , T_MIN, T_MAX, -512, 512) * T_INVERT;
  Joystick.setThrottle(value);
  
  Joystick.sendState();
  delay(10);
}
and lastly a link to a thingiverse page that helped me realise this was easily doable (especialy as i have 3D Printers avaiable).
https://www.thingiverse.com/thing:4576634
and Akaki's explanation video https://youtu.be/na3NeZJYK3g

The nice thing is that the Arduino comes up in the windows joystic settings as an arduino leonardo
image.png
image.png (15.08 KiB) Viewed 4134 times
Here you can see how windows sees the device (based on the code above). Im using X and Y as prop angle and mixture. teh rudder will end up as trim in the sim
image.png
Next ive just got to test it with Xplane and FS2020 but i cant see that being a problem :D

ericrolfe
Posts: 44
Joined: Tue Jul 28, 2020 3:13 am

Re: DIY Arduino Slide Throttle Build Notes

#5 Post by ericrolfe »

polarair wrote:
How could you integrate this not as a joystick but as a device in Airmanager (I really mean the code to run it directly in AM and not as JOYSTICK.

PS the Thingiverse link does not work

My original post was for a throttle device in Air Manager (LUA code is described in the build notes and reproduced below).
I could not get Thingiverse to fix the link - so edited the post to provide a zip file.

If you are referring to the Hugh8's elegant design, I think configuring it for Air Manager would be similar to the approach described in the throttle device build notes.
You would just define additional hardware devices for the prop and mixture using hw_adc_input_add and corresponding callback functions.

As a reminder, here's the code for the throttle, right from the wiki example, with one small change

Code: Select all

xpl_dataref_write("sim/operation/override/override_throttles", "INT", 1)
-- Callback function which is called when the ADC input state changes
-- 0.0 : GND (lowest voltage)
-- 1.0 : VCC (highest voltage)
function adc_input_throttle(value)
-- FSX and Prepar3D expect a value between 0 and 100
fsx_variable_write("GENERAL ENG THROTTLE LEVER POSITION:1", "Percent", value * 100)
print("new value= " .. tostring(value) )
-- X-Plane expects a value between 0 and 1, no conversion necessary
xpl_dataref_write("sim/flightmodel/engine/ENGN_thro_use", "FLOAT[8]", {value})
end
-- Create a ADC input
hw_adc_input_add("Throttle", adc_input_throttle)


User avatar
HughB
Posts: 64
Joined: Sun Feb 23, 2020 9:01 pm

Re: DIY Arduino Slide Throttle Build Notes

#6 Post by HughB »

@ericrolfe is correct. you could easily replace the Arduino micro with a supported arduino for airmanager and add the code you need in the way Eric has layed out. If i get some time i will give it a go.
Ive just tired the thingiverse link and it works for me. If you search Thingiverse for Akaki you will see its the first item returned called flight sim throttle.

Mike Horsten
Posts: 79
Joined: Tue Dec 01, 2020 8:50 am

Re: DIY Arduino Slide Throttle Build Notes

#7 Post by Mike Horsten »

I have made a similar 3d printed device setup, will share all (STL's and BOM) details when its finished. (Setup is for a full TPM + Plus choke pull on off).
I have used 128mm linear Pods giving me a bit more points.

My issue is i need to find the right data ref in X-plane, for the prop. I found the throttle and mixture "sim/flightmodel/engine/ENGN_thro" & " sim/flightmodel/engine/ENGN_mixt" but cant fint the right one for prop.

Any help is appreciated.

Mike
Building a home Cessna 172SP Steam. X-plane/MFS2020
(ex Name on Airmanager forum Polarair)

Stef26
Posts: 11
Joined: Sat Aug 22, 2020 7:01 am

Re: DIY Arduino Slide Throttle Build Notes

#8 Post by Stef26 »

@Mike Horsten

sim/flightmodel/engine/ENGN_prop ?

Mike Horsten
Posts: 79
Joined: Tue Dec 01, 2020 8:50 am

Re: DIY Arduino Slide Throttle Build Notes

#9 Post by Mike Horsten »

OK, i did not know that "Commanded Prop Speed (per engine)" would set the pitch of the prop, as that is what the real live situation does.

Thanks

Mike
Building a home Cessna 172SP Steam. X-plane/MFS2020
(ex Name on Airmanager forum Polarair)

Post Reply