Rustic Engineering

My Mind working on…

Archive for the ‘engineering’ Category

Transformerless Power Supplies (design)

leave a comment »

One thing that all us need know is that the project power requirements not only besides on efficiency and quality. Efficiency and quality are subjective terms and you (like me) break and open some market products, you’ll found some really dirty way to power up a electronic device.

Well, with that in mind I’m working in power my Samsung Infrared Decoder with a transformerless power supply. Transformerless Power Supplies, instead of use regular transformer-rectifier circuit or switched power circuitry, use direct coupling of AC line to passive components, like resistors and capacitors, to obtain a desired voltage. Yes, it’s a very dangerous idea, but you can control it and minimize risks too.

Some projects are really cheaper, and don’t require much power. Think in a microcontroller circuit that do the following things:

  • Wake-up from sleeping;
  • Reading temperature (ADC);
  • Transmit it (802.3.15.4);
  • Return to sleep;

These steps doesn’t require more that 20mA (aprox), and most market components are cheaper. But if you want to really make this cheaper and smaller, a transformer/wall adapter supply it’s a big monster. The bad news is that transformerless power supplies, not only are dangerous but less current capable of other supplies. If you need more than a few mA, your circuit will be exposed to a great risk.

The two basic types of transformerless power supplies are resistive and capacitive. You can view nice example after Google it. My idea it’s use a capacitive version. My circuit simulation is based on bellow (ignore V2 for now, I’ll explain it later):

Capacitive Transformerless Power Supply

The main rule to keep in mind is that “R1” and “XC1” (capacitive reactance) are the only input current limiters. So, more current, need other values. The other rule is to keep the supply working: keep output current requirements less than input current calculated. See:

We need to resolve the input voltage in terms of RMS (Root Mean Square) value. The voltage is the RMS value of a half-wave, because D2 rectifies it. So:

Put all it together to resolve:

I’ve chosen values to meet approximately 5V@20mA. The RMS voltage value in Brazil is 127V. The frequency is 60Hz. The zener used have 5.1V drop across.

For circuit simulation I’ve used MacSpice, a great Berkeley Spice 3f5 clone. In this circuit you view another voltage source (V2) with zero voltage output. That’s a way to measure output current on transient analysis on Spice. You can download my circuit file for run your own simulation here. The results are:

SPICE tran analysis (Vout)

SPICE tran analysis (Iout)

The voltage drop on zener diode and common diode D2 is determinant for output voltage. In really, I never reach desired 5V output because of voltage drop across D2. But it’s ok, most modern microcontrollers operate on a wide range of voltages. The output voltage is given by:

The next step is test a real circuit with real load. So long I’ve news, I’ll post them here.

Remember again that transformerless power supplies are naturally unsafety. After decide make that circuit, and finish it, you have in your hands live AC voltage very close to low power electronics, with is a great danger. Stay as advised.

Written by forrequi

July 19, 2011 at 15:45

How much current (part 1)?

with 7 comments

Someone send to me a question, about how much current my OLED board consumes at all. Well, after measure with a multimeter the answer is: 660μA (aprox.) with display all ON and contrast at 0xFF (max). But this question make me thinking about how measure that current myself, without a multimeter.

When I’m in graduation (some good years ago) I made a little circuit to measure how much current my power supply project output. The circuit is based on “high-side current-sense” methodology. See my hand-drawn circuit above:


HIgh-side current-sense

High-side current-sense


This circuit is a classic high-side current-sense, where the voltage drop across Rs resistor is isolated by a operational amplifier (op amp) in a differential configuration with unitary gain. The many implementations of technic were based on discrete components or semidiscrete circuitry. In their simplest form, such high-side monitors require a precision op amp and a handful of high precision resistors.

The resistor value should be low (like mΩ scale), to minimize power losses, but don’t be too low, because stability problems. And don’t forget about power dissipation across the resistor.

One common approach for high-side measurements has been the use of the classic differential amplifier, which is employed as a gain amplifier.

So, after reading a lot of theory, I’ve going to search my integrated differential amplifier.

Integrated Differential Amplifier

I should admit: Maxim is always my source of good op-amp IC, so I’m was doing some search and found a good and little evil: MAX4372. Some goods about this guy:

  • Tiny SOT23-5 package;
  • Low cost;
  • 3 gain options (20V/V, 50V/V and 100V/V);
  • +2.7V to 28V range of operation;
  • Consumes only 30μA;
  • 0.18% full-scale accuracy with 100mV Vsense input (This is equivalent to only 0.18mV input offset voltage);


MAX4372 typical use

MAX4372 typical use


The MAX4372, in a tiny SOT23-5 package is a very good device to make a current sense device. You can set the full-scale current reading by choosing the device:

  • MAX4372T: 20V/V Gain;
  • MAX4372F: 50V/V Gain;
  • MAX4372H: 100V/V Gain;

What means 20V/V Gain? If you have 1A current flow through a 100mΩ Rs resistor, you gave only 0.1V drop. But with 20V/V, you multiply this and obtain 2V. Obviously? The design goal with Gain is thinking in terms of full scale design. If your A/D converter uses 3.3V was reference, you can consider this to check what the max current value you can measure with determined gain value.

A test circuit

I’ve designed a test circuit to test my idea. Basically is a MAX4372T with a 100mΩ Rs. I’ve mounted it in universal board, and my idea is connect it to my USB Low Pin Kit:


MAX4372 basic circuit



Test board


To test them, I’ve used a PIC18LF2520 and a great character LCD from Electronic Assembly. See my test circuit working:


First test



Looks great!


The pictures show that the global idea works great. Now I need some work to improve stability and other features.

Next steps…

The next step is create a USB device for read, store and show the current measurements:


USB Power Monitor

USB Power Monitor


Written by forrequi

October 17, 2010 at 03:02

OLED 0.96″ Breakout Board (SH1101A Driver)

with 19 comments

Some mounts ago I’ve bought a PIC24F Starter Kit. It’s a very nice development kit from Microchip for who wants know about USB OTG, Capacitive Touch Sensor and more. But I really like is the OLED display it comes.

The OLED is very small but with a good resolution (128×64 pixel). It’s monochrome black and white and, believe or not, very bright but without backlight! Well, I’m very impressed and obviously imagine what I can do if I have a small OLED like that.

So I’ve started to find the manufacture of OLED. I find some information at Microchip driver code and with some Google research:

  • It’s use a Sino Wealth SH1101A controller;
  • Parallel  or SPI interface. Very nice feature for a display;
  • The controller logics operates with 2.4V – 3.5V, but OLED requires 7.0V – 16V. It’s have a internal simple DC/DC Booster for that;
  • The display is constructed with COG  (Chip-On-Glass) technology;
  • There’s a version where 128×16 pixels being yellow OLED, and 128×48 pixels as blue OLED;
  • Crystalfontz sells this Yellow/Blue with code CFAL12864N-A-B1;
  • Univision has the Black/White and Yellow/Blue version;

After that, I’ve started design a board to this OLED. Oh, if you don’t know what OLED means visit Wikipedia page.  My design concentrates in a breadboard friendly board. The circuit is little variation of the circuit founded in Microchip PIC24F Starter Kit schematics. I’ve substituted some components for more flat and foundable items. Basically I change the inductor, the N-Channel MOSFET and the diode. You can see the design bellow:

Eagle cad board

Design goods:

  • 0.1″ pin space and breadboard friendly;
  • It comes with SPI interface preseted. If you want use 8080 parallel interface, simply pull-up “P/S” pin;
  • Very flat design with only SMD parts;
  • Clear pin identification;
  • Small size (don’t increase OLED size too much);
  • Can be hand soldered (whitout hot-bar or even hot-air station);

That’s my board finished:

My board and OLED

Circuit and solder

First test...

Breadboard friendly

Low profile

I really like this board because it’s work at first time, and it’s not so common in electronics word with your first board design. After some tests, I’ve learning some useful information about the OLED displays in general:

Most of OLED displays have SPI interface. But most of them don’t let you read the display RAM data with SPI interface, because it’s a SPI 3-Wire interface. When you cannot read  display RAM, should be impossible make functions that read display RAM and alter only one pixel (for example). So, some simple functions (like line creation) became very complex if you like to use it without modify some graphics already displayed. Example: if you have a picture and draw a line, you will change some blocks of RAM, don’t only the line pixels. I’m working on that problem.

If you like this board, email-me at I’ve five empty boards and five OLED yet.


Written by forrequi

May 10, 2010 at 16:33

Posted in electronic, engineering, LCD, OLED, pcb, projects

Tagged with , , , ,

Lithium Polymer Battery USB Charger

with one comment

Finally I’ve finished this project. It’s a USB Charger for Lithium Polymer Battery, that’s very compact and high powerful batteries that I use in most of my projects.

A tiny and elegant charger...

All sides...

In my recent GUI Bot project I’ve used the famous MAX1555, a greatest IC in a tiny SOT23 package. One thing about MAX1555 that I don’t like is the current limitation it has (about 100mA). I know it’s for USB low speed compatibility, but who knows someone that don’t have a high speed USB host surround? Because that I use the greatest MAX1811. It’s a great IC too, but can deliver up to 500mA! See one of my first post to check more details.

That’s the finished work:


If anyone like this circuit, email to

Written by forrequi

March 10, 2010 at 23:40

USB Small Peripheral Board (aka PIC18F14K50 Board) Finished

with 17 comments

Well, my board comes to me yesterday and I’ve soldered all parts. The board is really small, very compact, very robust. I’ve made a little test only to check if are something wrong, but not. Everthing works well. Very good for version 0.

See the photos:

Finished and empty PCB

Breadboard friendly

Programming via PICkit3

Now, I (and you, please contact me if you like it) can test and make nice devices, without boring with crystals, capacitors, reset, USB it self. You can attach it on a breadboard or your own prototype PCB with your circuit.

I’ve created a kind of pin card, for rapid pinnout reference. I got the card idea from Mbed project. It’s very useful, with all pins and ports plus the information about device peripherals.


Reference Card (like

Think the nice things you can do… I want to make a test with USB Mass Storage Device, yes, a Flash Drive. I’ve a little project where this really help me with configuration storage, etc.

For test, I’ll show us some application example, like a USB RFID reader.

RFID Reader

If you like this board and want to get one, email me to talk about. It’s a zero version, so some errors could exist.


Eagle files here.

Written by forrequi

March 5, 2010 at 00:17

GUI Bot, a overview…

with 10 comments

I few months ago, I started a prject of a little robot, to be able to self study some control, resolve maze algorithms and do something fun. The robot needs to be small with very quickly and smart movements.

The prototype was a success, made with some materials that I already have and with little issues, work’s great!. It can do:

  • Move, turn and gyro with speed and agility;
  • Speed up and Stop when you need;
  • Generates little sounds/alerts (and some music too, like a old cell phone);
  • Detects and follow a black line over white plane;
  • Easy programs changes, via USB/Serial adapter connection and a bootloader on the microcontroller;

This is my prototype, called GUI v1 (honor my son, Guilherme), build with universal PCB and some wires:

nice work!

Lithium Battery (like the new cell phones)

some wires...

The chassis was made with PCB it self, because I don’t like spend time to find some special enclosure to it. The universal PCB was cutted with Dremel and all components are soldered with a common solder iron. I need to confess: when the prototype was finished, it’s length and robustness impressed me. I don’t spect. See it in action:

After some tests that comprove some abilitys, I started to design a well polished and projected PCB. Now the hard work begun. I used Eagle software to design the circuit and PCB, but I don’t have all parts I want. So, I’ll go at SparkFun to find some devices I like to use in the robot. They have all really nice stuff you can think.

The processor (a Microchip PIC18F452) running at 20MHz and control motors speeds, LEDs, Buzzer, Wireless and all the embbeded stuff. It’s using a Bootloader to facilite the program upload, so the user don’t need complex flash programers to load their own software on the board. Just compile your program and upload via USB cable using a serial program like Hyperterminal or Putty.

Now, with the PCB designed, I’m going to BacthPCB and ordering some pieces. BacthPCB do a nice and decent job to amateurs designs, because they accept even a one board was order. The time to process your order is about 20 days. You can view my design (up board) and the processed PCB below:



After have almost all parts soldered and load some basic program to test, the result is:

low profile...



It’s power come from a little 3,7V Lithium-Polymer battery, charged via USB mini-B connector. I’m calculating the robot autonomy, as son as possible I’ll post this important data.

And if you can see this little robot in action:

As you can see, your movements are clean and fast, but with the control it’s can be smooth and slow. Now I need finish the Wireless comunication. I’m wonder if the program upload can be done via wireless…

The total cost of the robot it’s about $200 (excluding post services of board and components). The robot don’t stay in comercial prodution…maybe after some corrections and testes I change my mind.

Written by forrequi

February 1, 2010 at 17:20

GUI v2 – Final

with 2 comments

It’s finished! (almost). The Motor Board PCB arrives and I’ve soldered all components together. The final results looks awesome to me! Most beautiful that I’ve planed. There’s some parts that I don’t solder, because I need purchase a SMD rework station (all solders on this robot are made with a ordinary solder station).

GUI v2

GUI v2

GUI v2 - Power ON!


I found two problems with this design:

  • I’ve used the RA4 pin of PIC18LF452 for digital I/O, but unfortunately according to datasheet, that pin is a open drain. To operate like a common digital I/O it’s need a pullup resistor, but I don’t put it on my design. I need to solder the pullup 10kΩ SMD resistor. Lesson: All the times, read the entire datasheet before use any device pin.
  • In my Eagle motor library, I don’t provide horizontal restrictions to the motors area. Then, a little decouple capacitor stay above the motor, touch the white bracket motor house. This make a bad contact between boards. This capacitor it’s for crystal stabilization, so I removed it.

Well, even with all the issues:

  • Inverted connectors on boards;
  • Capacitors with wrong package (remember: 3406 don’t is 0603!);
  • Open drain pin without pullup;
  • Parts that I can’t found where purchase them;

… I think the whole project was a success. The robot works well, silent, smoothly. They are solid, very small and useful. The final result is a perceived evolution of the prototype, you see next:

Prototype and Final

Prototype and Final

GUI v2 - two boards

That’s the video of your first tests:

Now, the wireless part (NRF24L01+ transducer) waits to be soldered. It’ll on the party next month. So, the whole project has been closed and I’ll work on the software development, that I only write a very basic functions for test and maze solves.


Written by forrequi

November 7, 2009 at 11:12