WIP WIP WIP manual being revamped WIP WIP WIP
Open Flight Stabilizer (FlightStab)
rcgroups thread http://www.rcgroups.com/forums/showthread.php?t=1794672
source code https://github.com/noobee/FlightStab
build images https://github.com/noobee/FlightStab/tree/master/Builds
- 3-axis gyro-based stabilization.
- WING mode mixing (single aileron and flaperons).
- DELTA mode mixing.
- VTAIL mode mixing.
- CPPM mode.
- throttle and flap channels pass through in CPPM.
- gyro-based attitude hold.
- configurable mixer limits to prevent servo binding.
- stick-based configuration for options.
- EEPROM storage for configurations (can be reset through jumpers on bootup)
- LED flashes for status and errors.
- RX calibration during startup to determine neutral stick positions.
- IMU calibration during startup to remove sensor offsets.
- AUX channel controls master gain linearly from 0% to 100%
- AUX channel also controls RATE and HOLD modes
- VRs on RX3S control axis gain and direction.
- DIP switches on RX3S control the mix mode.
- HOLD mode for attitude hold
- stick-controlled rotation rate in HOLD mode, optional in RATE mode
- inflight RX calibration to reset RX neutral values
- PID parameters adjustable through program box
- stick position controls gain, which prevents overcorrection or "fighting" commanded stick movement during manoeuvres.
- allows side mounting on flat fuselage foamies (by rolling 90° left or 90° right and then mounting to the fuselage side)
- optional AVRootloader to allow firmware update without usbasp ISP.
- use pre-built firmware or build your own from the source code.
- support the AQUASTAR or DLUX programming box
note that some features are currently only in the dev/beta image.
Flashing the Firmware (for non Arduino-based boards)
Flash using eXtreme Burner
Setting up eXtremeBurner (first time)
- install eXtreme Burner - AVR (http://extremeelectronics.co.in/category/software/)
- edit the properties of `C:\Program Files\eXtreme Burner - AVR\Data` to allow the user full control over the directory. otherwise, the contents are read-only.
- edit the file `C:\Program Files\eXtreme Burner - AVR\Data\chips.xml` to add support for the new ATmega168PA chip type.
- add the following XML section just after the ATmega168 section
- save the file. if there is an error saving, then check the directory access properties in the second step above again.
Checking and erasing the device before flashing for the first time
- run eXtreme Burner and select Chip type as ATmega168PA
- connect the ISP connector to the RX3S
- select Read All. the program should recognize the chip and proceed to read the flash, EEPROM and fuse/lock bits
- the flash and EEPROM will be read back as 0xff (since the lock bits LB1/2 are set). that is correct.
- the fuse/lock bits should read the following (the calibration value does not have to match):
- DO NOT PROCEED IF THE VALUES DO NOT MATCH OR IF EXTREME BURNER CANNOT RECOGNIZE THE CHIP (AFTER 2-3 TRIES)
- FROM THIS POINT ONWARDS, YOU WILL ERASE THE CHIP AND REFLASH WITH NEW FIRMWARE. THERE IS NO WAY TO RESTORE THE ORIGINAL FIRMWARE.
- select Chip Erase. the program will erase the chip and reset the lock bits.
- select Read All again, this time the lock fuse should read lock=0xff.
Flashing the device (each time you want to upgrade the firmware)
- open the firmware hex file
- either select the appropriate one from .\FlightStab\Builds\*.hex, or
- select the generated FlightStab.cpp.hex (if you built the firmware from sources, which is described later)
- select Write from the menu bar then Flash. the program will write the updated firmware to the flash. sometimes it will fail to recognize the chip ID. try again 2-3 times and it would usually succeed.
- disconnect the ISP connector from the RX3S.
Flash using avrdude
- avrdude recognizes the ATmega168PA with -p m168p
- please check the docs on how to read and verify the fuse bits, and how to erase the chip.
- apply the same caution in the previous section to verify the fuse/lock bits before erasing the chip.
- to flash the device, i used the following command (in a single line):
avrdude -C "C:\Program Files\arduino-1.0.3\hardware\tools\avr\etc\avrdude.conf" -c usbasp -p m168p -U flash:w:<filename>.hex
Flash using avrdude on NanoWii (which has the arduino/leonardo bootloader)
avrdude -p m32u4 -P COM7 -c avr109 -b 1200
avrdude -p m32u4 -P COM5 -c avr109 -D -Uflash:w:%1:i
Save above code to a Text file and rename something handy for you, example NanoFlash.bat. Open Explorer and type into address bar '%APPDATA%\Microsoft\Windows\SendTo' and put NanoFlash.bat in that folder.
You'll need to swap details in Blue/Red to suit your FC.
How to find Trigger and Active Comports:
- Open device manager. Plugin NanoWii that port number will be Trigger Port. Replace Blue with this number.
- You'll manually reset the board while watching device manager. Will change to the Active Port number for few sec's. Change Red with this number.
How to use
- Right click on *_NanoWii.hex file and go to option 'Send to' chose NanoFlash and your done.
Optional: Flashing the AVRootloader
It is possible to flash a bootloader via usbasp on the RX3S. If the bootloader is installed, then flashing the main stabilizer firmware does not require the usbasp. Instead, an FTDI USB-serial adapter with a small circuit mod connects to the AILR_OUT channel, which is more convenient than opening up the device to upgrade the firmware via the usbasp ISP connector. The circuit mod follows:
Steps to flash the bootloader (note: for RX3S only):
- if flashing for the first time, follow earlier instructions to erase the chip and clear the lock bits.
- flash the hex file at .\FlightStab\AVRootloader\AVR\default\AVRootloader_AILR_OUT.hex
- update the EXTENDED FUSE setting from 0xF9 to 0xFC. This enables the atmega168pa to boot a 512-byte bootloader on reset.
Steps to flash the stabilizer image with a bootloader-enabled device:
- connect the servo connector from the FTDI + circuit mod to AIL_OUT channel
- run .\FlightStab\AVRootloader\Windows\AVRootloader.exe
- verify that baud rate is 115200 (optional, bootloader auto detects), “erase device during programming” is checked, “verify device after programming” is checked.
- click “connect to device”, which should establish a session with the device. If you have trouble connecting, try pressing “connect to device” then turn on the switch to power up and boot the device.
- select the flightstab hex file as the flash image file.
- click “program” to flash the stabilizer firmware. it should flash and verify the image, which completes in about 4 seconds at 115200 baud rate.
OPTIONAL: Building the firmware image from source code
Building firmware from sources is optional, you can also use prebuilt firmware in .\FlightStab\Builds\*.hex
Building the firmware via arduino IDE
- install arduino v1.0x (http://arduino.cc/en/Main/Software)
- installing the i2cdevlib is optional unless you want to enable this library with #define USE_I2CDEVLIB. the default is USE_I2CLIGHT
- download i2cdevlib (http://www.i2cdevlib.com/usage)
- place i2cdev directories in C:\users\<user>\My Documents\Arduino\Libraries
- run Arduino.exe and select Board as `Arduino Pro or Pro Mini (5V, 16MHz) w/ ATmega 168`
- load `FlightStab.ino`
- uncomment `#define RX3S_V1` for RX3S V1 and check all other devices are commented out.
- verify/compile the program.
- locate the generated hex file at `C:\users\<user>\AppData\Temp\build<numbers>.tmp\FlightStab.cpp.hex`. sort the directory by modified-date to help find the most recent `build<numbers>.tmp` entry.
- verify the timestamp of `FlightStab.cpp.hex` matches current time.
Building the Firmware via cmake (recommended)
- install C:\Program Files (x86)\CMake 2.8
- ensure PATH includes C:\Program Files (x86)\CMake 2.8\bin
- install C:\Program Files\arduino-1.0.3 (this exact path is important!)
- ensure PATH includes C:\Program Files\arduino-1.0.3\hardware\tools\avr\utils\bin
- run the following commands:
rd /s . (this optional step wipes out all intermediate files)
cmake [-DTODAY=yyyymmdd] -G"MSYS Makefiles" .. (-DTODAY is optional to override the system date)
- a list of .hex files will be created in the current directory for all the different devices and with different compile-time options.
Connecting the RX3S V1
Connecting the RX3S V1 with CPPM
Connecting the RX3S V2
Connecting the RX3S V2 with CPPM
Connecting the NanoWii
- connect the device based on the connection diagrams. for RX3S, the DIP switches set the WING mode (single aileron, dual ailerons or flapperons, delta or vtail). for NanoWii, the stick configs will set WING mode.
- if you change any DIP switch settings, power cycle the device to enable the new setting to take effect.
- the VR gain POTs on the RX3S control the correction gain and direction for each of the pitch (ELE), roll (AIL) and yaw (RUD) axis.
- 7 o'clock = max gain in one direction
- 12 o'clock = zero gain
- 5 o'clock = max gain in opposite direction
- the AUX channel controls the master gain linearly. It can be set with a knob/slider (ideally) or a 2/3-position switch. It can also be left unconnected, which defaults to MAX gain in RATE mode.
- the AUX channel also controls RATE mode vs HOLD mode. The following diagram shows the AUX1 pulse width determining RATE and HOLD master gain values. To calibrate the TX AUX1 for 1500us, apply subtrim to AUX1 (with 3P switch in middle position for example) until you are at the point between 4 flashes and no flashes, that is effectively zero stabilization.
- the stick position also controls the gain to reduce the stabilizer from over correcting your controls during manoeuvres.
- neutral position = max gain
- extreme position = zero gain
- in between = linear between max and zero.
- there are 4 LED message slots. each slot is a series of flashes to indicate a condition. LONG flashes are 600ms pulses (600ms on and 600ms off), SHORT flashes are 200ms pulses and VERY_SHORT pulses are 30ms pulses. the number of pulses and duration of each pulse determines the message.
WING mode = single aileron
WING mode = delta
WING mode = vtail
WING mode = dual ailerons (flapperons)
both RX and IMU calibrating
HOLD stabilization mode (otherwise RATE stabilization mode)
device init error (gyro)
20 VERY SHORT
50 VERY SHORT
EEPROM has reset, power cycle device now
RX and IMU Calibration on Startup
- after powering up, the device will try to calibrate the RX input and IMU sensor simultaneously.
- during RX calibration, keep the AIL/ELE/RUD sticks in the neutral (centered) position. for flapperons, it does not matter if they are in the UP or DOWN position. once the device has detected that the sticks have been still for a period, it will record those readings as the neutral stick positions.
- during IMU calibration, keep the plane still on the ground. it does not have to be wings level, just have to be still. once the device has detected that the IMU readings are stable, it will record those readings as the “zero” rotation rate values.
- the LED will flash accordingly if the RX or IMU (or both) calibration is still in progress.
- Stabilization will engage once both RX and IMU calibrations complete. You can tell it is the case by any one of the following:
- waiting for the control surfaces to wiggle back and forth 3 times
- looking at the LEDs (should not see calibration status)
- rocking the plane to see if there is correction (with proper gain setting)
- If there is a power cycle in the air, the device will undergo calibration again. But it is unlikely for the plane or the TX to be still enough for calibration complete in the air successfully. However, the RX signals still pass through to the servos, allowing you to control and land the airplane, but without any stabilization.
Mixer EPA Mode
- there are 3 mixer EPA modes that controls the limits of all the servos.
Mixer EPA mode
start with 1250-1750us, then track and never exceed the RX
- with tracking mode, the servos will never be driven past the point that the RX would drive if there was no stabilization correction. this would prevent servo binding. however, this means that you should “cycle” the sticks to the limits on the ground each time before flying for the device to learn the limits from the RX. otherwise, it would apply a smaller correction than it could based only what it learnt from the RX.
- the mixer EPA mode can be set from stick configuration.
- The device supports CPPM mode for reduced connections to the RX and to enable more channels (AUX2, THROTTLE and FLAP) on the RX3S V1 and V2 devices. The RX3S V3 device has an integrated RX, which cannot be set to CPPM mode.
- Refer to the connection diagram for CPPM connection. note that the THROTTLE and FLAP channels are passed through and available through two pins since the RX is unlikely to output CPPM and individual channels at the same time.
- currently, only the “RETA1a2F” CPPM channel order is supported.
- Attitude HOLD allows the plane to fly with a fixed attitude (as long as there is sufficient power and control surface authority).
- The AUX1 channel determines if the plane is in RATE (stabilization only) mode or HOLD mode.
- When attitude hold is enabled, the device will engage, or hold the attitude, whenever the sticks are near their neutral position. Attitude hold will disengage when the stick moves away from the neutral position.
- Pitch and roll are separately controlled from yaw. For example, the device can hold a high alpha attitude (with pitch and roll) while you use the rudder to steer the aircraft. For another example, the device can hold a knife edge (with yaw) while you use the aileron and elevator stick to steer the aircraft.
- Attitude hold is short term as the gyros drift after a brief period. When you move the sticks to correct for the drift, the device will disengage the hold and then re-engage when you return the sticks to the neutral position.
- The device supports mounting to the side of a flat fuselage foamy. Assuming you start from a normal flat orientation, you can either roll the device 90 degrees to the left and mount it to the left side of the fuselage or 90 degrees to the right and mount it to the right side of the fuselage. in this way there is no need to rearrange all the RX and servo channel wires.
- Please see the stick config section for updating the device mounting orientation and storing it into the EEPROM.
Stick Configuration Mode
- To enter stick configuration mode, move the AIL/ELE stick to 7-9-7-9-7 positions within 15 seconds after powering up the device (assuming mode 2 TX).
- The position numbers correspond to the telephone pad. 1 = top left (roll left nose down), 9 = bottom right (roll right nose up). Start from position 7 (roll left nose up):
- Note that the device assumes that the stick will visit the bottom left corner (position 7) first and will calibrate its orientation from that reference point. you could also enter stick configuration with 9-7-9-7-9, 1-3-1-3-1 or 3-1-3-1-3 stick transitions but the up/down and/or left/right directions will be reversed while in configuration mode.
- Once in configuration mode, the ELE servo toggles to indicate the config item and the AIL servo toggles to indicate the config value:
1 = single aileron [default]
2 = delta
3 = vtail
4 = dual ailerons (flapperons)
-4 to 0 to +4 [+4 default]
-4 to 0 to +4 [+4 default]
-4 to 0 to +4 [+4 default]
1 = full (1000-2000)us [default]
2 = normal (1100-1900)us
3 = tracking the RX
1 = No CPPM [default]
2 = RETA1a2F order
1 = Normal (flat) mounting
2 = Roll 90° left and mount on left side
3 = Roll 90° right and mount on right side
1 = no-op
2 = write EEPROM and reboot
- Move the AIL stick left or right to change the config item and the ELE stick up or down to change the config value.
- WING mode and Roll/Pitch/Yaw gains are ignored on the RX3S since they use the DIP switches and VR POTs for WING mode and axes gains, respectively.
- For the Pitch/Roll/Yaw gain, the AIL servo toggles one way to indicate positive gain and the opposite way to indicate negative gain. It does not toggle when the gain is zero. Try it to get a better idea.
- Selecting the last config item (Exit) and then changing the config value from 1 to 2 will write the updated config to the EEPROM and reboot the device. This is the only way to exit the stick configuration mode (other than power cycling the device).
Resetting the EEPROM
- To reset the EEPROM to default values, use a jumper to short the pin pairs for the device and then power up.
Pin pair to apply jumper
AIL_OUT and ELE_OUT
D6 and D5 (in the Motor Output group)
- On reboot, the device will clear the EEPROM and flash the LED rapidly in 3 sec bursts, which indicates that you can now power off the device and remove the jumper. On the next power up, the EEPROM should start with the default “factory reset” values.
- Normally, the plane will wiggle the surfaces 3 times to indicate that calibration has completed. If the EEPROM was reset to factory default (either on first boot or on jumper reset), the plane will wiggle the surfaces 9 times instead. This can be used to indicate a problem with EEPROM corruption when you do not expect the EEPROM to be reset.
Programming Box Support
FlightStab supports configuration through the Aquastar or DLUX programming boxes. Using the programming box is more convenient and will allow more options that using the stick configuration.
The steps to enable programming box support are:
- Use the USBASP ISP programmer to erase the chip, update fuse settings and flash the AVRootloader_AQUASTAR.hex bootloader
- Use the AVRootloader to update the main programming box firmware:
- 2013xxxx_AQUASTAR.hex for the AQUASTAR box
- 2013xxxx_DLUX.hex for the DLUX box
- Connect the programming box to the FlightStab device through the “one-wire” servo connector and power them up.
Flashing the Aquastar/DLUX with AVRrootloader
On the Aquastar, the CPU is exposed, so it is highly recommended to use the HK chip adapter for the ISP cable to the USBasp. The ISP pads are also exposed on the PCB if you want to solder the signals instead.
On the DLUX, the CPU is hidden behind the LCD board, but the pads are exposed just above the 3rd and 4th buttons. The ISP pads have the following definitions (from left to right):
After connecting the USBasp programmer to the program box via the ISP connector, the next step is to erase the chip and set the fuse for bootloader support.
- Select the target chip type as ATMega8A chip (and not ATMega168pa) on the programmer (eXtremeburner, AVRDude, etc).
- Read the fuse settings. The following table shows the expected fuse values. The calibration value is not important (and should not be changed):
On the Aquastar, the LOCK fuses are NOT set (0xFF), so you can read and save the flash image at this time in case you want to restore the factory functionality. On the DLUX, the LOCK fuses ARE set (0xFC), so you can only erase the chip to proceed.
DO NOT PROCEED if the values are unexpected.
- Erase the chip. This should also reset the LOCK fuse for the DLUX to 0xFF.
- Change the HIGH fuse from 0xCF to 0xCC. This will enable the chip to boot a 512-byte (256-word) bootloader. Remember to restore the HIGH fuse back to 0xCF if you rolled back to the factory image on the Aquastar.
- Flash the AVRootloader bootloader. Both Aquastar and DLUX use the same bootloader hex file at .\AVRootloader\AVR\default\AVRootloader_AQUASTAR.hex
Use the AVRootloader instructions to flash the main programming box firmware image (including using the “one-wire” serial connection). The Aquastar firmware is at .\Builds\20130505_AQUASTAR.hex and the DLUX firmware is at .\Builds\20130505_DLUX.hex (dated 20130505 or later).
Using the Aquastar/DLUX Programming Box
Connect the programming box to the FlightStab device. The RX3S devices uses AILR_OUT as the default channel. Power them on at the same time (or the RX3S after the program box). If the device recognizes the program box, the program box will display the recognized device ID on the status page. Press left/right to change pages and up/down to change sub-options within the page.
The status page (first page) has several items. The device ID, device version, and EEPROM statistics (1/2/R). 1 means the number of times the device detected an error and reset copy #1 of the config. 2 is the same for the redundant copy. R is the number of times both copies have been reset, usually as an outcome of the jumper-based EEPROM reset procedure or by choosing “erase cfg” through the program box.
The eeprom page (last page) has several actions. Update cfg justs updates the Flighstab device with the config that you modified with the program box. Erase cfg invalidates the config so that the device will default to “factory settings” on the next restart, as if this was the first time it was booting up. Erase stats erases the 1/2/R stats.
20130702 dev onwards
set WING mix mode
based on DIP switches
override to SINGLE AIL
override to DELTA
override to V-TAIL
override to DUAL AIL
limit servo correction output to
never exceed RX input
allow combined PPM input from RX
no CPPM, use separate RX (PWM) channels
use CPPM with RETA1a2F
use CPPM with TAER1a2F
use CPPM with AETR1a2F
support mounting sideways on flat fuselage
mount device flat “normally”
roll device 90 deg left and mount on left side
roll device 90 deg right and mount on right side
stick-position gain blends from max (1.0) to zero over
full stick range
half stick range (ie. no correction from ½ stick onwards)
quarter stick range
set stick-controlled rotation rate at full stick to
allow stick-controlled rotation rate in RATE mode
toggle RATE/HOLD 3x within 0.5s to calibrate
disable inflight RX calibration
enable inflight RX calibration
POT = use device POT setting *
-127 to 127 = override POT setting
P, I, D parameters (500, 0, 500) * for
ROLL axis P/I/D in RATE mode
PITCH axis P/I/D in RATE mode
YAW axis P/I/D in RATE mode
P, I, D parameters (500, 500, 500) * for
ROLL axis P/I/D in HOLD mode
PITCH axis P/I/D in HOLD mode
YAW axis P/I/D in HOLD mode
Write Config to EEPROM
Erase Config in EEPROM to Default
Erase 1/2/R Stats in EEPROM to 0/0/0