Rustic Engineering

My Mind working on…

Archive for the ‘projects’ 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

Infrared Room Control (Samsung IR protocol) Code

with one comment

Well, I can’t finish the PCB for this project yet (I’m planning make it with a Transformerless Power Supply), but I’m posting the Microchip C18 code for all that want work with this protocol.

The on breadboard... yet

Please, visit my download page.

Bye.

Written by forrequi

June 23, 2011 at 14:35

Infrared Room Control (with Samsung IR protocol)

with 36 comments

I had ear some time ago that laziness sometimes is the best thing for inspiration. That week I discover that’s true.  Some nights,  I  lay on my bed to watch some thing on TV and doing some electronic research, before sleep. And, I don’t like to put off the lights (effficient ilumination is the best friend for a good reading) . Then, obviously, before sleep, I need to stand up to turn lights off. At my side, on bed, always resides a great remote control TV, with a set of unused buttons, telling “use us to turn the lights off“.

My remote

That’s a project that I was retarding because other, but now I decide to initiate and finish it.

The Basic Idea

The first step is recognize what my remote control is send to TV. It’s a Samsung remote control, with TV, VCR, DVD and STB specific and shared functions. My basic idea is: use some of this unused buttons to turn the lighst ON and OFF. But, why not dimmer the lamp? Why not doing some other useful thing? (Yes, thats because some projects growing up…)

So, the basic idea now is:

  • Make a device that recognize when a command is addressed to it self or not;
  • Recognize different commands;
  • Save usuful states (dimmer regulation);

Samsung Protocol

The Internet has a lot of information about RC5, NEC and Sony IR protocols, but not the same for Samsung. After some search at Google, I found this usefull page with some information about Samsung IR protocol. Resuming Samsung protocol:

  • 37.9KHz carrier wave (ON state is a burst of carrier with some duration, OFF is absense of it);
  • 1 Start bit (4.5ms ON, and 4.5ms OFF);
  • 32 data bits stream (data + address?);
  • bit “1” (590μs ON, 1690μs OFF) (thanks to Islam qabel,  for the more precise bit duration);
  • bit “0” (590μs ON, 590μs OFF);
  • 1 Stop bit (590μs ON, 590μs OFF);

I think that more information only with a test.

Test Circuit

The test circuit is very simple, consisting on a IR receiver (with filter, carrier demodulation and output). My only device available at home is a TSOP2236. Well, let’s go see what hapens.

TSOP2236 is a dedicated IR receiver with PIN diode and preamplifier, assembled on lead frame. The epoxy
package is designed as IR filter, to improve sensibility. The demodulated output signal can directly be
decoded by a microprocessor, but it’s logical reversed:

  • ON state (carrier presence): TSOP output LOW;
  • OFF state (carrier absence): TSOP output HIGH;

To make measures and confirm my suspects, I had use my Logic Analyzer from Saleae on the follow circuit:

Test Circuit

That’s the results for press button “1”:

Received data after pressing “button 1” on remote

Signal stream

Start bit identification (9ms total)

Bit “1” representation

Bit “0” representation

The process to gathering all this information is very easy with Logic Analyzer. The measured times differs a little bit, but this isn’t a problem. I count the transitions after the START bit and there’s 32 bits in.

Look again at the sequence of high and down states. Remember that we have a reversed version of the original IR wave from remote, because TSOP OUT signal is inverted. But actually it’s really doesn’t matter. What I need is: pressing “1” differs from pressing “2” or other buttons on remote. I don’t wanna to create a compatible device.

Decoding the data stream

To decode the data stream I used a PIC18F2520 MCU. I already has working on 16bits and 32bits MCU, but this project is much simple to require a great MCU. My design goals are:

  • Use internal clock (8Mhz, Instructiom Time TCy = 4/8MHz = 500ns);
  • Use Timer0 as counter with 1us increment (Timer0 prescaler to 1:2);
  • Use External Interrup 0 (INT0) to handle incoming IR waves and get the building IR code (final version);

That’s the circuit:

Decoding Test Circuit

Coding

The code (for Microchip C18 compiler) consist in a set of functions to detect when the signal change it’s state from DOWN to UP or UP to DOWN. See the sequence (basic):

Basic Algorithm

Note that for data bit identification, only HIGH time is important. It’s the difference between logic “1” and “0”, so you don’t need to be very precise in that differentiation. The red right program branch, needs to run 32 times, for all 32 bits.

I get…

The test was a success! After all, I have a 32bits unique data, that contains (probably) a Address Part and a Data Part. Again, I don’t worry about what is address or data. Only need unique 32 bits codes. If address part repeats (because you are send codes to one device), data should be unique. Ok to me.

The stream is read as it is delivered from TSOP to MCU, from left to right (START BIT to right). I’m considering from LSB to MSB, so when you see the analyzer stream signal, you are viewing the reversed version. See:

IR Data Stream Mapping

After some nights adjusting some things, the code works great!  I’ll publish it here in the next week.

As I think, some codes changes if you are using TV, DVD, VCR or STB buttons. See the codes for VCR function:

Some codes

If you observe the first pictures, about button “1” stream, you can see the sequence of 1110000 (reverse order, 0x07).

Proof of concept

To test my concept, I programing the device to waiting VCR signal functions (ended with ….0505) as you can see:

  • Buttons 1,2 and 3 turn ON color RED, GREEN and BLUE;
  • Buttons 4,5 and 6 turn OFF color RED, GREEN and BLUE;
  • Button 9 turn ALL ON;
  • Button 0 turn ALL OFF;
  • VOLUME+ increase LED power (PWM duty cycle);
  • VOLUME- decrease LED power (PWM duty cycle);

See my video:

Next Step

Now I need to design a transformerless power supply and the power control circuitry (TRIAC, etc) to control the real lights. Some nice ideas to next version:

  • Store dimming states on internal PIC EEPROM, so you can save desired conditions every time;
  • TV Remote now can act in others projects too (robots, toys, other home automation, etc);
  • With a small LCD, create a small menu, some configuration options, to more advanced projects;

I hope yours enjoy this project. From the first paper to here, I took one week to get it working properly. In a few weeks, I’ll share all the files here, in downloads page. Thank’s!

Written by forrequi

February 9, 2011 at 00:40

Posted in hack's, projects

Tagged with , , , , , , , ,

OLED Display (SH1101A) and DS18B20 (with C18 example code for download)

with 12 comments

For who need SH1101A OLED driver, I’m posting here my code (written in Microchip C18, but easly to port to other platform) to help more people on get use this great OLED display. It’s not finished, yet, but it’s very useful.

Demo code running

 

The code has geometric draw functions to draw single pixel, lines, rectangles and circles with fill option. There’s  characters output functions too, with 8×6 pixel font.

The icons for Battery (animated), Bluetooth, WiFi, Sound (animated), etc are on the code too.

Some example of available functions are:

  • SetPixel(), GetPixel();
  • Line();
  • Bar();
  • Character output functions, PutROMString(), PutString();
  • PutImage();

In the code you’ll find a DS18B20 Dallas OneWire Digital Temperature sensor driver too. That’s a limited version (only work for one sensor in OneWire bus) but works great. You get a float reading plus a string with temperature value (in Celsius Degrees). More improvements coming soon.

Well, let’s go to download link:

DS18B20 with 12bit resolution!

If you have any trouble with that code, email-me or let me a comment.

Written by forrequi

November 26, 2010 at 01:03

Hand Soldering OLED – video

with 5 comments

Hi friends.

Some people ask me about how to do hand soldering on smaller parts, like on my OLED Display Board. It uses a “TAB” (tape automated bonding) or “COF” (chip on flex) style flex tail mated with a “COG” (chip on glass) display. Normally, TAB connector is soldered directly to corresponding pads on your PCB using a hot-bar soldering machine.

I don’t have that hot-bar soldering machine, so my hand’s can make the job. The first time I’ve done this soldering, I was a bit scare about damage the connector. My only tip is “don’t spend much time over the fragile contacts.

For help us, I’ve recorded my last OLED soldering. Maybe can help some people about SMD soldering (as some internet videos help me some years ago).

On YouTube:

 

 

Written by forrequi

November 11, 2010 at 16:55

Posted in electronic, LCD, OLED, pcb, projects

Tagged with , , , , , ,

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

I’ve promised… project’s Eagle files for download.

with 3 comments

Some people have contact me about my projects, with questions and support. I’m very happy because when I started blog I can’t imagine that my little stuff has been useful to other people.

And now I like to share my Eagle project files with us:

I hope this files may help you with your design, with your project. If you need some help, email me.

So long I finish some source codes, I’ll post my codes too. I promise! 🙂

Written by forrequi

July 30, 2010 at 15:23

Posted in pcb, projects

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 lubiana@gmail.com. I’ve five empty boards and five OLED yet.

Bye.

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:

Working!

If anyone like this circuit, email to lubiana@gmail.com.

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.

USBLowPin_pinnout

Reference Card (like Mbed.org)

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.

Cheers!

Eagle files here.

Written by forrequi

March 5, 2010 at 00:17