Showing posts with label parts. Show all posts
Showing posts with label parts. Show all posts

Thursday, 3 September 2015

Using XBox One Controller for command input

One of my requirements was to achieve fully autonomous flight. It dawned to me that before I get there, I'll probably need to manually control the quad to perform flight tests and improve the control subsystems. Hence I need a controller, but I don't want to invest in a costly radio-controlled solution.

I already have WiFi onboard the Pi. I have an Xbox One Controller. And I already need to develop a control app to run on my computer. I'll simply interface with the Xbox One controller, which is extremely versatile.


The control mapping will surely change, but it could look like the above.
  • Throttles: control motor throttle in manual mode, control altitude in altitude stabilization mode
  • Select: switch between manual, altitude stabilized, position hold and fully automated
  • Start: start/stop onboard control
  • Right joystick: adjust yaw
  • Left joystick: adjust pitch (up / down) and roll (left / right)
  • A-button: automated lift-off and landing activation
The controller can be plugged into any Windows system with a USB cord and is instantaneously recognized. Plus there are DirectX APIs to interface with it. Since I'll be developing in C# on the Windows side, I'll be using the SharpDX.XInput library, a convenient managed wrapper around the DX native XInput APIs.

I'm using Visual Studio Community 2015. In the package manager consoler, install the latest beta version of SharpDX.XInput
Install-Package SharpDX.XInput -Pre
I'm using the beta version as the latest stable release is based on DX11 and I ended up with missing DX DLLs (Windows 10 comes with DX12).

Once you have that imported, getting a Controller object is quite simple.. In the example below, in a simple Form app, when I update the text field with the X/Y coordinates of the left joystick anytime the form button is pressed.

using SharpDX.XInput;

namespace QuadRemote
{
    public partial class Form1 : Form
    {
        public Controller _controller;

        public Form1()
        {
            InitializeComponent();
            _controller = new Controller(SharpDX.XInput.UserIndex.One);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (_controller.IsConnected)
            {
                var state = _controller.GetState();
                var x = state.Gamepad.LeftThumbX;
                var y = state.Gamepad.LeftThumbY;

                richTextBox1.Text = x.ToString() + " " + y.ToString();
            }
        }
    }
}

Thursday, 27 August 2015

BOM

I've been trying to budget the project in terms of cost and weight of the quadcopter.
I have a model in mind of a simple 24" wide X shaped design made of wood, polycarbonate and sorbothane (for vibration dampening). With that model in mind and a quick survey of what I need to propel / control the quad, I get the below.

Description Size Units Weight (g) Wratio Price (CAD) Pratio Required TWeight Tprice
Structure
Polycarbonate Sheet 432 sq-inch 1000 2.3  $        23.90 0.06 128 296 7.1
Goujon SQ 1/2 48 lin-inch 99 2.1  $          1.78 0.04 48 99 1.8
Goujon RD 1/2 48 lin-inch 44 0.9  $          0.98 0.02 32 29 0.7
Insulation tube 36 lin-inch 17 0.5  $          1.29 0.04 6 3 0.2
Sorbothane 1/4" 30 DURO 50 sq-inch 50 1.0  $        26.95 0.54 8 8 4.3
Hardware (screws, nuts, etc.) 1 bulk 100 100.0  $        50.00 50.00 1 100 50.0
Propulsion/Energy
1050Kv Brushless Motor 1 motor 57 57.0  $        35.09 35.09 4 228 140.4
Propellers 10in/4.5p 4 approx 60 15.0  $          6.00 1.50 4 60 6.0
ESC 30A 1 approx 29 29.0  $        13.00 13.00 4 116 52.0
3S 5200mAh Lipo Pack 1 approx 330 330.0  $        35.00 35.00 1 330 35.0
Control
PCA9685 1 unit 7 7.0  $        15.85 15.85 1 7 15.9
Raspberry Pi 1 unit 45 45.0  $        46.11 46.11 1 45 46.1
MPU9250 1 unit 5 5.0  $        15.61 15.61 1 5 15.6
BMP280 adafruit 1 approx 5 5.0  $          9.95 9.95 1 5 10.0
GPS 1 approx 10 10.0  $        50.00 50.00 1 10 50.0
(optional) Xbee radio

Some components I've already bought and weighted, some are just approximations based on some quick web searches. I haven't locked on some components.

Still, I'm 11% under budget for weight, and 28% under budget for cost. I've excluded the cost of tools - they can always be reused for other projects. I've taken a similar commercially available kit (ELEV-8 V2 Quadcopter Kit from Parallax) as a reference. I've converted the amounts in Canadian currency (CAD).

Metric Total Target Delta %
Weight (g) 1341 1500 -159 -11%
Price (CAD) 435 600 -165 -28%

Thursday, 13 August 2015

Ordered some parts...

While I continue to read on the topics of quadcopter flight dynamics and control, I've decided that the next logical step was to play with the I2C protocol and try to generate PWM signals to eventually drive the brushless motors of the quadcopter. I'll write up more on those topics soon. In the meantime, here are the parts I ordered to start experimenting:
  • Adafruit 16-Channel 12-bit PWM/Servo Driver I2C Interface (here)
    • This is based on the NXP PCA9685 chip. It supports the I2C protocol, so I won't be using too many GPIO pins on the Pi, and it can drive PWM signals on up to 16 channels. It's more than what I need for the 4 motors of a QuadCopter, but it could be reused to prototype something else.
    • I would have loved to just buy the NXP chip, but it's only available in surface mount packages (no DIP, or something I could have mounted in a socket). Since I don't yet have the funds to have customs PCBs made, I'll stick with the pre-assembled hobbyist board :-)
  • Adafruit Raspberry Pi Model B+ Breakout Kit  (here)
    • Going to use that to do some quick prototyping on a breadboard and get easy access to the 40 pins on the Pi.
I've had a hard time sourcing the components. Amazon.com has everything but they don't ship electronics to Canada for some reason.

I've been able to find a few Montreal local stores (they also ship across Canada). They offer free in-store pickup when you order online.
Digikey.ca is American but they also ship to Canada. They basically have EVERYTHING you would dream of, but the shipping cost is a bit higher.

In terms of tools, I'll need to buy a decent soldering iron and an oscilloscope. The scope is not absolutely necessary, but it might prove very useful when debugging the circuits.