Hello, for my final project for highschool, I decided to make a hexacopter with the goal in mind of the final product being cheap and effective. The final product was indeed very cheap (340$ for something with the capabilities of about this. The drone flies, but it doesn't fly well, and I'd like some pointers as to why that may be. I've tried to document my code as well as I possibly can, if you guys have any questions I'll be happy to answer.
Picture of the drone on display at my school's fair:
Basic explanation:
The current method takes the values of the right stick (presented as X,Y coordinates between -1 and 1) and convert them to polar coordinates (R,theta). the Theta value is I want to get, as the theta is normal to the axis of rotation. I use theta to find the axis of rotation, and I use that as a variable in a sine function with the motors that looks somewhat like adjustment = sin(theta - the_rotation_value_of_virtual motor);
This graph represents how much the motor's power changes as the drone rotates (the motor moves in a circle around the center of the drone) starting from being on the axis itself. You can see that on the axis, the motor's powers is not altered, gut increases until is is PI/2 (perpindicular) from the axis of rotation. The change in power then decreases ( but is still positive) until the motor hits the other side and is once again on the axis. This process happens again, but below zero as you continue until once again it is colinear with the axis.
right now, I'm having troubles with controll. Too much motor adjustment and the drone loves to flip over, too little and it becomes hard to take off, and near impossible. thoughts?
I don't know why nobody has responded to your question, it seems like you have described the problem well enough.
It might help to show a picture of your actual device, rather than a link to someone else's. If you use the forum's attach function, go back and edit your post to link the image inline in the post.
Why is the motor rotating around the center? Usually hexacopters have fixed motor arms.
Do you know how long your main loop takes to execute a full cycle of measurements, calculations and outputs? Often when a control loop is running poorly, you have inefficient calculations taking too much time to adequately respond to controls. Using trig functions is a big one. I recently finished a project using a Teensy that spends 80% of its time calculating a sine function and I had to be very careful how long each calculation took.
I would not have recommended a Due as a flight controller. Even with 6 motors, the weight of that board is a significant fraction of your payload.
Why is the motor rotating around the center? Usually hexacopters have fixed motor arms.
I was thinking the same and agree a picture would be valuable in understanding the contraption
As for the Due, I suspect some of the issues are because the Due does not support hardware floating point math ... this makes a significant hiccup in the numerous sin() functions.
MorganS:
I don't know why nobody has responded to your question, it seems like you have described the problem well enough.
It might help to show a picture of your actual device, rather than a link to someone else's. If you use the forum's attach function, go back and edit your post to link the image inline in the post.
Why is the motor rotating around the center? Usually hexacopters have fixed motor arms.
Do you know how long your main loop takes to execute a full cycle of measurements, calculations and outputs? Often when a control loop is running poorly, you have inefficient calculations taking too much time to adequately respond to controls. Using trig functions is a big one. I recently finished a project using a Teensy that spends 80% of its time calculating a sine function and I had to be very careful how long each calculation took.
I would not have recommended a Due as a flight controller. Even with 6 motors, the weight of that board is a significant fraction of your payload.
I added a picture
The 'rotating motor' is a representaation of the whole drone turning. eg: "as the motor turns 90 degrees around the center..." becomes "as the drone turns 90 degrees, this motor...."
The entire loop is executed (with all interrupts on) at about 1KHz, which should be suffecient, right?
The weight is not an issue, the drone itself is rather large!
I am also surprised that you are achieving a repetition frequency of 1KHz... but I do not own a Due.
Ray
Yes... I just learned of PID. I was using a linear control system.. this may be an issue that I'll have to solve!
weight distribution is huge, with 2 batteries, it's important to keep them centered as well as possible.
well, if you think about it, 81MHz (due freq) to 1Khz is a scale factor of about 81,000 processor level instructions, which doesn't sound too far off.