Monday, January 19, 2015

Soda Can Wifi Antennas

Some clever folks posted the parabolic antennas made from beer cans.  It is quick and easy to do.  I made one for my router.  Although the gain is not dramatic, I do see some improvement in SNR.  The signal quality indicator goes up a few percent.


Monday, January 12, 2015

A 4-W White LED Driver Circuit

Here is a white LED driver circuit for four 1W white LEDs powered by one Li-ion battery cell.  It is a boost converters with current limit to about 400mA.  The converter frequency is about 35KHz with 80% duty cycle.  The current draw from the supply is 1.4A average with 0.5A ripple.  The current delivered to the LEDs are 0.3A.  The prototype achieves about 72% efficiency, matching the simulation very well.





Tuesday, January 6, 2015

IoT with ESP8266

The recent release of ESP8266 has opened new possibilities for the age of IoT.  Its low-cost, versatility and simplicity make it instantly popular.  I fetched a module for less than $4.
ESP-01 Module
The Chinese made ESP8266EX is a complete WiFi chip, including RF and a Tensilica processor.  The programming of the processor is supported by the GNU toolchain.  On the module, it includes a 4Mb SPI flash PROM for mass storage, a crystal, a few discretes and a printed antenna.  There are one red LED for power and one blue LED to UART TX.  The 8-pin connector has the following connection,

Pin
Name
Description
1 GND Ground
2 U0TXD UART0 Transmit, GPIO1, (blue LED)
3 GPIO2 U1TXD, I2C_SDA, has internal pull-up
4 CHIP_EN Chip Enable, active high
5 GPIO0 Has internal pull-up, (for Flash programming mode)
6 EXT_RSTB External reset signal, active low, pull-up resistor
7 U0RXD UART0 Receive, GPIO3, has internal pull-up
8 VDD +3.3V power input

Pull GPIO0 low at power up to enter the Flash programming mode.

The ESP-03 has more I/O pins.  The board is 17.4mm x 12.2mm with 2mm pin spacing.
ESP-03 Module
The additional pins are

GPIO12MTDI, HSPI_MISO, PWM0

GPIO13MTCK, HSPI_MOSI, UART0_CTS

GPIO14MTMS, HSPI_CLK, I2C_SCL, PWM2

GPIO15MTDO, HSPI_CS, UART0_RTS, PWM1

GPIO16Deep-Sleep Wakeup

Module Schematic
For normal operation, CHIP_EN should be high and GPIO15 low.  In standby, the power draw is about 1mA; in the receive mode, the power draw is about 70mA.  The transmit power draw is over 100mA, maybe as high as 200mA.  So make sure the voltage supply can provide this peak current.

For this version of the firmware, the baudrate is 9600.  It had to be determined by looking at the scope of the TX signal.  (Note that some documentation says 115200, but that may be for an earlier version.)

The ESP module starts as an access point, which can be connected from a PC WiFi adapter.  Open a server TCP port on the PC, using nc.   We can start the communication,
AT+CWMODE=2 # set mode AP
AT+CWSAP? # returns AP: ssid, password, channel, encryption
AT+CIFSR # returns the IP address
AT+CIPSTART="TCP","192.168.4.100",6789 # open a TCP connection
AT+CIPSEND=4 # send 4 bytes, type in the 
The message shows at the PC terminal running nc, and anything you type in nc is displayed at the serial terminal.

To create a TCP server
AT+CIPMUX=1 # must be 1 for server
AT+CIPSERVER=1,6789  # create server port 6789
At this point, we can connect to the server from the PC and whatever we send is displayed.
To send data back,
AT+CIPSEND=0,5 # send 5 bytes, must specify id

Another way to try is to set up an access point (AP) on a PC and have the module connect to it.  The command sequence is as follows,
AT+CWMODE=3 # set mode to station and AP
AT+CWLAP    # list the available APs
AT+CWJAP="AP","Password"  # to join an AP
AT+CIPSTART="TCP","192.168.12.1",1234 # open a TCP connection
AT+CIPSEND=4 # send 4 bytes, type in the 

Next we check the compiler toolchain and the SDK.

The toolchain is xtensa-lx106-elf.  The latest SDK is esp_iot_sdk_v0.9.4.  The default app IoT_Demo is built by running make and gen_misc.sh in the app directory.   To upload through serial port, set GPIO0 low and GPIO2 high and run in the bin directory,
~/esptool-py/esptool.py --port /dev/ttyUSB0 write_flash 0x00000 eagle.app.v6.flash.bin 0x40000 eagle.app.v6.irom0text.bin
Connecting...
Erasing flash...
Writing at 0x00008c00... (100 %)
Erasing flash...
Writing at 0x00067000... (100 %)

Leaving...
esptool.py is a python program to communicate with the ROM bootloader.  The baud rate is non-standard 74880.

The at_v0.20 only works with esp_iot_sdk_v0.9.3 .  It can be built and uploaded to the module like above.  The default baud rate is 115,200.  After spewing some garbage, it is ready to accept AT commands.

Sunday, January 4, 2015

PWM Drive Efficiency

Here we consider a half-bridge circuit, which could be used in a motor drive or synchronous switching regulator.

The first thing to consider is the IR loss from the FET switches, which is simply the RMS current on the $R_{ds}$.  The more ripple current the higher is loss even with the same average current.  This loss is independent of the switching frequency.

The switching loss is consisted of the gate drive and the turning on/off the FETs.  To turn on an FET, the gate capacitance has to be charged.  It is easier to use the total gate charge given in the MOSFET data sheet than dealing with gate capacitance, $C_{gs}$ and $C_{gd}$.  The total energy required to deliver the gate charge $Q_g$ is $\int{VI}dt = V Q_g$.  Note that we do not need to know the exact function of $I(t)$, which is depended on the gate driver and the gate capacitance.  The gate capacitor is charged to $CV^2/2$, but the energy delivered by the supply is $CV^2$, so half of the power is dissipated by charging and the other half is lost during discharging.  So the total power for two FETs switching at Fsw is $2VQ_g F_{sw}$.

The loss in turning on/off the FETs is depended on the rise and fall time.  The current is flowing as the voltage across the switches rises or falls.  Assuming the average current $I$, the power loss is $V I (T_r + T_f) F_{sw}/2$.  The rise and fall time are on the order of 100ns.  This is usually the dominant loss.

To prevent the shoot-through current, a dead time is added between the turning on one FET and the turning off the other.  During the dead time, the current continues to flow because of the inductance.  The conduction goes through the diodes, either the FET's body diodes or external diodes.  So the current flows through one diode drop, this is usually greater than the Rds drop.


Tuesday, December 30, 2014

Human Touch Temperature

A lot times, we use our finger to judge how hot a device is and whether it has adequate heat sink. The late Bob Pease describes a 5-second rule in his well-known book "Troubleshooting Analog Circuits":  "A good rule of thumb is the 5-second rule: If you can hold your finger on a hot device for 5 seconds, the heat sink is about right, and the case temperature is about 85°C."

NASA Johnson Space Center actually conducted a study on human touch temperature, "A New Approach to Defining Human Touch Temperature Standards" by Ungar and Stroud.  The onset of pain threshold is about 44°C.  The touch temperature is material dependent.  For Aluminum, 1 second touch corresponds to about 70°C, and 5-second touch corresponds to about 55°C.  Bob was probably talking about plastic case, 5 seconds is about 85°C, then 1 second is about 140°C, 2 seconds is about 110°C.


Tuesday, December 23, 2014

Temperature dependency

All electronic components have some temperature dependency.
  • Resistance: 
    • Copper wire resistance has a positive temperature coefficient of 3900ppm/°C; for 100°C, the copper resistance changes 40%. 
    • Carbon film resistor has a negative temp co of -200ppm/°C and is worse for larger value resistors.
    • Metal film/Thin film/Thick film resistor has a temp co of +/-10ppm/°C to +/-100ppm/°C.  Testings show that the temp co is valid to -150°C.
  • Capacitance:
    • C0G or NP0 ceramic capacitors have very good temperature co, +/-30ppm/°C.  
    • X7R capacitors have +/-15% variation over the range -55°C to +125°C.  The capacitance typically peaks at the room temperature and falls off at both ends, but it could have very nonlinear temperature dependence.
    • Aluminum electrolytic capacitors have considerable temperature dependence.  The capacitance falls off significantly at low temperature because the viscosity of the electrolyte increases.
    • Solid tantalum capacitors have much less temperature dependence in comparison with aluminum electrolytic capacitors.
  • Inductance:
    • Core materials have nonlinear temperature dependence. 
    • The permeability of a ferrite core is usually maximized around room temperature, but falls off at the extreme temperatures.  At -180°C, the inductance can drop as much as 70%.
    • The powder core holds up well at the lower temperature. 
  • Diode:
    • Silicon PN junction forward voltage decreases with temperature, usually -2.1mV/°C.
    • Silicon PN junction avalanche breakdown voltage increases with temperature.
      • High voltage Zener diode is actually avalanche diode.  1N5245 15V Zener has a temp co of +820ppm/°C and 1N5271 100V +1100ppm/°C.  MMSZ5245B is tested to -150C and has a fairly constant temp co about 1000ppm/°C over temperature.
    • Silicon PN junction Zener voltage decreases with temperature.
      • 1N5221 2.4V Zener diode has a temp co of -850ppm/°C.
      • At around 5V Zener and avalanche balance out.  1N5231 5.1V Zener has a temp co of +/-300ppm/°C.
      • Temperature compensated reference Zener diode can have very low temp co, e.g. 5ppm/°C for 1N829 6.2V.  The temperature compensation is achieved with a forward diode in series.  At 5.6V, the temp co is about 2 mV/°C, similar to that of the forward diode voltage.
    • Schottky junction forward decrease with temperature.
      • -1.2mV/°C (ref 1)
  • Transistor:
    • Bipolar beta
      • Beta increases with temperature.
    • MOSFET threshold
      • Threshold decreases with temperature.
    • MOSFET Kp
      • Kp decreases with temperature.
    • MOSFET breakdown voltage
      • Breakdown voltage increases with temperature.

Reference:
1. Zetex, Temperature Effects On Silicon Semiconductor Devices, June 1995. (http://www.diodes.com/_files/design_note_pdfs/zetex/dn4.pdf) .

Sunday, December 21, 2014

Linux Wine

I'm pleased that some of my old applications actually work.  
What works
  • LTspice IV
    • This is very good. Now I have a superb Spice simulator running on Linux.
  • Adobe Acrobat 6.0 Standard
    • I can edit PDF files, but Linux solution may also exist.
  • Merrian-Webster
    • Works only after installing msvcirt.dll.
    • Matter of convenience with excellent pronunciation. Online dictionaries exist.
  • Viewmate 11.2
    • Good free Gerber viewer.
    • Most parts work except it cannot load directory.  Can load zip file.
  • ExpressPCB
    • An easy to use commercial PCB design tool for simple boards. Can import netlist from LTspice.
What does not
  • Protel 99 SE
    • Fails to start with error message: Unhandled exception 0x0eedfade ... It would be nice if this works. But I can always run it on a virtual machine.
  • Altium Designer Viewer
    • Installs fine, but fails in the middle of starting up.
  • Visio 2014
    • Cannot even install.  Linux alternatives are Dia and xfig.