Friday, 11 July 2014

SimonK Firmware

This tree contains Atmel AVR assembly code for ATmega-based 3-phase sensor-less motor electronic speed control (ESC) boards, originally for Turnigy and similar models. This work is based on Bernhard Konze's "tp-18a" software, which was a port from his earlier personal work to the TowerPro 18A and original (not current!) Turnigy Plush boards. Please see tgy.asm for Bernhard's license.
Patches and comments are always welcome! Let me know how it goes!

Features

  • 16MHz operation on most boards
  • 16-bit output PWM with full clock rate resolution (~18kHz PWM with a POWER_RANGE of 800 steps)
  • 24-bit timing and PWM pulse tracking at full clock rate resolution
  • ICP-based pulse time recording (on supported hardware) for zero PWM input control jitter
  • Immediate PWM input to PWM output for best possible multicopter response (but NOT where soft start or really any significant current limiting is needed!)
  • Accepts any PWM update rate (minimum ~5microseconds PWM low time)
  • Optimized interrupt code (very low minimum PWM and reduced full throttle bump)
  • Configurable board pin assignments by include file
  • Smooth starting in most cases
  • Forward and reverse commutation supported, including RC-car style reverse-neutral-forward PWM ranges, with optional braking

Hardware

Tested boards by target:
  • afro:
  • afro2:
    • AfroESC 2 (prototype)
  • afro_hv:
    • AfroESC HV (high voltage, with all-N FETs and drivers)
  • afro_nfet:
    • AfroESC with all-N FETs (revision 3)
  • birdie70a:
    • Hobby King Birdie 70A (BIRD-60A)
    • Hobby King Red Brick 200A (RB200A, black board)
  • bs:
    • Hobby King 6A (HK_261000001)
    • Hobby King 10A (HK_261000002)
    • Hobby King 40A (F-40A)
    • Hobby King 60A (F-60A)
  • bs_nfet:
    • Hobby King 20A (F-20A)
    • Hobby King 30A (F-30A)
  • bs40a:
    • Hobby King BlueSeries 40A (and some Mystery 40A boards)
  • dlu40a:
    • Pulso Advance Plus DLU40A with opto-isolated inverted PWM input
    • Hobby King Multistar 45A
  • dlux:
    • Turnigy dlux 20A SBEC
  • hk200a:
    • Hobby King SS Series 190-200A (HK-SS200ALV)
    • RCTimer 50A TQFP version
  • kda:
    • Keda 12A rev B with inverted PWM input (30A should also work)
    • Dynam 18A, 25A with Blue Heat Shrink
    • Hobby King Multistar series (30A and under)
  • maytech30a:
    • Maytech 30A and 20A, complementary PWM
  • maytech40a:
    • Maytech 40A, complementary PWM
  • maytech60a:
    • Maytech 60A, complementary PWM
  • mkblctrl1:
    • MikroKopter BL-Ctrl v1.x (flashable by ISP only)
  • rb50a.hex
    • Hobby King Red Brick 50A (RB50-ESC)
  • rb70a.hex
    • Hobby King Red Brick 70A (RB70A)
    • Hobby King Red Brick 200A (RB200A-BTO, black board)
  • rct50a:
    • RCTimer 50A older MLF version
  • tbs:
    • Team BlackSheep TBS 30A ESC (ICP input version)
  • tp:
    • Original TowerPro 17A, 25A
    • Hobby King SS models without "-HW" in part number
  • tp_8khz:
    • tp at 8kHz PWM (workaround for DYS/HK-SS clones with PWM noise problems)
  • tp_i2c:
    • tp modified for I2C input (old ADC4 routed to ADC1)
  • tp_nfet:
    • Newer TowerPro 25A with inverted low side (BL8003 drivers)
  • tp70a:
    • TowerPro 70A with BL8003 FET drivers (inverted low side)
  • tgy (these boards typically have no external resonator):
    • Original TowerPro 18A
    • Original Turnigy Basic and Turnigy Plush 10A, 18A, and 25A (Hobbywing OEM)
    • RCTimer 10A, 18A, 20A, 30A, 40A (18A, 20A, 30A are same board with more or less FETs)
    • Hobby King SS models with "-HW" in part number
  • tgy6a:
    • Original Turnigy Plush 6A

Notes

  • If it breaks, you get to keep both pieces!
  • Use at your own risk, and always test first without propellers!
  • New Turnigy Plush, Basic, Sentry and Pentium boards (Hobbywing OEM) have all switched to SiLabs C8051F334, d'oh!
  • If your ESC has 6 pads and an AVR, it's probably compatible; the pads are MOSI, MISO, SCLK, GND, VCC, and RESET. If it has 4 pads, it is probably a newer SiLabs-based one, for which this code will not work. (Except HK_261000001 which has 4 pads but has an AVR.)
  • I build and maintain this in Linux with AVRA (1.3.0 or newer). Patches welcome for AVR Studio APS files, etc.
  • The TowerPro/Turnigy Plush type boards typically do not come with external oscillators, which means their frequency drifts a bit with temperature and between boards. Multicopters and RC-car/boat controllers (with a neutral deadband) would probably be better on a board with an external oscillator. The Mystery/BlueSeries boards typically have them, as well as most higher current boards.
  • This doesn't yet check temperature or battery voltage. This is not desired on multi-rotor platforms; however, people still want to use this on planes, cars, boats, etc., so I suppose I'll add it.