Tuesday, January 20, 2015

80486 PC: Power Supply

Power Supply

This particular PC power supply is rated 230W: 5V@23A, 12V@9A, -5V@0.5A and -12V@0.5A.  There is no 3.3V output.


It takes 120V AC (with a switch for 220VAC).  The AC color code is usually black for line, white for neutral and green for ground.  The earth ground is tied to the chassis and is tied to the circuit ground.  In this power supply, the line and the neutral are brought to a switch at the front panel.  The switch connects them to a connector on the board (brown and blue wires) and to an AC socket to optionally power a monitor, a feature that disappeared later.  It does not have a way to turn the power off electronically by software. The line is fused (5A/250V), but the fuse is soldered to the board, so not easily replaceable.  A thermistor is used to limit the inrush current; it starts at 5 Ohms and drops to 0.2 Ohm at the full load of 3A. The AC input is filtered by capacitors and a common-mode choke.  Then it is rectified by a diode bridge and filtered by two large capacitors (330uF 200V).   These two capacitors are connected in series; depending on the 120/220V switch, they are either charged in series with the full wave rectifier or individually charged by half wave rectifier (a voltage doubler).  This is how both 120V and 220V are accommodated.   The maximum voltage is 2*120*sqrt(2)=340V.  If the switch is closed (intended for 120V) but 220V is applied, the voltage would exceed the capacitors' rating.  I wonder if any power supply is destroyed this way.


Now we have a high voltage DC to work with.  The switching regulator is in the half-bridge configuration.  Two power NPN 2SC3040 transistors (400V/8A) mounted on a heat sink drive a transformer primary.   The secondary is diode rectified and filtered; the diodes are mounted on a heat sink.  (For some reason, the heat sink is tied to the cathode of the 12V rectifier diode.)  The circuit board is one-side; all components are on one side and all are through-hole.  The only IC DBL494 is the pulse width modulation controller and is resided on the secondary.  The base drive comes through a transformer.  The frequency is about 32KHz.  DBL494 has a 5V reference.  The feedback is on 5V; the other voltages are not regulated and do vary with the load on 5V.   When the 5V is unloaded, the 12V is only 10V.  When 5A is drawn from the 5V, the 12V is 12V.  DBL494 is powered from the 12V.  An interesting question is, how does the secondary bootstrap itself?

The fan is often the source of irritating noise.  The size of the fan is 3" x 3".  The fan (12V/0.14A) is powered from the 12V.  The fan is brushless and an outrunner (the magnet is out side); a Hall switch inside the fan does the communication.

The motherboard power connector is as follows, (note the color code)
Pin Signal Description

P8.1 Power Good

P8.2 +5 V

P8.3 +12 V

P8.4 −12 V

P8.5 Ground

P8.6 Ground


P9.1 Ground

P9.2 Ground

P9.3 −5 V

P9.4 +5 V

P9.5 +5 V

P9.6 +5 V

There are other power connectors for floppy drive and hard drive.

[I accidentally shorted something and the fuse was blown.  The two power BJT were destroyed.  Not sure how it happened.   I might have touched the heat sink to the chassis ground.  The fuse is not there to protect the components.]

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.