Arduino controlled flying wing and a joystick app to control the plane

I am trying to make an Arduino controlled flying wing and a joystick app to control the plane but I can't get the app right as well as the evelvon mixing code plus the data receiving part from the app too. The app is made in MIT app inventor so if you can help please do. (Arduino Bluetooth flying wing - MIT App Inventor Help - MIT App Inventor Community) Processing: wing_.aia...
Please help me.


You are in the wrong forum!

@mayinjabob indeed you are.
Installation and troubleshooting is for Problems with the Arduino itself NOT your project. It says so in the description. Therefore I have moved your post here.

Thanks but can u help me

fw.ino (3.2 KB)
That is the ino file.

Not sure, I have no experience with App Inventor, so I am not sure how your code relates and is different from pre written code. You ask for "help" but you are not very forthcoming about what you want help with.
Please read this
how to get the best out of this forum

At the very least we need you to post the code in the proper way, in a code box. We don't even know what Arduino you are using, nor the schematic of what you are working on.
Then you need to describe what the code actually does as opposed to what you want it to do.

Mike,
I have installed bob's app and run it. The two joysticks on his screen are not responding correctly -- their movements are not correct. Moving a finger over the right joystick makes the left joystick move. Probably a some simple errors in the app blocks.

So at this stage the app has to be corrected before he should look at what occurs on the Arduino side.

The app is a good example of needing reliable fast BT comms. Interesting to see how it develops.

1 Like

OK let me try fixing the app first thanks but also could anyone help with a sample code that can turn two servos into proper elevon control for pitch and roll.

Hi @mayinjabob

Your flying-wing's elevons need to move in the same direction for pitch and in opposite directions for roll. However, you also have to take into account that your elevon servos are likely to be a mirror image of each other, (with respect to the centre line of your fuselage), which means that same signal will cause the servos to move in opposite directions.

First, you'll need to map your roll and pitch input control signals to the values you're using to control the servos, which is usually either: 0 to 180 with centre at 90 or in microseconds: 1000us to 2000us with centre at 1500us.

Taking this mirroring into account, the motor mixing for a flying-wing is relatively simple:

servo1 = mapped_pitch + mapped_roll;
servo2 = -mapped_pitch + mapped_roll;

Finally, you'll need to constrain the output to the servos so that the addition or subtraction of motor mixing doesn't exceed the servos' minimum and maximum values.

To ensure that the servos are going in the right directions just try it out on the bench (with any motor disconnected or props removed). If the servos are going in the wrong direction then reverse either the polarity of your pitch and roll control input, or the values in the motor mixer.

OK if I may ask why first add the pitch and then subtract it. And then what about when I need the craft to do a roll and not pitch only and vicevaser and rather not doing the same at once, because in may code I have some thing where I kind of check whether to take a value for either a roll or a pitch but there after I then have to give a value for the other axis so as for it to stay neutral. Also advice me on that please.

If you can't work this out, I doubt building this flying wing is a good idea!

It's basic physics!!!!

No I can bit I worries me that I may do the same things at once. I building it for its simplicity 3CHs and few electronics that is it.

Hi @mayinjabob

My apologies, I guess I could've explained that a lot better.

First subtract 1500 from mapped pitch and roll values, mix, then add 1500 using an optional servo trim offset at 50 (for 50%, or in other words stick centre):

mappedPitch = mapped_pitch - 1500;
mappedRoll = mapped_roll - 1500;
servo1 = mapped_pitch + mapped_roll;
servo2 = -mapped_pitch + mapped_roll;
servo1 = servo1 + (10 * offset) + 1000;
servo2 = servo2 + (10 * offset) + 1000;
constrain(servo1);
constrain(servo2);

For example, you start with your pitch and roll stick centred, this generates pitch and roll values of 1500. If you now move the roll stick to the left it generates a value of 1300, while pitch remains at 1500:

mapped_pitch = 1500 - 1500 = 0
mapped_roll = 1300 - 1500 = -200
servo1 = 0 + (-200) = -200
servo2 = -0 + (-200) = -200 
servo1 = -200 + (10 * 50) + 1000 = 1300
servo2 = -200 + (10 * 50) + 1000 = 1300
constrain(1300) = 1300
constrain(1300) = 1300

Since the servos are mirrored they move in the opposite direction so one elevon moves up while the other down, causing the aircraft to roll.

Taking another example, returning the roll to 1500, you now pull the stick back so that the pitch is at now at 1750:

mapped_pitch = 1750 - 1500 = 250
mapped_roll = 1500 - 1500 = 0
servo1 = (+250) + 0 = 250
servo2 = (-250) + 0 = -250 
servo1 = 250 + (10 * 50) + 1000 = 1750
servo2 = -250 + (10 * 50) + 1000 = 1250
constrain(1750) = 1750
constrain(1250) = 1250

Since the servos are mirrored they move in the opposite directions, however since one is commanded to move up and the other down, the overall effect is that both elevons move up, causing the aircraft to pitch.

Wow had to read that 2 times. OK let try that thank you.

IMG20211016145133
The app seems to work now but one of the servos keeps doing that by the way even when I give no input. And the motor "brushed"


is making the some noise as the of the brushed ones yet am using a MOSFET what is happening? Please bail me out.