Using a Nano as an extension to a flight controller

The aircraft is a Combi-copter, with additional thrust prop, tilting wings, intermesh rotor scheme.

After looking at the Arducopter code system, I am going back to planning for add-on Arduino boards.
This is much simpler than modifying the Arducopter code,
and functionality and build is more modular.

Nano application: Controlling and driving feathering wings, with elevon/aileron and pitch control.
I want yaw control and low speed manoeuvring when vertical,
and possibly aileron and pitch trimming when horizontal.

I can do a servo following a sensor pot on an airflow paddle, or is a digital rotation counter a better bet?

I also need a calibration input, and a trim input.

I need two servo PWM outputs from the Nano.

This covers roughly 120 degrees of rotation, using 180 degree servos.

I can run a PWM output from the flight controller for wing pitch trim
direct from the transmitter to the flight controller, and straight to servo output.
These are Nano inputs.

A Transmitter switch can be used for another PWM output to act as a Nano input, as a mode switch to wing feathering.
This is also an input to the Nano.

The pair of wings follow the ambient airflow direction to reduce drag, and/or to create lift.

The mode change to wing feathering can also be internally generated in the Nano by examining the angle of the
airflow paddle to the chassis as well.

I can set another angle switch point relative to the chassis, from the flow paddle output,
to allow low speed mode change.
This will take a rudder and pitch PWM output from the controller as its input to the Nano.
I need to add to or subtract , and multiplex, this input, so that pitch acts like an elevator, and rudder acts like an aileron.
This goes to the two Nano servo outputs, and is combined with the flow following servo output
The elevon multiplex has to be done by the Nano.
There are different multiplexes, depending on state and wing angle.

Hover is rudder + pitch, level flight is roll-related.

Normally, copter servo PWM from the flight controller is divided between 3
servos from collective and 2 cyclic pitch channels.(pitch and roll)
I need to feed the unchanged pitch and roll signal out from the flight controller as PWM signals

Feedback is appreciated.

I need to settle on a control development plan, and reduce my variables a bit.
There will be some back-and-forth with the "other" forum.

I can clarify some points on request. There is a bit of technical Heli and Controller terminology included.-unless you are familiar with both, you will have difficulty.

If I can get some directions to items in a solutions library, that would be good.

Could you edit your post. Can you make the text understandable in (international) English. I'm confused by the . (- •, -
Can you change the title, because your question is about using a Nano as a flight controller for a helicopter.
Can you change the category ? To "Project Guidance".

Here is a black box diagram of the hookup.

Any sources for internal logic diagrams, conventions?

Do I use a decision tree, or some other format?

How do you indicate PWM-adding, multiplexing multiple inputs- as for V-tail, or Elevons?
The Pwm input can be represented as a value on as scale of 1 to 100, I suppose?
question: why does this post show in grey? - is this to do with moderation.

The next stage is to diagrammatically represent the Nano app, I think.

I am familiar with decision trees, but never used them in my work.
Do they have an application here?

I would divide the app into logic blocks and functional blocks.

  • PWM converters, current loop setup and monitor, calibration tables, storage.

Then I can go looking for existing code blocks that do the required jobs.

I saw a nice app suite that did quads, helicopters etc, and had a desktop graphical interface.
I am not likely to find something that detailed for this app.

In the meantime, I will watch a few You tube videos on learning the Arduino system.
as well as a Helicopter example.

An Arduino board can output a generic PWM signal with analogWrite(), and also a signal for a Servo motor. I like to keep those two things apart, so I call it a "servo signal".

The Arduino Nano is for slow signals. There are faster Arduino boards, such as boards with a SAMD21G processor, for example the MKR Zero. Then there is more time to do calculations. Some will say that for a helicopter, the SAMD21G is still far to slow and a processor of a few hundred MegaHertz is needed, such as the Teensy 4.0.

The Arduino world is a different world than the remote control world. Reading a signal from a ESC and converting it to a digital value in a sketch and then making a signal for a Servo motor, that is not 100% accurate. If the code is not okay, then some jitter or hiccups might occur.

There are libraries to read a Servo signal from a ESC.
This one claims to be able to read a number of PPM channels: Do you use PPM signals ?

Please give a link to the other forum.
I hope someone who knows all the terminology will reply.

I would only use it for servos, but I don't really want servo jitter.

What I want to do is not controlling the whole helicopter.

It has been done well for quadcopter drones.
That just has motors, and no servos.

There was one reply from a guy on the Ardupilot forum, who did something with helicopter thruster commands, but I suspect they have actually said their piece:
"Read the documentation"... "Practice". - seems like lots of typical c++ developers! :slight_smile:
I could try rewriting Ardupilot software, but I hesitate
to "poke the dragon" in this case. 700k lines of code is formidable.

I would rather build something similar that runs very much "unix" and has a lot of separate pieces.

There is a helicopter app referred to in the YouTube quadcopter article which looks pretty good.
You probably don't get a real detailed Gyro/GPS/Nav setup, though. You couldn't store it on the Arduino boards.

I could go Raspberry Pi if all my inputs could be made digital, but the I/O system
is not very intuitive.

Microcomputers like BeagleBone and Pi run around 1 Ghz.

Once I get the actual heli built, then I will have a potter around with the Arduinos,
and maybe get an MKR Zero. The helicopter will be 2 kg or so, so room for a fair amount of processing power.
At the moment, I am prepping my conceptual design, and looking at suitable apps and bits of apps.

I had a look at the MKR Zero and the standard zero, and I have a number of questions:

  1. Which pins can I use for PWM input and output?
    I presume the 14 analog pins can be used for pots.

  2. 256k flash memory sounds pretty low. Do any versions have more?
    It sounds like it should be able to directly address at least 516k.

48MHz, 32 bit sound OK.
3)Is there any capability difference between standard zero and mkr zero?
4) 68x53mm sounds about the same size as my Matek F765 wing.
what size is the MKR?
5) I see usb power input can be 5v, but battery input is 3.3-3.8V only

Can I use the standard BEC 5v anywhere or do I need a dedicated 3.3V supply?
I will look for a 5v to 3.3v converter.

The Helicopter kit has arrived, so I will start gearing up.

I will download the Arduino stuff from the quadcopter/helicopter controller.

The Arduino development environment and code should be easier to pick up then full C++

The actual flight controller has s-bus in with 12+ channels, and 12 pwm output channels,
so it will be handy to do at least part of the job.

specs are 216 MHz, 2MB flash.
6) How many amps should I allow for the 3.3v supply?
All the PWM lines should be 3.3V

I have been looking, and all seem to be 3.3v, 1w.
I would have thought that 15w, 5A would be a better size.
What do you think?
what is the draw for a Zero?- I will check the specs.
it says 7-12v DC in.
The flight controller has a whole sub-board producing a regulated 5v.
Where could this be connected?

I have purchased a Zero, downloaded Multiwii, and bought a mpu 6050 gyro.
Now to find out how the interfaces work.
I also need to find a supply for trimmer pots.
Any ideas? - does the Arduino shop sell this stuff?
Do I need a shield to mount stuff on? which one?
Possibly 12 inputs from the transmitter plus 5 PWM new outputs may be a bit much.
The only way I can get the channels is to run it through the Matek F-765, off Rx s-bus.
That also has an excellent 5V output.

The only non-massaged, non-gyro item is the thrust motor.

that can stay on the Matek. I don't really need arducopter for this- maybe Inav??
I will have a look.
Can I channel the inputs onto the Zero board a bit more neatly?

new question:
What format does Arduino like at the uart ports?
what does a digital port do?- is that a uart?
I can spit out other formats from the flight controller.
Where is this topic in the documentation?
I will Google it.

I'm afraid that I might write something silly when I write about the RC world. So far no one with RC knowledge has joined :cry:

In the Arduino world a PWM signal is not a Servo signal. Please keep them separated.
A generic PWM signal is with analogWrite():

The Arduino Servo library generates a servo signal. It runs in a interrupt and uses software in that interrupt to generate the servo signal on any digital pin:
Funny: 32 servos in Wokwi simulation All the signals are made in a single interrupt routine.

You need a library for PWM input. There is no official or standard library for it.

Any analog pin can be used for a potentiometer.

256k flash is a lot. You can not fill that with a sketch of a many thousands code lines.

The "MKR" series are small boards. The larger Arduino Zero has an extra usb port and a different port to upload a sketch. The Arduino M0 is between the Zero and the MKR Zero but uses its own settings. They are all very much the same.

I don't know the dimensions of the Arduino MKR Zero ! It should be somewhere :mag: :question:

If the PWM output needs to be 3.3V signals, then use a 3.3V board. I prefer with a SAMD21G processor, because that processor is used in my Arduino boards, such as the MKR Zero.
The Arduino Uno/Nano/Mega output 5V signals. Those signal are also very strong, up to 40mA shortcut current for a simple digital output pin. That is enough to damage 3.3V sensors or other 3.3V components.

I don't care how many amps you have. I suggest to add a fuse or polyfuse to prevent that a shortcut will cause a fire. Some Arduino boards have a 500mA polyfuse between the USB 5V power and the board. Since 100mA might be enough for the Zero board, a polyfuse of 500mA is a reasonable value.

It is possible to power a Arduino board with 5V. Some say it is not recommended, and some prefer it. The Arduino MKR Zero is something special. It only accepts 5V at the VIN pin.

The larger Arduino Zero board has a onboard DC/DC-converter to make 5V and then a voltage regulator for 3.3V. If you have 5V, then the safest way is to apply that 5V via a USB connector to the board (only one USB connector can accept power). I see other possibilities, that those might not be 100% safe.

The MPU-6050 is outdated and noisy and your MPU-6050 might be a counterfeit.
Arduino user @jremington has selected a good sensor and make a library for it:

I don't know where to buy RC things.

A prototype shield can be handy to connect wires to the Arduino. I solder the wires, then I attach the wires firmly to the prototype shield and then I put hotglue over it.

Some mechanical damping for the accelerometer/gyro will help a lot. They are very sensitive for vibrations and short shocks.

You can make your own format for Serial/UART communication.

Where did you read about a "digital port" ? There are "digital pins" and "digital pots" and the manufacturer sometimes refers to the internal hardware for a digital pin as "digital port function". I suggest that you ignore the term "digital port".

Arduino started with a "documentation" section and now it is very confusing. Sometimes the documentation for a board is spread over 4 or 5 page. A single page in the store with details and one more "Getting Started" page would be enough.

If you mention something, could you give a link to it ?

There's so many question in here that it's hard to keep up. Looking at the diagram, you have three PWM input to the Nano. What sort of frequency are we talking about here? The Nano is only 16 MHz, and it's got only one input capture pin so not easy to "capture" and measure high frequency signals

There must be some standard software for sending a numeric value serially.
I don't know what the transmitter is sending, or what format is used internally
in the flight controller.
The flight controller sends out a continuous pwm/servo? stream with variations.
How do I do that in a more digital manner, process it, then create an output servo or motor
It probably is not a good idea to create a servo signal as an input., then try to figure out what number it represents. Ideally, you can send 8-bit askii codes for numbers, and use reserved askii
characters as delimiters.- that was how we used to do it, anyway.- how is this done nowdays?
what is this unicode thing?- is it used in arduino?
If you want other than integers, you have to indicate what you are sending, and reconstitute the
scientific notation value based on an agreed standard.- that doesn't apply here.
Unsigned integers seems the obvious choice, and just use the askii code for the integer in a decimal fashion.
What range is natural? 0-255 ? that seems to be fine enough for controlling motors or servos.

I can have a look at the Multiwii code, I suppose, but a shortcut to examples using
an integer-stream as I have described would be useful.
If you are getting a stream like this, you have to process and pass it along very quickly,
or you need a pipe-like protocol, so that you have to read each value explicitly.
a back-and forth read-write system could be required , as you can't be expected to dispose of data as fast as it can arrive.
then, if you are going to invoke a handshake protocol, you can add headers to the data, and send all your streams down the same pipe- and have a distribution module to send the data to the correct processing instance, which has its own defined output channel-ie a mixer, or a servo output. Someone will have done this. How do I find example code?

This is similar to how things like s-bus work.- master-slave hookup??
one-to-one, anyway.
I will have a look for the Mahona AHRS module- I think that is what he is talking about?

I have switched to the Zero board.
I am gathering data on available input coms code.
Possibly a data bus implementation may be suitable.
I can possibly get a bus output going on the flight controller.

No, this is an Adafruit LSM9DS1 breakout board, with several sensors on it.
It is out of stock.
It would be neat if I could get it.

I can buy just an Adafruit accelerometer, MMA8451.
What do you think? - I suppose Adafruit have info on how to hook it up, and how to use it.

Hi @owen-bern

One issue with using an external, auxiliary microcontroller, is that the flight controller itself is a self-contained, closed loop control system. This means that the flight controller will do everything in its power to maintain the aircraft orientation commanded by the pilot.

Anything outside that closed system is simply an impediment to getting the aircraft from your current orientation or where you are now (sensor input), to your future desired orientation or where you want to be (pilot setpoint). The difference between the two is the error (setpoint - input), which drives the PID control loops that control the aircraft's motors and servos.

If you introduce another microcontroller thats managing aircraft control surfaces external to the closed loop, the flight controller will simply fight it, until either it overcomes the impediment to its motion (with the PID integral term), or loses control of the aircraft.

Hello, I have moved on from this idea.
I have another post in general topics, on loading the arduino 32 bit system on the Matek.
If there is no simple way of doing this, I will have a go at implementing s-bus on the arduino zero.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.