Giter VIP home page Giter VIP logo

tgy's Introduction

https://github.com/sim-/tgy

Binary Downloads: http://0x.ca/tgy/downloads/

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

See http://wiki.openpilot.org/display/Doc/RapidESC+Database and/or https://docs.google.com/spreadsheet/ccc?key=0AhR02IDNb7_MdEhfVjk3MkRHVzhKdjU1YzdBQkZZRlE for a complete list.
Some board pictures here: http://0x.ca/sim/esc/

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.

Building from Source

AVRA 1.3.0 or newer or avrasm2, part of the AVR Tools, should assemble this source. AVRA should also build on a Mac. "make all" will emit a .hex file for every build target; "make binary_zip" will make a release .zip file. There are some other make targets for programming.

In AVR Studio, the Makefile is not supported, and just loading tgy.asm and attempting to build it will not define the constant indicating the board type / build target. You must either edit tgy.asm or add an option for the assembler command line to define the board symbol, unless building the default "tgy" board type. For example, this option should emit the bs_nfet target: -D bs_nfet_esc=bs_nfet_esc Look near the top of tgy.asm for the includes and board information.

WARNING

Never just randomly try build targets until one works, especially not when directly powered from a LiPo! :P Many boards have inverted FET drives and different pin assignments. Toggling one wrong pin can fry multiple FETs. Some boards, like the Mystery 20A ESC, may all look the same on the outside by have different FETs as well. Be careful and check your board before flashing.

Installation

For more information, check out these sites:

http://wiki.openpilot.org/display/Doc/RapidESCs http://wiki.openpilot.org/display/Doc/Flashing+Instructions http://www.rcgroups.com/forums/showthread.php?t=1513678

See warning above! The safest arrangement is to use a current-limited bench power supply, set to a low voltage (6V-7V), for both flashing and initial testing. If the pinout is wrong and causes a short, the current limiting causes the input voltage to drop below the brown-out detection voltage of the MCU, causing all output pins to go high-impedance in hardware, and an automatic reset when the voltage comes back.

If you do not have a current-limited supply, you can improvise by using 4 AA batteries or an old NiCd pack or even a LiPo with a 12V light bulb in series to act as a current limiter. Be careful when touching the board, since it can be quite easy to turn on a FET gate with just your finger. This should be OK if you have a current-limited supply, since it should just reset.

Even if the board appears to be one tested by others, make sure yours has the expected FET pin assignments, inversions, and sense lines! The assignments for each board type can be found in the .inc files, and the actual pin mappings can be found in the first few pages of ATmega8 datasheet. This typically requires a voltmeter and, preferably, an oscilloscope.

When not powered, use a voltmeter to check the path from the MCU pins to either the FET resistors, transistors, or driver chips, and verify that they match the assignments in one of the include files. Then power up the ESC with the original firmware, and check with an oscilloscope the inversions of the same pins. A voltmeter may be used instead when the motor is stopped. Be careful not to short FET pins together! If all voltages are low when the motor is off, nothing is inverted, and the INIT_Px values in the .inc file should be 0 for all of the FET bits.

Older and smaller boards typically use P-FETs and N-FETs in the H-bridge; the P-FETs are typically driven by three NPN transistors, while the N-FETs are driven directly at TTL voltages with just a low resistor. Medium-sized and newer boards have moved to all-N-FET designs, but maintain the NPN transistors, and so have inverted P-FET pins from the MCU. Larger current (>~30A) boards typically have separate FET driver chips, to which the N-FET or P-FET pins may be inverted (but not both, since it would blow up before the MCU initializes).

PWM is usually done on the low side of the H-bridge, where high frequency driving is easiest. If the average voltage increases at the AVR pin as throttle increases, and drops to 0V when stopped, the low-side FETs are not inverted; if average voltage decreases, and rises to 5V when stopped, the low-side FETs are likely inverted. The high side FETs are only switched at every other motor commutation step, and so switch at a lower frequency, and should be off 2/3rds of the time. If at 0V when stopped, and less than 2.5V average when running, the P-FETs are not inverted. If at 5V when stopped, and more than 2.5V when running, the P-FETs are inverted. In the case of inverted an FET group, they should be listed in the INIT_Px values (to turn them ON at boot), and the "on" macros should use clear instead of set instructions. The inverse applies to the "off" macros.

There are four sense lines. The three output phases go through resistor dividers (to bring the voltage down to between 0-5V), and then are connected to ADC channels which can be accessed by the comparator with the ADC multiplexer when the ACME (Analog Comparator Multiplexer Enable) bit is enabled. Some boards use all ADC channels while others put one pin on AIN1 so that the ADC can sample voltages on other ADC channels while the comparator samples that phase. A "center tap" is established with a resistor star and connected to AIN0 on all boards, for detecting the zero-crossing from the motor back-EMF for timing. You can check which pins run to which output phases as they will have the lowest resistance from output phase to AVR pin, and all three will have a common resistance to the AIN0 pin.

Boot Loader

Since the 2012-06-01 release, the pre-built .hex files contain a boot loader that allows for flash and EEPROM reading and writing over the PWM input wire. The main purpose of this boot loader is to support software updates without having to expose the MCU or ISP pads for SPI programming, assuming this version or newer has previously been flashed.

The boot loader is available on all boards which are wired in way that permits two-way communication over the wire. Some ESCs are isolated with an opto-isolator or by components to invert the signal to be compatible with ESCs that do have an opto-isolator, such as ESCs that work with the kda.hex target. Such boards will not be able to use this protocol.

The boot loader uses an implementation of the same wire encoding as the Turnigy USB Linker. This is a simple 9600bps serial to half duplex wire converter that encodes signals in a way that should make it difficult to start a motor, even on an ESC not supporting the protocol, regardless of data sent. However, it is still possible that this could occur, so follow the same precautions as with normal ISP flashing, below.

If the Turnigy USB Linker is not available, it is possible to use an Arduino or MultiWii board as a gateway between (USB and) serial and the wire protocol used by the boot loader. See the ArduinoUSBLinker project by Chris Osgood: https://github.com/c---/ArduinoUSBLinker

Boot Loader Fuses

Since the 2012-09-30 release, long periods of high PWM input while disarmed will cause a jump to the boot loader, if present. Since the 2013-04-24 release, this became detangled from the included boot loader (BOOT_JUMP vs BOOT_LOADER), so other boot loaders may be used instead.

As a result of the automatic jumping, it is not necessary to change the fuses to enable the boot loader. It may or may not be desirable to set the BOOTRST flag depending on intended operation and the hardware in use.

If the hardware does not have any low pass filter or pull-down on the PWM input, it may easily float high by the time the boot loader checks it, which can prevent normal startup if another input (eg: I2C) is expected to be used. There should be pull-down or load present on the PWM input to prevent this if BOOTRST is enabled.

Confusion may also result if the pin floats high with nothing connected and power is connected to check for starting beeps. Likewise, touching the connector or connecting it later may drain the input and cause normal startup to occur, which may seem like the ESC is resetting while powered. This is not a problem if the PWM input is normally intended to be used.

On the other hand, with BOOTRST not set, it is not possible to recover from an interrupted flash, flash of the wrong board type, or flash of other software or versions older than 2012-09-30 without connecting to the ISP pins to do the flashing.

To enable the the boot loader on ATmega8 boards, the low nibble of the hfuse should be set to 'a'. See "make bootload_usbasp" to do this automatically. BOOTRST and BOOTSZ1 should be enabled to set 512 words, start at $0E00.

Flashing and Testing

Sort out how you want to connect an ISP programming device to the chip. Some boards have 6 pads in a row for this purpose. You can either solder wires, or make up some kind of springy-pin connector that touches the pads or chip pins without needing to solder. This is helpful when flashing more than one board. See here for some ideas and discussion: http://www.rcgroups.com/forums/showthread.php?t=1513678

Sort out which software you will use for flashing. The KKMulticopter Flashtool now supports ESC flashing and is commonly used. You may also download AVR Studio and the AVR Toolchain from www.atmel.com, or try "avrdude" on most OSes. There are plenty of resources on the web for AVR ISP programming, and many ways to do it.

Power the ESC from a current-limited supply and try to read the stock firmware (flash) and EEPROM, to use as a backup. Most are locked and will still appear to read, but the files will contain just a series of repeating/increasing digits. If you do manage to get something, consider yourself lucky!

Write down the stock fuse values, and check that they are sane. Most AVR programmers have a menu for this, but with avrdude or uisp, Google "AVR fuse calculator", select the ATmega8 target, and type in the hex values. If the "watchdog" fuse is enabled, you will want to disable it for now. The brown-out voltage should be set to 4.0V and enabled (BODEN). Leave the rest of the fuse values as shipped, and write down the new values.

Flash the desired target .hex file to the AVR, then set the fuses, if anything needs changing. If you have any errors, check the connections to and voltage at the chip. Sometimes, a weak power or signal connection can temporarily work and then fail part-way through programming, giving verification errors. This can happen particularly if the target chip is powered weakly by the programmer itself, which then back-feeds to the rest of the circuit and tries to charge the capacitor, etc. Also check that the ground pin (black wire) actually connects to a pin marked "GND", not "NC" as on some USBasp devices!

Once programming is successful, hook up a small motor without propeller and reset the power. You should hear three increasing beeps. If not, or if you hear only some beeps, the FET pinout may be incorrect or one or more FETs may be broken. Repetitive clicking can also indicate that the pinout is incorrect and causing continuous brown-out resets.

Now, if you attach a valid PWM servo pulse with low-enough pulse length, you should hear a forth beep indicating that the ESC is armed. If not, try lowering the trim as far as possible. If it still doesn't work, you may need to raise the STOP_RC_PULS value in the code.

Once armed, the ESC will try to start the motor if the pulse length (throttle) is increased. Try running up the motor slowly, and make sure everything runs smoothly. If on a variable supply, increase the voltage to the expected running voltage, and try again, with slow and rapid throttle changes.

Finally, test the ESC in the intended application, with the usual power source, without anything attached to the motor shaft/bell first. Then, attach the propeller or gear, etc., LOCK IT DOWN so it doesn't hit you in the face, and try a slow sweep from idle to full throttle. Finally, try rapid throttle changes from slow to fast. The ESC and motor should run smoothly, never lose timing, and the ESC should not reset. If using a flight control board, you can sometimes tap the board to make it output a sudden throttle increase.

For debugging reset causes, recent code has different beep sequences for each AVR reset case. See the Troubleshooting section below.

Throttle Calibration and Programming

Since the 2012-01-04 release, the input throttle range may be calibrated. This should be used whenever PWM input mode is used, including where external resonators are present, to set the usable throttle range.

The default range is set at the top of tgy.asm (stop at 1060us, full throttle at 1860us) and is not changed if no new value is saved to the EEPROM. However, boards without external oscillators (typically those which use tgy.hex) must use the internal RC oscillator on the Atmega8, which may be off by 5% - 10% between each board, and will also drift by 10% or more over a 40 degree Celsius temperature range. This can cause throttle differences between boards if not calibrated, and issues arming the ESC, particularly in cold environments.

Some flight boards may have automatic calibration procedures, or it may just be possible to set the min/max motor output to exactly match the ESC defaults listed above. ESCs with external resonators can use this method to avoid calibration. With a flight board such as the Naze32 running baseflight, the min/max can be set with CLI commands as follows:

set minthrottle=1064

set maxthrottle=1864

Otherwise, to calibrate the ESC, REMOVE ALL PROPELLERS and follow the steps that may be documented for your flight controller board. KK2 boards have a two-button procedure that emits calibration pulses automatically. With KK boards, the Yaw pot must be set to the minimum position in order to enable "pass through" mode from the RX input to the ESC output. The ESCs are then calibrated to the radio's throttle stick.

Calibration may also be done with a servo tester or with the ESC directly connected to an RX channel. The only requirement is that the input pulse has to be at or above PROGRAM_RC_PULS (default 1460us) to enter programming mode. This will differ slightly on boards with no external oscillator. If calibrating ESCs individually, try to maintain a close temperature and at least 6-7V input voltage (the ATmega8 oscillator speeds up as temperature and Vcc decrease).

With the propellers removed and the source (radio, servo tester, or flight control board) set to full throttle, power up the ESC and wait for a single beep after the typical rising initialization beeps. This indicates the high pulse length has been saved to RAM. Move the stick or knob to the lowest setting, and wait for two beeps. This indicates that the low pulse length has been saved to RAM.

If RC_PULS_NEUTRAL has been enabled (RC Car-style reverse mode), move the stick/knob to the center, and wait for three beeps. This indicates that the neutral pulse length has been saved to RAM.

If the stick is not moved after the final setting, the ESC should now write the RAM settings to EEPROM, and continue startup. The ESC should recognize the same pulse length input as a valid arming pulse, and arm and work as usual.

The input PWM pulse is measured in 24-bit space and scaled in 16.16 space to fit the number of PWM steps defined by POWER_RANGE - MIN_DUTY. There should be no measurable aliasing or quantization. Alternatively, the values may be adjusted in EEPROM directly. While calibrating, margins of 1/16th on the low end and 1/32nd on the high end are used to try to avoid problems with arming and reaching full throttle during temperature extremes. If desired, margins may be adjusted in tgy.asm between rc_prog2 and rc_prog5.

There is currently no way to reset (remove) the calibration other than by clearing the EEPROM (or reflashing without EESAVE set). This may be implemented in the future by some basic stick programming feature.

NOTE: As of 2012-03-15, throttle calibration is disabled when a brown-out reset is detected. I accidentally calibrated an ESC when testing with a NiCd pack. The pack could not supply enough current, resulting in a brown-out reset of all ESCs, excluding the flight controller. I did not lower the throttle in time, resulting in one ESC getting a stable enough signal to store a new calibration. When intentionally calibrating, be sure that you cleanly connect the power. If you don't hear the rising beeps, remove the power for a few seconds to allow the capacitors to discharge, then try again.

Troubleshooting

There are 4 main beep frequencies used at different intervals and lengths to signal the various operation and fault states. These beep frequencies are labelled here as f1 through f4, where a higher number indicates a higher frequency. Repetition indicates longer beeps.

If CHECK_HARDWARE is enabled (default on the Afro and TBS boards), the drive and sense circuitry will be tested for correct operation at boot. This check will prevent beeping if it would be unsafe to do so (for example, if beeping would end up completing a short circuit), and so may prevent further damage in some cases.

Error conditions from CHECK_HARDWARE are flashed through the LED(s), if present, or beeped (if possible) before anything else, in a looping pattern, for as long as the error condition(s) persist. All conditions cannot be checked on some hardware due to pin routing, but will be indicated by beeping or flashing a particular count followed by a pause. If more than one error condition is present, each error will be reported in sequence. The error conditions are:

1: Phase A stuck high
2: Phase B stuck high
3: Phase C stuck high
4: AIN1 stuck high
5: AIN0 stuck high
6: Phase A low-side drive broken
7: Phase B low-side drive broken
8: Phase C low-side drive broken
9: Phase A high-side drive broken
10: Phase B high-side drive broken
11: Phase C high-side drive broken

Note that if the ESC resets while the motor is still spinning (such as after a brief power cut), it is possible that the induced current will cause some transient errors that will clear once the motor stops, and then operation will continue.

During boot, the MCUCSR register is checked to see the reason for reset. For exact behaviour, see near "Check reset cause" in tgy.asm. Here are the expected beep sequences:

f1 f2 f3: Regular startup with nothing special detected

f3 f1: Voltage brown-out bit was set (MCU voltage dropped below 2.7V/4.0V)

f4: External reset (via the reset pin, as in after programming)

looping f1 f1 f3 f3: Watchdog reset (previous execution locked up)

looping beeps (8) of f2 or f4: Unknown (beeps out all MCUCSR bits, LSF)

fast repeating beeps of f4 while idle: Noise on PWM input detected

Once a valid input source is found and receiving idle throttle, f4 f4 f4 (a long f4 beep) indicates that the ESC is armed and will start the motor when throttle goes non-zero. If you are unable to start the motor and are not hearing the forth, long beep, try lowering the throttle trim, or raise it all the way to start throttle calibration (above).

If no input command is received for about 1 second, f3 f2 is beeped and the ESC returns to disarmed state, waiting for a valid arming signal.

If no valid input is received while disarmed and BEACON is enabled, an f3 beep will be emitted after about 8 seconds and then every 4 seconds.

The various beep frequencies use different FET combinations (rather than all FETs at the same time) to try to help diagnose boards with failed FETs or possible incorrect firmware pin configuration (build target). If you hear only one or two of the usual three power-up beeps, and the board worked previously, it is likely that one of the FETs has burned out. The ESC may still start and run the motor like this, but the motor will sound bad, and power and efficiency will be reduced.

tgy's People

Contributors

ahalekelly avatar esden avatar saper avatar sim- avatar sparky-p32 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tgy's Issues

Afro ESC 30A & D3530-14 Motors.

Hi everybody
With my setup:

  • Motors D3530-14
  • ESC Afro ESC 30A
  • Propellers 10x45
  • Battery 5000mAh 20C 30CBurst 3s.

When Increasing throtle slowly motors fail (I think it is a sync loss) at full throttle. When throttle is increased fastly they lose sync always. I made a couple of videos showing this behaviour. I can see red led blinking.

https://dl.dropboxusercontent.com/u/19638886/multirrotor/issues/VID_20140119_123709.3gp

https://www.dropbox.com/s/lttnpn4aj496by1/VID_20140119_142254.3gp

First time I thought it was caused by a brownout so I eliminated the PDB and shortened the DC wires to the min possible.
But it now looks like a sync problem.

My afro ESC are bought on December, but I don't know what is the version loaded. I own Afro servo wire programming tool, should I try to load the latest firmware or increase the "advance" parameter? Or maybe I am 100% wrong and there is other solution.

Thanks in advance!!

bs_nfet low frequency tones

hy!
I have build an bsnfet ESC.I used ir2101 drivers.
When i plugged in to the battery i hear 3 beeps but on low frequency tones.
As you expected theESC dosen't work....Have you some idea about this problem?
Thx!

Compile on Mac OS X 10.9

Hi,

I have installed avra 1.3.0 in my Mac, but when I try to compile I get the following error:

Kristians-MacBook-Pro:tgy-master Lauszus$ make
avra -fI -o afro.hex -D afro_esc -e afro.eeprom -d afro.obj afro.asm
afro.asm(2840) : Error   : Unknown mnemonic/macro: rcalghwait_for_high
AVRA: advanced AVR macro assembler Version 1.3.0 Build 1 (8 May 2010)
Copyright (C) 1998-2010. Check out README file for more info

   AVRA is an open source assembler for Atmel AVR microcontroller family
   It can be used as a replacement of 'AVRASM32.EXE' the original assembler
   shipped with AVR Studio. We do not guarantee full compatibility for avra.

   AVRA comes with NO WARRANTY, to the extent permitted by law.
   You may redistribute copies of avra under the terms
   of the GNU General Public License.
   For more information about these matters, see the files named COPYING.

Pass 1...
make: *** [afro.hex] Error 1

Just a side-note: since upload are deprecated on Github: https://github.com/blog/1302-goodbye-uploads. Would it be possible for you to upload all the hex files every time you tag a release instead? See: https://github.com/blog/1547-release-your-software.

Then people will be able to download all the hex files here: https://github.com/sim-/tgy/releases.

Thanks a lot for you hard work. I just bought my first quad and it flies really great. You code really made a lot of difference to the performance!

Auto-detect feedback RC constant on startup

This firmware works best with capacitor values ~20x smaller than are found on almost all ESCs. However, this could be tuned for by adjusting the new TIMING_OFFSET feature. It could be calculated as follows:

Turn on channel A,B,C Low-side.
Wait ~1ms for all capacitors to discharge
Turn off channel A Low-side
Wait ~20us for FET to switch (larger than necessary, to be safe)
Turn on channel A High-side
Wait ~1ms for capacitors to charge and virtual neutral to shift
Turn off channel B Low-side
Wait ~20us for FET to switch
Start timer
Turn on channel B High-side
compare on channel B vs virtual neutral
Capture timer value on crossing. This should be an accurate representation of the delay from the capacitors and FET switching.
If it takes more than 1 ms cut out for safety reasons, assume timer value of 0 or give an error

Edit:
This process actually measures the delay that the switching and capacitors cause in similar conditions to what is happening when the motor is running, so it should be more accurate than the other way I was doing it.

Minor Afro ESC 20A flashing trouble (caught fire)

I recently purchased 4 20A Afro ESCs to use with a RaspberryPi for flying a quad.
Since I'm planning to use the I2C interface, I needed to flash the ESCs to change their address.
However, while attemping to flash, my ESC caught fire :(
I read the related issue with comments https://github.com/sim-/tgy/issues/26#issuecomment-27143261 and realized that I had done the same mistake - connected a LiPo battery (3S1P) to the ESC to power it while flashing..

Could you please elaborate on what you mean when you say 'Power the ESC from a current-limited supply' :(
Having scourged the Internet all day, I still don't know what the right setup is to flash the ESCs

Alternate braking FETs in COMP_PWM

Right now only the top FETs do braking duty during COMP_PWM. It would be better if this was alternated between top and bottom FETs to spread the load, and it would also charge the bootstrap capacitors better for NFET based systems.

Need ESC frimware to work on 328P instead of 8A

Hi Simon,
I'm building my own esc, and I tried loading the frimware on a board I have with a 328P instead of 8A. I noticed that the pinout is identical so I thought that if i upload the firmware to the 328P and set the right fuses then it should work. But it doesnt show signs of life.
(avrdude -c usbasp -p m328p -B100 -b9600 -U lfuse:w:0xff:m -U hfuse:w:0xdc:m -U efuse:w:0xfd:m
avrdude -p m328p -P usb -c usbasp -B 8 -e -U flash:w:C:\Download\flash\tmp\tgy-master\rct50a.hex:i
Of course I can change back to an atmega 8A, but before i do it, I was wondering why this doesnt work, and if it is little effort would it be possible to make a rct50a.hex for this?

Blueseries 30A with mulitstar 690kV fails during operation

Actually truth said, I have been using this ESC for quit a while now almost a year. And this weekend all of a sudden the ESC stops working in midair. Clearly upgraded with Simonk firmware. However it has been giving me signs, I could see the gopro video twitching, and small oscillations on the quad when flying. I was convinced it had to be one of the motors. But I found out the hard way it was an ESC failing.
After examining the schematic, I couldn't help to notice that the AVR is directly driving the Low side Power MOSFETs. Now that the frequency is significantly higher ~18kHz, I tend to think this could be the cause of the failure... I believe the driver is not capable of delivering so much ac current at such high frequency, but that it must be beyond its limits. Truth said there is some resistance before the gate, but once grounded the first spike of current is significantly higher than the DC specified in the spec of the 8A (40mA). However I still have to confirm this theory. Im going to replace the AVR on the failed device and reflash it, then see if this is what failed. In any case, I do not believe anything else could have failed. My avg current was way lower 30A, ~6A. After looking at the power FETs they all look ok, but I will give you more ifno as soon as the new AVRs arrive.

missing i2c communication protocol description

Hi, You've done good job! I want to build tricoper and control ESCs through i2c. There is one obstacle, I can't find any description, what do I have to send to ESC and what can i get. You are referring to BL-Ctrl, but I can't find any useful information.
Can you describe content of bytes, that ESC need to get to understand me?

Thanks a lot!

Complementary PWM on HK F30A possible ?

COMP_PWM is set to 1 for Maytech 30A's. I read that these are very similar to HK F-30A's. I currently use wii-esc with complementary feature enabled on F-30A's and noticed more stability with that. So i would like to have this feature also for the bs_nfet.

Is there a reason why it is not activated for the bs_nfet build, or can i use it without problems (and hopefully achieve the same results as wii-esc) ?

(Sorry for accidentally posting issue twice. #40 may be removed)

BRAKE_SPEED = 8 : Constant out of range

Hi Simon,

First - I'm really enjoying using and learning from this code! Superb work!

Here's an issue I've found, and I wanted to check the solution with you.
If we set braking to maximum (ie 8 as suggested in the commentary) then
tgy.asm(line:2657) ldi YL, 1 << BRAKE_SPEED
returns a warning tgy.asm(2657) : Warning : Constant out of range (-128 <= k <= 255). Will be masked
which makes sense as 1<<8 === 256.
I don't know how AVRA is applying a mask and don't want to risk an undesired setting, so should we update the code to ldi YL, (1<<BRAKE_SPEED)-1 which would then give settings of : 1,3,7,15,31,63,127,255 rather than 2,4,8,16,32,64,256?

Thanks!

Afro ESC & Multistar 4220

Synchronization failure, with sharp movements of the kvadrokoptera.

Turnigy Multistar 4220-650Kv 16Pole Multi-Rotor Outrunner.
Afro ESC 30Amp Firmware: afro_nfet.

DL40A++

Hi, I have 4 Pulso DL40a++, how can I tell if they are supported by the firmware ?
It is not in the various lists of supported ESCs, but I was wondering
if anybody knows if it is identical to some other and thus is supported under
a different firmware name.
Thanks,
Lorenzo

NTM 3530 constant problems

Hi, I'm using a self-made bldc esc, the wiring is similar to the RedBrick 50A and I'm having issues with the NTM 3530 1400kv motor. I've tried setting COMP_PWM on and off, playing with motor advance and so on but I always have issues with fast acceleration from let's say 10-15% to max throttle when in most cases the motor dies completely. I've done the test on a two quadrant power bench supply @ 15V (almost nominal voltage for a 4s battery).
I've also tested a HDD motor and a EMAX CF2805 motor (@ 11V - 3S battery) and with a little tweaking they worked as they should. Has someone tested this motor with a different ESC and with a SimonK software version? Really want to know if it's worth the trouble or should I try different motors.

rc-car mystery cloud50A/80A problem

hi all, mybe is usefull for all, i have this issue in my rc car after flashed the esc:http://youtu.be/6DRZenkfw3Y ..it appens sometime randomly when the car is near, and ever when is about at 50meters and over, as Simon i think could be the rc signal input dirty, or grownd reference problems, but why with original firmware this not appens? .. when the motor can start nothing can stop it :D very powerfull and better than original control! only this start problem, no1 had this in the past? thanks

added info: the bip when rc signal lost is deactivated in the fw settings

with 3s battery when i use the car in 20 meters around transmitter the problem not appen, when i go over it block my car beeping until a random start or i must go near to take the controll, if i use 6s lipo the problem appen near too

12/04/2013 from the last try: until the motor is running i can use my car in entire transmitter rage, if the motor stop running the esc can't recognize se signal coming from the receiver (i see sometime start in backward when i give forward command) .. i wait for resolve this, mybe in a quadcopter it dont uppen because motors dont stop far from transmitter

Sunnysky 2204 2300Kv stutters at full throttle with COMP_PWM enabled

On one of my mini qauds I have been running 2014-3-6 with COMP_PWM enabled. It flies very well and displayed no problems but while doing some testing with props removed I noticed that at full throttle the motors stutter. They don't stall completely but just stutter. I never noticed while flying because I'm rarely using full throttle. I downgraded to 2013-5-15 with COMP enabled and the same thing. Stuttering at full throttle. I re-flashed with 2013-5-15 COMP disabled and no stuttering. The problem is that without COMP I do notice less stability but I'm afraid to use it. Is this a correctable issue? Is it a known issue?

Low Voltage Cut Off

Would it be possible to add a low voltage cut off? (or goto half throttle when too low) like you would normally find in a car ESC?

I am wanting to use a Hobbyking F-30A ESC in an airboat.

Active braking feature (for multicopter)

I'm interested in an active breaking feature (for multicopter).
As far as I understand COMP_PWM = 1 enables active freewheeling which helps braking a bit.
You already implemented the "Enable brake during neutral/idle (MOTOR_BRAKE = 1) Feature".
Do you have any plans or is it possible to extend it to "real" active breaking (not only when idle) ?

Hobbyking Series SS 15-18A

The Hobbyking SS Series 15-18A ESC is listed under the tgy build target in README.md, but it should be listed under the tp build target.

afro30 esc and turnigy 4822 690kv

Hi.
The turnigy 4822 690kv motor looses sync in flight with the default afro 30 esc.
I just flashed one afro30 esc with the newest available binary release 5/2013 (afro_nfet.hex) and now the red led blinks often at low speed and stays off at higher power but sometimes it lights up when i move the throttle rapidly.
With the stock firmware the red led stays off all the time even when the motor looses sync.
To be honest i haven't tried it in flight because last time i crashed because of motor twitching.

Afro 30A w/ NTM 28-26 1200kv fails under high load

The afros are flashed with the newest firmware and I've tried a lot of different settings. But they all, more or less, fails under high load. Fails as in loosing the sync and just flipping out for a brief moment. Sometimes they brake so hard that they start to reverse. Running 3s LiPos. Only happens with the prop mounted (8x4.5) at about 70% throttle or more.

I've tried changing the timing, turning I2C and UART on and off, changing POWER_RANGE, COMP_PWM...

Are the motors crap? Or am I doing something wrong?

External signal for throttle?

Would it be possible for an external switch (open/closed) to be used to change the throttle setting of the ESC? For example, when the switch is closed, have the throttle move to 100%, and be at 0% when the switch is open. This would allow an esc to be used in a toy/replica airsoft gun, integrating the simple on/off trigger system instead of the power standard range input from a receiver.

This is similar to how MOSFETS are used currently with brushed DC motors in airsoft guns.

Tarot 4006/620KV out of sync on quick throttle-up

Hello Simon,

my setup:

Afro 30A ESC (afro_nfet), Tarot 4006/620KV 22-pole motor, 1355 carbon prop, 4S LiPo.

All goes smooth after slow throttle changes, but once I quickly push the throttle, motor loses sync (red LED blinks, weird sound, loss of power and rpm).

The problem is much more present when using 400Hz input (Naza controller). When using 50Hz input (raw RX output), it is hard to reproduce, but is still there.

I will very very very appreciate any advice.

Dave

Motor whine when using COMP_PWM

I recently flashed 3-6-2014 with comp enabled. I'm using blue series ESCs with tiger 2216 1100kv motors. I noticed quite a bit more whine from the motors than before enabling comp. JUst as an experiement I tried flashing 5-15-2013 with comp enabled and it might be my imagination but the noise, while still there, seemed less loud. Is this possible? Is there any reason to be concerned about the noise? Motors seem to run cool as do the ESCs.

HobbyKing Red Brick 30A ESC - now with Atmega88

Hi, since a few weeks Hobbyking delivers the Red Brick 30A ESC with a Atmel MEGA88-15AT1. The ESC looks excatly like one with the Atmega8 I noticed it when I want to connetct the ESC with my PC and start read with eXtreme Burner to test the connection. Is it possible to compile the tp.hex/tp 8kHz.hex for the Atmega88 becuause there are differences in the programm adress, i/o register ...? Many people buy this ESC but the stock firmware does not work (wrong timing, stop working after wrong timing,overheating e.g. http://www.youtube.com/watch?v=nnYPddIUTcI)
I hope you can help us.

Thanks in advance!

[feature req] Brushless Camera Gimbal Mode?

Is it at all possible to use this firmware as a basis for creating a brushless gimbal controller? If the power side of things is capable of driving the motor in the required way then I'm thinking it might be possible for the controller to talk i2c to a gyro mounted on the camera and perhaps talking to a second esc (controlling a separate axis) in some sort of slave mode.

The answer might be obvious but I haven't seen it discussed at any level of detail, and with ESCs and gyros/IMUs/Nunchucks being pretty available and affordable it might be a good option.

The three main questions I guess are:

(a) Can the hardware physically drive a brushless motor in the required way
(b) Is it something best forked to a separate project, or would there be any advantage in having it a custom build mode to take advantage of the project's knowledge about different ESC configurations
(c) is there enough cpu time for it to do the math or does controlling the motor pretty much dominate all available cycles

Any thoughts?

Could we add feedback to the flight controller through SPI?

I was wondering if it would be possible to add feedback to the flight controller perhaps reusing the SPI ports used for programming the AVR (we'd need to leave wires connected to those ports after programming). This would be useful to allow more sophisticated controllers to check the status of the ESC (i.e. temp overload, low voltage, motor RPM, etc).

-Randy (DIYDrones Arducopter dev team)

tgy_debug firmware

Hello!

Is there any plans to add tgy_debug firmware to the code tree?

RCTimer ESCs with external oscillators seem to use it, but it's not available publicly, no updates etc.
Or i can just change frequency to 8Mhz and it's good to go?
I think it'll use internal oscillator for clocking with tgy.hex, and not external crystal.

Thanks in advance.

Running a motor by connecting power

Hi SimonK, I looked over your asm-file but was not able to find a way to start the motor instantly without going first to "zero". Could you please point out the right place or implement a switch?

On one hand it's a bit dangerous, but on the other it should make flying a lot safer. I think I had two power cuts on a quad that led to a crash because at least one motor wouldn't start up again.

Sync issues on latest firmware on Afro 12A and Multistar 380kV

I'm having sync issues with 4 Multistar 380kV motors I have on my quad. They keep randomly loosing sync and the crashes have caused me no end of grief.

I'm running 4S with 17" props on AfroESC 12As.

The ESCs have self-compiled latest firmware with COMP_PWM.

change arming melody

hi,
is there a way to modify the code so to make, for example a patch, to modify/change the sounds-melody of the esc when arming?

what lines do i have to look? i'm not really experimentated with compiling this kind of software.

thanks for any help

SUNNYSKY X3508S 700KV

Hi

I have this motors SUNNYSKY X3508S 700KV and has sync issue with Afro 30amp by HK. And next problem is compatibility with DJI Naza - M
Which firmware is good for this motors?

UART Mode on BS_NFET doesn't work

I've tried to use a HobbyKing 30A BlueSeries ESC in UART Mode.
The RX pin of the ESC is onboard connected to the RC control wire.

AFAIK the UART sequence should look like this: 0xF5 0xAA 0xBB 0xCC 0xDD ...
(AA = Value for Motor 1, BB = Value for Motor2 ...)

But if I try to send such a sequence (e.g. 0xF5 0x20) to the ESC, then the motor won't speed up. MOTOR_ID is set to 1. INT0 Mode works perfectly on this ESC.
Debugging with DEBUG_TX showed, that the sync byte (0xF5) is accepted and in the SRAM
rx_h, rc_duty_h and rc_duty_l is correctly written, but not the registers duty_h and duty_l.
Probably the ESC isn't armed (Where is the flag for this?), but I don't have an idea how to change this. The SET_DUTY flag isn't set as well.
If I send the value 0 (0xF5 0x00) to the ESC, then the signal lost beacon gets active. If I send a value from 1 to 100, then it works. I don't believe that this is intended or I just totally missunderstood the code.

I would be glad, if you could help me. Thanks!

Turnigy Multistar 20 Amp (OPTO) Sync Loss

Hallo Simon !

First of all, let me tell you how much I appreciate your work and the great job you are doing with code writing!

I have incredible sync loss with Turnigy Multistar 20 Amp Multi-rotor Brushless ESC 2-4S (OPTO) and Turnigy Multistar 2213-980Kv 14Pole Multi-Rotor Outrunner .

I have tried the Turnigy L2210-1230 Bell Style Motor (150w) and I have the same problem !

I have tested all your keda firmware and actually I have resolved flashing the Multistar with other type of open firmware !

Maybe a Timing problem….

James.

How to compile?

Simon,

I've been using avra and avrasm2 and it gives me a list of errors regarding the latest firmware. Specifically the m8def.inc file with unknown macro's. Should I be trying the latest AVRstudio and copying the latest avrasm2? I can only use the 1.2.3 avra due to no binary for windows on 1.3.0.

dedicated H-bridge-driver

Hi Simon,
after studying the afro-esc i asked myself if it's efficient enough to use such a minimal approach on driving the high-side n-fet instead of a dedicated driver for a half-H-bridge.
What do you say?
The 3 phases can not get near V_in and the high-side n-fet is getting noticeable warm because the fet is not completely on all the time.
With just 1$ for 3 drivers the afro30A-ESC could be rated with 60A.
Am I wrong?

Turnigy 4220 650kv - Sync issue on every firmware

I have 4 Multistar 4220 650kv motors that are causing me no end of grief.

Originally purchased with 20a Afro's and kept crashing. Flashed with latest firmware, made the situation worse.

Figured I'd try bigger ESC's so spent more money on F30a's flashed with SimonK, and the result is as follows:

http://youtu.be/XGV8F3yoW0k

I have about £900 sunk into this thing and cannot fly it without it crashing. I have tried the three latest bs_nfet firmwares listed in kkmulticopter tool, and am about to take a hammer to the whole lot because nothing seems to be sorting the problem. I just want to fly the damn thing... Please help.

big motor problem

hello,

i have a bike-hub-motor(approx 80 poles) and i want to use a HobbyKing Multistar 45A for powering this thing.
only problem is that it wont turn faster than appox 1,5hz (90rpm)
i have tried to change some settings, but not much helped,
what did help was, set MOTOR_ADVANCE to 30 and all PWR_MAX_**** to MAX_POWER

any ideas? (I only need it to turn around, not for cycling)

Afro 30 A esc's & Turnigy Multistar 4220-880Kv

hi wondering if some one may be able to help guide me in the way to re-flash a Afro 30amp esc as i haven't flashed one before ,, have issue with motors (Turnigy Multistar 4220-880Kv ) cutting randomly unable to fly ,, have put it down to the esc loosing the motor ,, i get a red flash from the esc when one of the the motor cuts, this is stressing me out , spent so much time trying different things ,, any help ,, regards Bart

Hello!

help, how to get kda_nfet.hex

Tgy Multistar 422-390KV / Afro esc HV / 15x5.5 CF prop / 6S 5800mA/ 2Kg tricopter

Some background; I have had some problems getting the above to fly reliably. I have narrowed the problem down to the parameters in the firmware. I am using the latest master through the kkMulticopter Flash Tool. Took me some time to get the boot loader enabled on the Afro Esc, have left a friendly note to HK to this effect.

Overall, it flies beautifully. Using 8A on hover. Gives me 30 minutes+, except that one cell is getting poor at the moment. This must be my fifth generation tricopter. The focus is to get long flight times and not exceeding 2.5Kg.

There were issues with the wiring to the motors, HK had just extended the coil wiring (?) and they failed at the connector side (cost me $$).

The problem is that the motors just stutters on large throttle changes, hence I am pitting this up here.
and searching the web shows little in terms on how to fix this. The best advice I initially found was to change POWER_RANGE, but this causes a ramp up issue (and a hard landing). However, I am at 1300 now. From stand still, if I give full power, it just flips over. However, from a hover start, it takes off like a rocket. Lots of ooh and aaah from the audience. Note that auto tune from the the laters APM causes me to crash.

The strategy now is to change the TIMING_OFFSET, I have found some references to setting it to between 5-12 from a German website.

The big question is, am I completely out for lunch on this approach? I have no with to re-engineer anyones code, but would be good to have a tool like ecalc for simonk firmware where we could put in some overall parameters and it could advice on the some brackets of parameters to put in.

Any suggestion(s) is greatly appreciated.

Thx,
bighans

HIGH Pole Count Motors Cogging Issue

HI Simon,
Any news if this issue has been solved? Or any new news which helps us to determine which version would be best to use for high pole count motors? I have a 22Pole, and I am wondering which version should i use?
I've noticed that there are not any new versions since this issue was detected. So just wondering if there was any progress on the root cause analysis, and of a potential solution.
Thanks
Sp1k3

RED BRICK 50A with atmega 48

Hello to everyone,

HK has started to sell RBricks with Mega48 wich maybe is less expensive , but the only way to flash is to change the chip with Mega8. A little tricky job. That"s why I was wondering if it is possible to flash and this "new" Atmega48.

regards
nikitz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.