Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

several patches that mean a dramatic power reduction while in idle/armed + neutral #102

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

msperl
Copy link

@msperl msperl commented Nov 3, 2015

Several patches that mean a big power reduction while the ESC is not running the motor:

  • implement idle sleep
  • implement adc-sleep (4096us timer is simulated via ADC interrupts)
  • implement green-led PWM while not running
  • implement an option to put FET into a low power configuration

Results:

  • afro-nfet:
    • stock (1e4c017):
      • 45.2mA idle - no PWM
      • 53.5mA armed - with neutral PWM (difference to no-pwm is mostly green-LED)
      • 2094 Words
    • USE_SLEEP=2 and USE_LED_PWM=3:
      • 35.6mA idle - no PWM
      • 39.8mA armed - with neutral PWM (difference to no-pwm is mostly idle-sleep vs. adc-sleep)
      • 2177 Words
    • USE_FET_* = 1 + all sleep and led optimizations
      • 19.9mA idle - no PWM
      • 23.5mA armed - with neutral PWM (difference to no-pwm is mostly idle-sleep vs. adc-sleep)
      • 2198 Words
  • tgy.inc:
    • stock (1e4c017):
      • 48.9mA idle - no PWM
      • 47.4mA armed - with neutral PWM (surprisingly this consumes less power)
      • 1773 Words
    • USE_SLEEP=2 and USE_LED_PWM=3:
      • 33.7mA idle - no PWM
      • 38.8mA armed - with neutral PWM (difference to no-pwm is mostly idle-sleep vs. adc-sleep)
      • 1839 Words
    • USE_FET_* = 1 + all sleep and led optimizations
      • not applicable, but there may be some low hanging fruit - see the stock reduction when armed!)

Note that the implementation is using adc, which can also get extended to allow for continuous ADC capturing while the motor is running and does not produce glitches at high RPM!

Also regular ADC reading has been implemented allowing to capture a sequence of ADC values also when the motor is rotating. There is still the need for a consumer - i2c comes to mind...

Measurements [email protected]:
* sleep = 0
  * 48.3mA no PWM/PWM (no PWM generator)
  * 56.4mA PWM neutral armed (including PWM-generator)
  * 1761 Words
* sleep = 1
  * 38.8mA no PWM (no PWM generator)
  * 46.7mA PWM neutral armed (including PWM-generator)
  * 1776 Words
* reduction of 9.5-9.7mA
* change
  * -9.5mA no PWM (no PWM generator)
  * -9.7mA PWM neutral armed (including PWM-generator)
  * +16 Words

Measurements [email protected]:
* sleep = 0
  * 44.9mA no PWM/PWM (no PWM generator)
  * 60.6mA PWM neutral armed (including PWM-generator)
  * 2086 Words
* sleep = 1
  * 37.8mA no PWM (no PWM generator)
  * 54.3mA PWM neutral armed (including PWM-generator)
  * 2101 Words
* change
  * -7.1mA no PWM (no PWM generator)
  * -6.3mA PWM neutral armed (including PWM-generator)
  * +16 Words
reduces code we need to maintain
Allow the use of USE_SLEEP=2 to mean we run with ADC-sleep when idle

As the timer does not work in adc-sleep, we use the extended
ADC conversion to simulate the 4096us overflow interrupt of T1.

Measurements [email protected]:
* SLEEP = 0
  * 48.9mA idle - no PWM
  * 47.3mA armed - with neutral PWM
  * 1773 Words
* SLEEP = 1
  * 38.8mA idle - no PWM
  * 38.8mA armed - with neutral PWM
  * 1789 Words
* SLEEP = 2
  * 33.7mA idle - no PWM - requires PWM pulldown!!!
  * 38.8mA armed - with neutral PWM
  * 1839 Words

Measurements [email protected]:
* SLEEP = 0
  * 45.2mA idle - no PWM
  * 53.5mA armed - with neutral PWM
  * 2094 Words
* SLEEP = 1
  * 38.4mA idle - no PWM
  * 46.9mA armed - with neutral PWM
  * 2110 Words
* SLEEP = 2
  * 35.6mA idle - no PWM - requires PWM pulldown!!!
  * 46.9mA armed - with neutral PWM
  * 2170 Words
When armed and in neutral my afro-esc consumes (with USE_SLEEP=2):
* USE_LED_PWM = 0 - 47.4mA
* USE_LED_PWM = 1 - 43.1mA
* USE_LED_PWM = 2 - 40.9mA (flashes already)
* USE_LED_PWM = 3 - 39.9mA
* USE_LED_PWM = 4 - 39.3mA
* USE_LED_PWM = 5 - 39.1mA
* USE_LED_PWM = 6 - 38.1mA

so there is some power that can get saved by implementing that
This sets up the FET in such a mode that we save on power consumption

Example config for afro_nfet:
.equ	USE_SLEEP	= 2
.equ	USE_LED_PWM	= 3
;*****************************************
; ENABLE_LOW_POWER_FET_MODE during sleep *
;*****************************************
.equ USE_FET_SET_LOW_POWER = 1
.MACRO FET_SET_LOW_POWER
	cbi AnFET_port,AnFET
	cbi BnFET_port,BnFET
	cbi CnFET_port,CnFET
	cbi ApFET_port,ApFET
	cbi BpFET_port,BpFET
	cbi CpFET_port,CpFET
.ENDMACRO

.equ USE_FET_RESET_LOW_POWER = 1
	.MACRO FET_RESET_LOW_POWER
	cbi AnFET_port,AnFET
	cbi BnFET_port,BnFET
	cbi CnFET_port,CnFET
	sbi ApFET_port,ApFET
	sbi BpFET_port,BpFET
	sbi CpFET_port,CpFET
.ENDMACRO

This results in:
* stock (1e4c017):
  * 45.2mA idle - no PWM
  * 53.5mA armed - with neutral PWM
  * 2094 Words
* USE_SLEEP=2 and USE_LED_PWM=3:
  * 35.6mA idle - no PWM
  * 39.8mA armed - with neutral PWM
  * 2177 Words
* USE_FET_* = 1 + all sleep and led optimizations
  * 19.9mA idle - no PWM
  * 23.5mA armed - with neutral PWM
  * 2198 Words
This implements 256 x ADC oversampling with 2 bit decimation
to result in a result value range of [0:65472]

There is also some scaling offset calculation that can get applied
to the gathered values.

when USE_ADC = 1 is set then we look for defined:
* mux_temperature
* mux_voltage
* mux_current
and calculate the mask of adc channels to use.
Alternatively USE_ADC_MASK can be set to a bitmask of the ADC channels
to capture - note that there are no Channels 8 - 13, so if any of these
bits are set the build will fail .

For example with afro_nfet on can define:
.equ	USE_ADC = 1
.equ	mux_voltage_mul	= (5*256*(18000+3300)/3300)
to get the voltage scaled correctly to: Vbat*256

Note that typically an oversample of a channel takes:
0.1037s for a motor running at aprox 1400 commutation cycles/s
0.0282s for an unarmed ESC

note that when armed the sample rate may go as low as 1 second -
especially when braking or accelerating.
Also there is no sampling happening while the ESC is "beeping"!

Last thing missing is exporting those numbers via I2C...
This already includes definitions for ADC value transformation
This will load a generated translation of ADC to a temperature value
from flash into SRAM for later use by the ADC translation layer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant