Example Code

Quadcopter Simulations

Code and Documents

Attachment

Two examples are included here, Single Axis Quadcopter.vi and Untethered Quadcopter.vi. These are quadcopter simulators that were developed as part of a LabVIEW quadcopter project by the AE department here at National Instruments.

They both include PID controllers that control a computer model of the quadcopter. The model currently simulates the thrust of the motors, the effects of gravity and the inertial effect of our quadcopter and you can add in some random disturbances with the turbulance button. Air resistance could be included as a future improvement.

To use Single Axis Quadcopter:

1. Open the VI and run it.

2. You can move the setpoint and the quadcopter will adjust to the angle you set.

3. To view the response to a step input on the "response" graph indicator, wait for the recording light to turn off, then click a new setpoint, being careful not to drag the needle.

4. Wait 4 seconds while the graph records the response, it will then plot it on the graph and update the values of Response Time and % Overshoot.

Capture.PNG

Using these values you can gradually try and tweak your PID gains until you have a response you're happy with. Now to get it off the ground!

To Use Untethered Quadcopter:

1. Open the VI and run it.

2. The quadcopter will drift as it stabilises itself, use the setpoint to move it back into the centre of the screen.

3. Make small adjustments to keep it within view! The controls are mapped to Home, End, Delete and Page Down so it might be easier to use these.

4. Try turning the control off to see the effect it has.

Some code from the flight simulator example was used to make the quadcopter 3D model so these VIs are also included.

Here's a video of the finished Quadcopter: http://www.youtube.com/watch?v=7PEb8Ipmv20

Joel G
Applications Engineer
National Instruments UK & Ireland

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
gaurav_sharma
Member
Member
on

It's great help.

I have some question if you can spare some time and answer:

1. Can we implement it for 2 -axis quad in this simulation.

2. I have made the program using complemenatry filter for quad and have filter outpus in labview. Can I simulate it in code. Any drawbacks ?

-Thanks to team behind this.

em_engineering
Member
Member
on

i tried running the programme but it asked to find VI nameed "NI_PID-pid.lvlib:PID structure Conversion (DBL).vi"

can anyone help me rectify that

Adam_Kis
Member
Member
on

Install  PID and Fuzzy Logic Toolkit from the websit and it will work

MSakr
Member
Member
on

I tried running Untethered Quadcopter.vi, but the quadcopter is flying away from the view and I tried some adjustment for the PID parameters and the same result, what should I do?

zuzu12
Member
Member
on

can we connect a real quadcopter to the program and control it using these VI's?

Contributors