Thread Tools
Sep 19, 2014, 08:40 PM
Registered User
MassiveOverkill's Avatar
Thread OP
Mini-HowTo

Cleanflight firmware for STM32F3 based FCBs, Check First Post Please!!


UPDATE 6/7/2016

Firmware 1.13.0 officially released:

https://github.com/cleanflight/clean...es/tag/v1.13.0

UPDATE 5/31/2016

CF Configurator updated to 1.2.2

What's the difference between Baseflight and CleanFlight? Grab a seat and listen to why it's the future:
Hydra (Dominic Clifton) Talks about Cleanflight (reloaded) (45 min 46 sec)


MutliWii thread: http://www.multiwii.com/forum/viewtopic.php?f=23&t=5149

This fork differs from baseflight in that it attempts to use modern software development practices which result in:

greater reliability through code robustness and automated testing.
easier maintenance through code cleanliness.
easier to develop new features.
easier to re-use code though code de-coupling and modularisation.
The MultiWii software, from which baseflight originated, violates many good software development best-practices. Hopefully this fork will go some way to address them. If you see any bad code in this fork please immediately raise an issue so it can be fixed, or better yet submit a pull request.

Cleanflight also has additional features not found in baseflight.

Multi-color RGB LED Strip support (each LED can be a different color using variable length WS2811 Addressable RGB strips - use for Orientation Indicators, Low Battery Warning, Flight Mode Status, etc)
Oneshot ESC support.
Blackbox flight recorder logging (to onboard flash or external SD card).
Support for additional targets that use the STM32F3 processors (baseflight only supports STM32F1).
Support for the TauLabs Sparky board (~$35 STM32F303 I2C sensors, based board with acc/gyro/compass and baro!)
Support for the OpenPilot CC3D board. (~$20 STM32F103 board, SPI acc/gyro)
Support for the CJMCU nano quadcopter board.
Support for developer breakout boards: (Port103R, EUSTM32F103RC, Olimexino, STM32F3Discovery).
Support for more than 8 RC channels - (e.g. 16 Channels via FrSky X4RSB SBus).
Support for N-Position switches via flexible channel ranges - not just 3 like baseflight or 3/6 in MultiWii
Lux's new PID (uses float values internally, resistant to looptime variation).
Simultaneous Bluetooth configuration and OSD.
Better PWM and PPM input and failsafe detection than baseflight.
Better FrSky Telemetry than baseflight.
MSP Telemetry.
RSSI via ADC - Uses ADC to read PWM RSSI signals, tested with FrSky D4R-II and X8R.
Autotune - ported from BradWii, experimental - feedback welcomed.
OLED Displays - Display information on: Battery voltage, profile, rate profile, version, sensors, RC, etc.
In-flight manual PID tuning and rate adjustment.
Rate profiles and in-flight selection of them.
Graupner PPM failsafe.
Graupner HoTT telemetry.
Multiple simultaneous telemetry providers.
Configurable serial ports for Serial RX, Telemetry, MSP, GPS - Use most devices on any port, softserial too.
more many minor bug fixes.

For a list of features, changes and some discussion please review the thread on MultiWii forums and consult the documentation.

http://www.multiwii.com/forum/viewtopic.php?f=23&t=5149

There's code, binaries and unit tests here:

https://github.com/cleanflight/cleanflight

Additional documentation here:

https://github.com/cleanflight/clean...ee/master/docs

Videos here:

https://www.youtube.com/playlist?lis...MH2DrllZAGWkt8

To configure it you should use the fork of *******-configurator, that can be found on the chrome web store, here:

Configurator source here:

https://github.com/hydra/cleanflight-configurator

There's a dedicated IRC channel here:

irc://irc.freenode.net/#cleanflight

You can find the creator, 'Hydra' there.

Pull-requests welcomed!

Targets:
Open Pilot CC3D - http://www.openpilot.org/products/op...trol-platform/
CJMCU - https://github.com/hydra/cleanflight/issues/22
*****32 - Link removed
Olimexino - https://www.olimex.com/Products/Duin...IMEXINO-STM32/
*****32Pro - Link removed
STM32F3Discovery - http://www.st.com/web/catalog/tools/...S1532/PF254044
STM32F3Discovery with Chebuzz F3 Taulabs shield.

List of vendors selling boards pre-loaded with Cleanflight:

MassiveRC: http://www.massiverc.com/PrestaShop/...control-boards
Aerobotik: http://store.aerobotik.com/43-flight-controller
UBAD: http://ubuyadrone.com/flight-control...ja32-acro.html
ImmersionRC: http://www.immersionrc.com/fpv-produ...x-racing-quad/
OverSky: http://www.overskyrc.com/mx-nano-ove...erx-p-616.html
Armattan Quads http://www.armattanquads.com/electronics/
GetFPV: http://www.getfpv.com/flight-controllers.html

Any vendor carrying the SPRacingF3:

Seriously Pro http://seriouslypro.com/
MassiveRC http://www.massiverc.com/PrestaShop/...control-boards
GetFPV http://www.getfpv.com/flight-controllers.html
TBS http://team-blacksheep.com/products/prod:f3_acro

Thanks to Dominic and all the contributors of CleanFlight.

Get your Cleanflight stickers:

Get stickers: https://www.rcgroups.com/forums/show...postcount=6931
Last edited by MassiveOverkill; Jun 07, 2016 at 09:28 AM.
Sign up now
to remove ads between posts
Sep 19, 2014, 08:40 PM
Registered User
MassiveOverkill's Avatar
Thread OP

Getting started


You've probably seen Mocha Boy's video, which is really great but some things you'll want to make note of in documentation:

The Cleanflight crew has been adding a lot of new features lately so if I'm upgrading firmware on a board that I've already configured, I'll take screenshots of my configuration pages for backup. You should do this after you've successfully flashed\configured your board and not try to do the next time you want to update\reconfigure.

If you already have Cleanflight Configurator installed and it hasn't auto-updated (and there's no reason for you to stay on the existing version). you may have to delete the Chrome app and redownload it to get the latest version.

When getting started, you need to download the drivers first. There's a link to them right in the Cleanflight program but here's the link:

http://www.silabs.com/products/mcu/p...cpdrivers.aspx

You may have to reboot your PC once the drivers are loaded. You'll know if your successful if you see a new port available in the upper left hand corner:



You don't need a separate program to flash CleanFlight. All you need is the Chrome App, which also allows you to do CLI (Many options are now available in the GUI)

PLEASE NOTE: Cleanflight will most likely have changed since doing this pictorial. If the version you have looks different, don't panic. It's very easy to use and the general directions still apply

It's recommended you flash the latest stable firmware. After you've loaded the drivers and see a COM port available it's important that YOU DO NOT CLICK CONNECT (Uncheck autoconnect if it's checked), click on Firmware Flasher:



This is something new, once in the Firmware Flasher screen, use the dropdown box to select the board you're flashing:



Click on Load Firmware Online:



You'll see the latest firmware downloaded as well as release notes:



On a new board, I'll select the Full Chip Erase and Flash Slowly checkboxes. If for some reason you have problems flashing you should select the 'No Reboot Option'. You may have to go one step further and short the bootloader pins on the board in conjunction with the 'No Reboot Option':



Now click 'Flash Firmware':



You'll see the progress bar showing update in process:



And programming succesful:



If you have to fall back to bootloader, Geekazoid was nice enough to do a how-to video:

Naze32 Cleanflight "unbrick" (2 min 42 sec)


CLI may be intimidating at first, especially if you don't know all the commands, but you can get a list of them by simply typing 'DUMP' (which also shows your current settings), which is also attached for reference. Typing 'Help' is also useful. I've only been using CleanFlight for maybe 2 weeks and have come up to speed with it very quickly............once you use it you probably won't go back to anything else. Here's what the CLI tab looks like



Once in CleanFlight, the first thing I recommend you do is backup your settings to text file. I've attached a default one. You also need to back up your CLI settings, which you can do by going to the CLI tab and typing GET. Copy and paste (text only) into Notepad. I've also attached a default GET.txt file backup.

By backing up these files you can upload them so others can help troubleshoot if you have a problem.
Last edited by MassiveOverkill; Feb 27, 2015 at 07:35 PM.
Sep 19, 2014, 08:41 PM
Registered User
MassiveOverkill's Avatar
Thread OP
If you're migrating over to Cleanflight make sure you note the CLI command differences:

NOTE: A lot of the commands below have been ported over to the new GUI interface. You should be able to configure most options except for Looptime from the GUI.

So here are some common CLI commands that I've used on my own setup:

Because I'm using a PPM LemonRX Receiver I had to enable PPM. You can check what features you have enabled by simply typing 'FEATURE' and pressing 'Enter'

FEATURE RX_PPM

Because I'm using PPM, this frees up the other RX input channels for installing other serial devices such as GPS:

FEATURE SOFTSERIAL

1st serial port is reserved for my RX so we go to serial port 2 and set it for scenario 2, which is GPS only. You can find more about the serial configuration here: https://github.com/cleanflight/clean...docs/Serial.md and https://github.com/hydra/cleanflight...0-%20Naze32.md

If you would like to operate the GPS from RC3/RC4 then you must enable the serial port to output in scenario 2 by using the command:

SET SERIAL_PORT_2_SCENARIO=2

Failsafe can be set on the board as well as on your receiver. If you want to enable failsafe features you really should enable them on both your FCB as well as your RX. If you're RX fails or loses connection to the board the board's failsafe will kick in.

FEATURE FAILSAFE

I want my motors to stop when throttle is zero\motors disarmed

FEATURE MOTOR_STOP

You can use a switch to arm/disarm your motors, but I'm used to the stick commands so I disable this. If you can't get your motors to arm you may have the default set (where the value below is 0 and not 1) and don't have Arm\Disarm set to a switch in the AUX page.

SET DISARM_KILL_SWITCH = 1

Default channel mapping is AETR1234 so I change mapping to match my transmitter's defaults:

MAP TAER1234

My Devo 7e' smidpoints are 1510 so I adjust that so I don't have to fuddle with my TX as much:

SET MID_RC=1510

Now, it's hard to get to the USB port on the board on an H quad since the USB port is on the rear, so you can rotate the board left or right for easy access and use the following commands to tell the board you've turned it:

SET ALIGN_BOARD_YAW=90 (ARROW POINTING RIGHT) or
SET ALIGN_BOARD_YAW=270 (ARROW POINTING LEFT)

I want my multi to be able to tilt past the stock setting of 50 degrees in angle mode, so I increased it to 75 degrees:

SET MAX_INCLINATION_ANGLE=750

I'm now using canted motor mounts which provide 12 degrees of offset:

SET ALIGN_BOARD_PITCH=12

I normally don't use GPS on my FPV 250 racing quad but I will eventually dual-purpose it so I have GPS enabled:

FEATURE GPS

Default provider is NMEA, which is text data but UBX uses binary, which is more efficient.

SET GPS_PROVIDER=0 (FOR NMEA) or
SET GPS_PROVIDER=1 (FOR UBX) (MassiveRC's GPS units are preconfigured for UBX)

MassiveRC's GPS units are preconfigured for 115200 (as well as 5 Hz update rate):

SET GPS_BAUDRATE=0 (115200) (in that other program you use an index and '0' = 115200. In Cleanflight you actually put your baud rate, so if yours is set to '9600', that's what you put in)

So it should be :

SET GPS_BAUDRATE=115200

Go USA!!!! (can make GPS lock faster)

SET GPS_SBAS_MODE=2 (WAS FOR NORTH AMERICA)

This is just a few common examples you may need to configure. You can MUST type 'SAVE' or clicking on another tab in CF configurator will automatically save settings a close.. The reason for this change is that it was requested that settings not automatically save in case you screwed up something and wanted to revert back to the unsaved settings

Since my Devo 7e only has 2 2-way switches (1st is set to Angle\Horizon and 2nd is set to Position Hold), I've created a config that maps throttle up\down trims to Aux 3 and 4. I use them for Auto Tune and Buzzer and both are set as momentary switches. My config is attached for Massive32 board

Post detailing the new AUX setup page: https://www.rcgroups.com/forums/show...&postcount=237

Looptime: There is some discrepancy about setting this down to 2500 or leaving it at default. If you're going to lower it to improve performance, keep in mind that if you have other softserial features enabled, they take up cycles so you should bump up your looptime up accordingly, if you've lowered it.

Some more tidbits from Zenman,

Quote:
Originally Posted by zenman
This always seems to confuse me as well. I'll use the numbers I have to try to explain what works for me.

MINCOMMAND 1000 - lowest signal the fc sees or outputs. Should be your lowest number in your set up. It is at your lowest throttle position. It should be what is being outputted at your lowest throttle position so your low endpoint must match this. Note : When not armed the FC will output MINCOMMAND 1000 unless over MAXCHECK I believe. The mincomand setting can also be used to calibrate escs through Baseflight Configurator.

MINTHROTTLE 1100 - Motor idle speed. Set to at least the lowest motor speed that will reliably turn on all motors. Seems every motor is a little unique and some might not start or have trouble starting at lower speeds. Can also be set higher if you want a higher idle speed. If this number is set lower than the motors can reliably spin, it can cause the motors to stop spinning when hard yawing or during quick flips and rolls. This would cause loss of stability and control.

MAXTHROTTLE 2000- Your full throttle setting. Should match what your ESCS are calibrated for. Can be set lower if you want less power at full throttle but this would come at a cost of having some dead space at the top of the throttle travel. At Full throttle the FC should be able to compensate by lowering power to individual motors, specially with comp_pwm or KISS ESCS. I keep mine at the ESCS full throttle calibrated setting.

MAXCHECK 1980 - Throttle must reach this number for stick commands while disarmed. I keep my mincheck and maxcheck pretty close to the endpoints so I don't accidentally input commands.

MINCHECK 1020 - The point (throttle position) at which MINTHROTTLE will be sent went armed. So in this case when armed and throttle reaches 1020, the motors will start up at 1100us power.
(Note: If motor_stop is not enabled - motors will spin and idle at MINTHROTTLE speed when armed but will not react to changes until MINCHECK is reached. ) Keeping mincheck low also keeps the dead area at the bottom of the throttle stick small and alows for more effective throttle space.
Effectively once the RX signal reaches mincheck the motors will spin and throttle will be low at 1020 and high at 2000 even though the motors will be spinning low at 1100 and high at 2000.

RX signal = (endpoint)1000 -----------(mincheck)1020 -->-->-->-->-->-->-->--> 2000 (Endpoint)
motor us = ----------------1000------------(minthrottle)1100 ->->->-->-->-->-->-->-->2000 (maxthrottle)
motor power -----------------------------------motors start-->->-->-->-->-->-->-->-->-motors full power

BTW my escs are calibrated at 1000 to 2000 at this time.

Hope that makes sense.
Please correct me if you see something wrong with this explanation.
Last edited by MassiveOverkill; Jan 06, 2015 at 03:41 PM.
Sep 19, 2014, 08:41 PM
Registered User
MassiveOverkill's Avatar
Thread OP

Calibrating your ESCs and Autotune


ESC Calibration

Calibrating your ESCs. There's already a YT video out there using ***** to calibrate your ESC's.......do a YT search. If anyone wants to do another video using CF, I'll be happy to post it here.

https://www.rcgroups.com/forums/show...3&postcount=69

Calibrating your ESCs with CF is so painless. WITH YOUR PROPS REMOVED, and main battery disconnected go to the Motor Testing tab and check the Motor Test Mode Notice box.

Now move the Master slider to max and you'll see all 4 motor throttle level indicators max out as well.

Now plug in your main LiPo and your ESC's should do their musical notes denoting max throttle (2 beeps). Shortly afterwards click the Master slider so it's back down to zero and your ESCs are now calibrated. NOTE: On Emax ESCs once you hear two beeps you must then lower the master throttle slider to zero. If you wait to long you can go into programming mode (if you do this, unplug the main battery to get out of it without changing parameters).

If your ESCs won't go into calibration mode you may have to set max throttle higher. Increase from 1850 to 1900 and try again. If it still doesn't go into calibration mode try 1950, and then 2000. Once calibrated, make sure your throttle endpoints in your transmitter is adjusted to match the max throttle value.

Autotune

Autotune (referred to as 'AT') is a relative new feature ported over from Bradwii. It's new but you can successfully get a really decent PID tuning session. Here are some videos of it in action:

Naze32 Cleanflight firmware auto tune test (2 min 56 sec)

Cleanflight autotune (1 min 52 sec)


Documentation

Turn off the autotune switch. If the autotune switch is on while not armed the warning LED will flash and you cannot arm.

Launch the multirotor.

Turn on/hold the autotune switch on your transmitter.

Observe roll left/right. A beep code will sound on the beeper.

Turn off/release the switch while still flying to stop this phase of tuning.

PID settings will have been updated for ROLL/YAW.

Turn on/hold the switch again.

Observe pitch forwards/backwards. A beep code will sound on the beeper.

Turn off/release the switch while still flying to stop this phase of tuning.

PID settings will have been updated for PITCH/YAW.

PIDS are updated, fly and see if it's better.

If it's worse, flip the switch again to restore previous pids that were present prior to arming.

Land.

Verify results via an app while power still applied if desired.

Cutting the power will loose the unsaved pids.

If you're happy with the pids then while disarmed flip the autotune switch again to save all settings then flip it back so you can arm again.

A beeper will sound indicating the settings are saved.


Now, some observations by some users:

1) Once autotune gets further into a tuning cycle you'll most likely need greater effort to keep the multi upright. Perform AT in an open, grassy area in case you crash. Start it with default, or close to default settings. ONLY perform it LOS, not FPV.
2) There's no need to let AT complete a full tuning cycle. I personally only let my sessions go until the first wild swing, which was between 5-10 seconds for aileron and elevator tuning.
3) Suggest you assign AT to a momentary switch to easily disengage it if things get too hairy for you.
4) AT is really for your average quad build and pilots who really aren't comfortable with PID tuning. If you have a high-powered setup and/or are used to PID tuning. You may want to stick to tuning manually. As stated: IT'S A BETA FEATURE. If you don't like it, don't use it. If you've had good results or have tips to share with your success, please share them so we can document it.

Loop time: I'm using stock looptimes (3500). 2500 seems to be a good recommended setting. Unless you know for sure what update frequency your ESCs support, leave it alone or increase loop time if you have ESC synch issues\ weird behavior and retune. Also if your running extra soft serial ports, you should add some loop time if you've initially lowered it to accommodate the extra processing required for your additional soft serial ports.

Props can make a big difference in PID tuning so when looking at someone else's settings you should look at the hardware\props they're using.
Last edited by MassiveOverkill; Jun 01, 2015 at 06:03 AM.
Sep 19, 2014, 08:58 PM
Registered User
How do you get AutoTune option ?

I've had it on my Goog and the only thing different, in feel, is RSSI.

I saw screen captures that showed AutoTune in CFlight, but for some reasons, I don't get that on my table of choices. A look at multiwii discussion, someone did use AutoTune but with 4s batts and claimed that extreme moves smoked his motors (no way to verify that was true) so I thought that's perhaps the reason it was removed for the time being.

I really wanted to try it.
Sep 19, 2014, 09:17 PM
What is a controlled landing?
bebeep89's Avatar
Quote:
Originally Posted by Modglock20
How do you get AutoTune option ?

I've had it on my Goog and the only thing different, in feel, is RSSI.

I saw screen captures that showed AutoTune in CFlight, but for some reasons, I don't get that on my table of choices. A look at multiwii discussion, someone did use AutoTune but with 4s batts and claimed that extreme moves smoked his motors (no way to verify that was true) so I thought that's perhaps the reason it was removed for the time being.

I really wanted to try it.
Did you flash your FC with Cleanflight firmware first? If not, try that and then see if it shows up under the Aux tab in Cleanflight. I am going to mess it more this weekend myself on my 250 quad.

make sure you back up your settings first like MO said above.

Vantasstic had this posted in the other thread. It's a step by step for using Autotune: https://github.com/hydra/cleanflight...cs/Autotune.md
Last edited by bebeep89; Sep 19, 2014 at 09:27 PM.
Sep 19, 2014, 09:37 PM
Registered User
MassiveOverkill's Avatar
Thread OP
Quote:
Originally Posted by Modglock20
How do you get AutoTune option ?

I've had it on my Goog and the only thing different, in feel, is RSSI.

I saw screen captures that showed AutoTune in CFlight, but for some reasons, I don't get that on my table of choices. A look at multiwii discussion, someone did use AutoTune but with 4s batts and claimed that extreme moves smoked his motors (no way to verify that was true) so I thought that's perhaps the reason it was removed for the time being.

I really wanted to try it.
You've actually flashed your board with CF firmware right? You'll be able to connect to a non CF-flashed board and see some settings, but until you actually flash it you won't have access to that feature.

Sep 19, 2014, 10:02 PM
Registered User
Got it. I thought I flashed it, but didn't. I just got too many distractions today!

Mucho gracias!
Sep 19, 2014, 10:15 PM
Registered User
MassiveOverkill's Avatar
Thread OP
One mistake many may make is trying to connect when flashing. You want make sure you can see a port available for connection in the upper left had corner, but you don't want to connect when flashing. Also when checking your TX channels, REMOVE YOUR PROPS, connect the LiPo, and then plug in the board via USB to your PC. If you connect to PC first you won't see TX movements (at least not in my case).
Sep 19, 2014, 10:35 PM
Registered User
MassiveOverkill's Avatar
Thread OP
Here are my AutoTune Settings for my NightHawk Carbon/Glass 250 quad with Emax 1806 motors, HQ6045 props, and 2S if anyone wants to compare.
Sep 19, 2014, 11:08 PM
Registered User
Quote:
Originally Posted by MassiveOverkill
Here are my AutoTune Settings for my NightHawk Carbon/Glass 250 quad with Emax 1806 motors, HQ6045 props, and 2S if anyone wants to compare.
How did it fly with those PIDs? Vs manual PID you set back in BaseFlight?

I will AutoTune come morning and post result, perhaps two sets of result, one for old 8"(8045) DJI props and one for the newer 9"(9443):
F330 + DJI red motors on ceramic bearings on 3s.

Later, I'd like to repeat the tuning with SunnySky X2216 motors.

That will give 2x2 matrix set of data, hopefully interesting to give a sense of how PID sets would vary with these two dimensions.
Sep 19, 2014, 11:11 PM
Registered User
MassiveOverkill's Avatar
Thread OP
I never manually set my PIDs. It flew great with default settings. I just wanted to test out autotune. I haven't flown it on our course but will do so this Sunday and report back. I'm not changing my looptime either.
Sep 20, 2014, 01:04 AM
Switching to guns!!!
CO_rcDude's Avatar
Been waiting for this Romeo!

subscribed
Sep 20, 2014, 01:19 AM
Embrace the suck!
Fyathyrio's Avatar
Besides the FC from He-Who-Must-Not-Be-Named, is it ok to mention others? I have a "frick"32 and a new "muppet" 32 Acro that looks just like yours...I suspect I may have some questions on those soon.
Sep 20, 2014, 01:23 AM
Switching to guns!!!
CO_rcDude's Avatar
Dont forgt about featre vbat and featturr failsdfe

I rather use FC falsafe tha nRX failsfe


Quick Reply
Message:

Thread Tools