-
ATTiny84A Low power mode
01/19/2022 at 20:53 • 0 commentsSleep and wakeup
Mode with lowest power consumption is power down mode. The MCU can be woken by e.g. a pin change interrupt.
At wakeup, the interrupt handler is executed, then the code continues where it left of before sleeping.
Pull-ups
Pull-up settings remain valid during power down mode. So you can leave out many pull-up resistors.
Software reset
The software reset is executed by first enabling the watchdog timer with minimal time interval, followed by running an endless loop. The first thing the setup() function should do is disable the watchdog again.
Peripherals
Internal ATTiny peripherals can be powered down to limit current consumption. Don't forget to re-enable them after wake-up or your code won't run correctly.
-
Secondary light source
01/10/2022 at 21:04 • 0 commentsUltra-violet
- VLMU3100-GS08 (datasheet) : 3.2V/20mA
With 30mA through the LED, there's enough UV-light to inspect your hotel bathroom when other lights are turned off. The downside of this LED is the high forward voltage. It's in the range of the Li-Ion supply voltage as it drops during discharge. For the sake of circuit simplicity, we'll use 2 UV-LEDs in series and use a boost-converter to power them.
RGB
- WS2812B
- Control by one GPIO, no PWM or large inductor needed.
- VCC=3.5 to 5V : can be directly powered from the Li-Ion battery
- provides many colors
- MCU must run at ≥ 8MHz
- tested and verified on PIN_PB1.
- consumes 500µA to 1mA when LED is off, depending on power supply voltage
Always ON LED
- Lumileds Luxeon 3535L L135-L567003500000 : 3.1V/100mA
- Very efficient for very low currents
- see Ultra low power LED
-
Debugging
01/05/2022 at 21:02 • 0 commentsSerial output
If you want to read the value of a variable inside your MCU, the easiest option is to just print it on the serial port.
TX-pin is PIN_PA1.
Calibrate your MCU-clock
- Set the fuse to enable clock output on PIN_PB2.
- Use a frequency counter (or an oscilloscope) to measure the frequency.
- When it's not correct you can adjust the frequency using the OSCCAL-register:
void setup() { OSCCAL-=4; }
Disabling RX
void setup() { OSCCAL-=5;//999.178kHz Serial.begin(4800); //Disable Serial RX ACSR &=~(1<<ACIE); ACSR |=~(1<<ACD); } void loop() { Serial.print("Hello"); delay(1000); }
-
Microcontroller
01/04/2022 at 20:57 • 0 commentsFor this a low power, low performance application. My go-to microcontroller is the ATtiny84A:
- Wide input voltage range (no need for 3V3-LDO when powering by Li-Ion)
- Plenty of peripherals (I²C, SPI, timers,...)
- built-in EEPROM
- no UART (but SoftwareSerial possible)
- enough GPIO
- SOIC-package which is easy to hand-solder
- Arduino & PlatformIO support
- previous experience with AVR-family
- 100nA shutdown current
-
Getting started with ATTiny84A on PlatformIO
01/04/2022 at 19:26 • 0 commentsTools
- Development board. I use the Konijntje-thermo-humi board from a previous project.
- ISP programmer. I use the Atmel AVRISP MkII
PlatformIO setup
- Create a new project and select "Generic ATtiny84 (Atmel)". The Arduino-framework will automatically be selected.
- Adjust the platformio.ini file:
[env:attiny84] platform = atmelavr board = attiny84 framework = arduino upload_protocol = avrispmkII upload_port = usb ; https://www.engbedded.com/fusecalc/ board_build.f_cpu = 1000000L board_fuses.lfuse = 0x62 board_fuses.hfuse = 0xD7 board_fuses.efuse = 0xFF upload_flags = -B ; bit clock needs to be slowed down (original=1) when underclocking the MCU 10 lib_deps = stevemarple/AsyncDelay @ ^1.1.2 thomasfredericks/Bounce2 @ ^2.70 ; FTDI TTL-232R-3V3-WE monitor_port = /dev/ttyUSB0 monitor_speed = 4800
- Simply hit the "Upload"-button to program your device.
That's it. No makefiles, no menu configs.
Remember to upload your code again after programming the fuses (if needed).
Here goes the blinkenlight example:
LED_BUILTIN = PIN_PB2
#include <Arduino.h> void setup() { // put your setup code here, to run once: pinMode(PIN_PB0, OUTPUT); } void loop() { // put your main code here, to run repeatedly: digitalWrite(PIN_PB0, HIGH); delay(500); digitalWrite(PIN_PB0, LOW); delay(500); }
framework-arduino-avr-attiny
More info about the framework (and the pin numbering) can be found on:
-
LED driver
12/20/2021 at 20:58 • 0 commentsDriver for main light source
The selected light source is a 12V LED-COB panel. There are not many circuit options to consider here. A boost converter will do the job just fine. In the current component shortage situation, we'll have to look for a solution that allows for multiple second source components.
That brings us to the following:
Pin list :
- SW : Switch
- AP3031 : 1MHz, max. 1.4A
- RT4533 : 1.1MHz, max. 1.2A
- FAN5333A : 1.5MHz, max. 1.5A
- MP302DJ : 1.3MHz, max. 1.3A
- MIC2291 : 1.2MHz, max. 1.2A
- GND
- FB : feedback voltage :
- AP3031 : 200mV
- RT4533: 200mV, RT4533A=300mV
- FAN5333A: 110mV
- MP3202 : 104mV
- MIC2291 : 95mV
- CTRL : enable pin: high = ON
- OV : over voltage protection
- AP3031 : max. 17.5V
- RT4533=36V
- FAN5333A, no over voltage protection, only 15% over current protection
- MP3202 : 28V
- MIC2291Y : not present
- VIN : input voltage
- AP3031 : 2.7V→16V
- RT4533: 2.5V→5.5V
- FAN5333A: 1.8V→5.5V
- MP3202DJ: 2.5V→6.0V
- MIC2291 : 2.5V→10V
Sources :
AP3031KTR-G1 has a 50µA quiescent current (CTRL=0V), so an external FET will be needed.
- RT4533GJ6 : 300nA quiescent current (EN=0V). Sold out Digikey end of 2021.
- FAN5333ASX: 100nA quiescent current (/SHDN=0V), but 1µA switch leakage? (2023: obsolete)
- MP3202DJ : 100nA quiescent current (VEN=0V)
- MIC2291Y : 100nA (VEN=0V)
Driver for secondary LEDs
The UV-LED has a forward voltage of up to 3.8V, while the Li-Ion battery is only 3.6V.
Reusing primary LED driver
We can cut costs by reusing the LED-driver for the main LED-string. The sense voltage is 200mV for the AP3031, which is quite a low voltage. This enables us to use NMOS-FETs to switch the LED-strings without need for gate bootstrapping.
By the arrangement of the sense resistors as shown in the picture, we can make each LED string work with a different LED-current.
Design consideration : Linear LED driver
We need a sense resistor in series with the LED. This causes an extra voltage drop, which requires a higher supply voltage. The 5V booster could be used to provide power for the linear LED driver. It's there already anyway.
The problem with this approach is the rather limited efficiency, both of the 5V booster for such low currents and of the nature of the linear LED driver itself.
An LMV321A opamp-current source with an FDV301 drive transistor and with 100mV over the sense resistor doesn't allow for the full 30mA output of the LED. At least 3.4V is needed. To be able to dim it, independent of the supply voltage, an extra voltage reference is needed. This is becoming a bulky circuit.
The AP2502 could be used instead, but unfortunately it's a single source component.
As it turns out, this circuit will cost more (both in money and PCB-area) than using the AP3031 with two UV-LEDs.
Design consideration :Switching LED driver
See #TritiLED for more info.
This is the basic circuit of the switchable LED driver. NMOS-transistor M1 conducts, causing the current through L1 to rise. When M1 stops conducting, L1 will dump its magnetic energy inside the (blow-back) LED D1.
A trade-off has to be made between the switching frequency and the inductor value. Smaller inductors are cheaper but require higher switching frequencies, which the MCU might not be able to deliver.
This circuit has limited dimming range. The pwm-resolution is 0.125µs. The maximum ON-time is around 12.5µs (50mA peak, 4V power supply, 1mH inductor). Which means we have a dimming ratio of only 1:100.
The ON-time regulation is very tricky in this circuit. If the ON-time is too long (software bug or glitch), we'll end up blowing up the mosfet and the inductor.
As a result this circuit will only be used when the NMOS is controlled with a fixed duty cycle.
Design consideration :Switching LED driver with selectable LED-output
The design will feature several LEDs, but we don't want a separate driver for each LED. That would add too much cost and PCB space. Using the following circuit, V3 selects whether to light D1 or D2. When M3 conducts, D1 will be lit. When M3 is off, D2 provides a blow-back path for the energy in L1. This only requires one extra NMOS-transistor. Several D1/M3 stages could be added in parallel to D1/M3 to allow for more selections.
The problem with this last circuit is that it no longer works when the supply voltage is higher than the LED forward voltage. If M3 is ON, then D1 would be conducting, even in the idle state (when M1 is off for a long period of time).
- SW : Switch
-
Charging output
12/07/2021 at 20:02 • 0 commentsAs a power bank, this device should be able to supply 5V/1.5A, because that's what each of my tablet and phone are drawing during charging.
Dedicated power bank ICs exist that incorporate a boost converter and battery charging and protection circuitry (Thinkplus MP5043/MP5045, Hotchip HT4936S & PB0059E, Injoinic IP5306). These don't need many external components. The main drawbacks are their limited output current capability and they turn off when the output current is too low.
Another option is to design our own PCB using DC/DC-converters available : FeelingTechnology FP6276, FP6293, FP6298 or XYSemi XR2981. Designing our own power supply board would take more time.
Option 1: 5V/3A boost converter
AliExpress 5V 3A DC-DC Step Up Power Module : €1.03/pce
Uses Xysemi XR2981 boost converter., can also be found as H&Msemi HM9228B (hmsemi.com)
- A TPS2514 will be needed on the USB-data lines to tempt the devices into drawing 1.5A instead of the normal 500mA.
- Tablet : with tps2514 : 1.35A, without : 0.476A
- smartphone (after a few seconds) : with tps2514 : 1.18A, without : 0.457A
- The no-load input current is 150µA (at Vin=3.7V).
- There seems to be very little filter capacitance on this board. Ripple will likely be quite high.
- The schottky diode has a Vf of 335mV at 1A and 359mV at 2A.
- Inductor Rdc = 11mΩ
The measurement stopped at an input current of 3.5A, which was the maximum for my lab power supply.
Option 2 : Qualcomm QC2.0/3.0 Fast charge module TPS61088A
AliExpress TPS61088 Boost power module : €2.21/pce
This module is more expensive, but it has the potential of faster charging by boosting the USB-voltage to 12V:
- 5V/3A : a Blackview cellphone and Samsung Galaxy tablet settle for this mode, drawing 5V/1A.
- 6.2V (=QC3.0) : used by cellphone BQ Aquaris X Pro
- 9V/2A
- 12V/2A
The no-load current is 548µA with a supply voltage of 3.7V. The EN-pin of the TP61088 is hard connected to VCC. Even disabling the TPS61088 would still leave us the 200µA current draw of the FP6601Q.
UVLO falling is 2.4V after which 0.5A is drawn. If the input voltage rises again above 2.6V, normal operation is resumed.
The TPS61088 is a synchronous boost converter, which minimizes losses that would otherwise be caused by the schottky diode. There's also a larger inductor used here, which probably has a lower Rdc than the one in the 5V/3A-module.
The measured efficiency matches the TPS61088A datasheet very well.
To be able to test it with an electronic load, I ordered a QC2.0/QC3.0 tester (AliExpress QC2.0 tester : €3.53/pce).
A better USB tester is the Fnirsi FNB38.
Another option is the Lithium Battery Charging and Discharging TYPE-C Integrated Board PD Bidirectional 18W Fast Charging Mobile Power Supply Bank. It uses an unknown IC. Idle current is unknown as well. Support for QC3.0 and USB-PD 3.0.
- A TPS2514 will be needed on the USB-data lines to tempt the devices into drawing 1.5A instead of the normal 500mA.
-
Main light source
12/06/2021 at 19:15 • 0 commentsThe light will likely be used to light from close range (i.e. lighting a dark room, the inside of a cabinet or the underside of a car), similar as an LED inspection lamp. I see less used for pointing a bundle of light at faraway objects (i.e. to draw attention, see where you're going at higher speeds such as a bike light).
So we'll need a wide angle of light instead of a narrow beam. That's why we'll use a COB-LED panel instead of a LED-STAR with a lens. It leaves us the added benefit of lower cost. COB-LED panels are very efficient. The heat is spread over a large surface area, so a heat sink might not be needed (at least, that's the goal).
Option 1 : "4W" LED-COB panel 50x20mm
AliExpress "Festoon light 12V" : €0.84/pce
As the housing shouldn't be longer than a 18650-cell, this panel fits nicely. The cool-white LEDs are generally more efficient than the warm-white version.
LED voltage is "12V", so a boost-converter can be used to power it from a 4.2V Li-Ion battery. The forward voltage is 10.1V at 300mA, 9.6V at 250mA. The maximum current for this module without heat sink is 250mA. The temperature rises by 45°C above ambient then. This has been measured with a thermo-couple stuck to the backside.
It would be more correct to rate this LED-COB panel at 2.5W instead of 4W.
The 20Ω series resistor needs to be replaced by a 0Ω-resistor. The resistor can't handle the power at a 300mA LED current (an 0805 resistor is not rated at 2W) and when powered by a LED-driver, this resistor isn't necessary anyway.
The two-sided tape has been removed because it impedes the heat flow. Two-sided heat transfer tape exists, but it certainly isn't cheap.
Option 2 : "3W" LED-COB panel 60x8mm
AliExpress Sumbulbs Official Store : €1.03/pce
All LEDs seem to be in series in this panel. The LED-voltage is about the same as a Li-Ion cell. A boost and buck converters can't be used with a single panel. We can put two panels in series and use a boost converter.
The panels could be mounted on touching surfaces of the housing to get an even wider light angle. The two mounting holes allow for easy mounting.
Some measurements:
- Forward voltage : 2.8V (at 650mA)
- Maximum current : 650mA without heat sinking the temperature settles around 56.5°C. For that measurement, a thermocouple has been stuck to the back of the COB-panel.
without additional heat sinking, power consumption is only about 1.8W (maybe 2W if you allow for a higher temperature)
Once again, it would be correcter to advertise this panel as 2W instead of 4W.
Conclusion
Option 1 is preferred because of the lower current and higher forward voltage, this makes it easier to design an efficient and reusable (for other projects) LED driver.
The only issue that needs to be solved is the mechanical attachment.