Sunday, November 29, 2009

I'm still alive

Just to let you know that I'm still alive. I'm just too busy (with my child and paid works). However, I have done some microcontroller projects. Yes, they are clock/watch related projects. I also want to complete many projects that the concepts have been proved for example, GPS Clock, Digital Wristwatch etc.,

By the way, I have got many friends via this blog.
Thank you all of you who sending me emails.

Tuesday, August 4, 2009

Small LED dot matrix development board

I was very busy for the past two months so this blog just didn't move. As you may know, the LED dot matrix display is my favorite device. I have designed a small development board for testing my led dot matrix related programs.
The schematic is as the following:
LED dot matrix development board Schematic

The PCB is single sided so I can make it at home. Most of the components are SMD to keep small footprint of the board. The PCB size: 58.4mm x 46mm
LED dot matrix development board PCB

Acutally, I made a PCB and installed all components but the board didn't work :p. It was working when I tested the schematic on breadboard (with through hole version of PIC16F887). I think the SMD PIC16F887 may be broken or the PCB is bad but I just don't have time to figure out the problem. I will try new PCB and PIC16F887.

Sunday, May 17, 2009

USB Coin/Button Cell Battery Charger

I have designed many small footprint PIC projects (such as, pocket watches and wristwatches) but I cannot make them really portable. To make them portable, I need small power sources. Of course, Coin Cell battery would be the smallest DC source that I can buy. The problem is that a Lithium button cell provides 3 V. which is not enough to drive my projects. I thought about using DC-DC step-up converter to boost 3 V. to 5 V. However, it's a little bit complex to add DC-DC converter to the projects. Moreover, my projects consume a lot of power as they consist of many LEDs, a button battery will not last for a day. So, I stopped my think at that point.

Just recently, I have found a rechargeable coin cell battery at Sparkfun.com. It provides 3.7 V. at 200mAh. I don't know that my projects will work at 3.7 V. or not. But, I want to give it a try. For portability, I want to charge the battery from my computer's USB port. So, I designed a USB coin cell battery + charger breakout board. Like many simple battery charger, I use MAX 1555 as the controller of the charger.

The schematic:


The single sided PCB (40mm x 30mm):

The LED goes off when the battery is fully charged (but the charger is still charging).
Please note that the schematic/PCB are just the design and I haven't made it yet. The parts are ordered and I will update when I complete the hardware.

Tuesday, April 14, 2009

Classic LED 7-Segment Displays

Just recently I have been addicted to old LED displays as they are small and bright and I love the classic look. We can see them in vintage calculators and vintage led watches. However these displays consume significant amount of power, so they are not used in watches and calculators anymore. As they are replaced by LCD, these LED 7-Segment displays are not in production anymore and difficult to obtain.

Now, I have 2 models of the classic LED 7-Segment as shown in the picture below: HP 5082-7414 from HP is on the left. It’s a 4-digit Red LED 7-Segment very nice for wristwatch. The one on the right is an 2-digit Red LED 7-Segment from an unknown maker. It can be used in a wristwatch too (with a little bit bigger case).

LED 7-Segment Display HP 5082-7414

Based on my inspection, I have made symbols for these displays with Eagle 5.4.0 free version. The displays are common cathode and the symbols are below

LED 7-Segment Display HP 5082-7414 schematic

The PCB footprints are as the following (DIP 12)

LED 7-Segment Display HP 5082-7414 PCB footprint

I have made simple clocks using these displays and PIC16F887. The real thing looks much better than the photo. The displays are bright red and sun light viewable. Very COOL!!! They are on my computer desk and I love to see them very often.
bubble-7-segment-clock

LED 7-Segment Display HP 5082-7414 clock

LED 7-Segment Display HP 5082-7414 digital clock

Each clock consumes about 0.25W (50mA, 5V) when the PIC16F887 operates at 250kHz (display refresh rate is about 61Hz). The amount of consumed current can be reduced significantly if I use some current limit resistors. But the displays will be dimmer than without resistors. I will try to use PWM for reducing the power consumption as I don’t want to put 8 resistors into my design. The schematic/PCB and firmware including source code in MikroC will be made public once I have complete all of the designs. I will even have kits for sell if my time permitted.

Wednesday, March 11, 2009

Setting Internal Oscillator for PIC16F627A

I love to use PIC16F627A and PIC16F628 because they come with internal oscillators. That means I can make a project with lower component count (without 1 crystal and 2 load capacitors). The project setting of MikroC for using internal oscillator of the PIC16F627A shows below:
Setting MikroC for Internal Oscillator

Saturday, March 7, 2009

Multisim Analog Devices Edition 10.0 Free Download

I have found a good and free circuit simulator,Multisim Analog Devices Edition 10.0. As you may know that Multisim is a famous electronics circuit simulation software (circuit simulator). It's based on Electronics Workbench from the same company. I have found the free version (not the cracked version) of Multisim by chance and you may not find it on the National Instruments website. It comes with a lot of measurement tools and it's very easy to use. I use it to simulate various analog circuits. The image below shows the screen shot of the simulation of DC-Boost Converter (12V to 150V step up).
Multisim Analog Devices Edition 10.0

Not only analog circuit, but it also simulates digital circuit as one may call it 'Mixed-Mode Simulator'.
Some features and limitations:
  • Build simulated component evaluation circuits to quickly assess behavior of over 800 Analog Devices operational amplifiers, switches and voltage references
  • Examine the unit under test in the intended circuit topology with up to 25 components
  • Use built-in instruments and analyses including oscilloscopes and worst-case analysis
  • Swap components easily to pinpoint best design options
  • Link to the Analog Devices Design Center for more online evaluation tools
  • Instantly access product pages and datasheets of each Analog Devices component
  • Upgrade to a full edition of NI Multisim to complete designs and transfer to board layout with NI Ultiboard

Please follow the link for Free Download Multisim 183MB

Friday, February 20, 2009

1Hz Clock Generator using PIC12F675

Based on the idea from http://www.josepino.com/pic_projects/?timebaseI have created a 1Hz Clock Generator. I use PIC12F675 as it's available locally. Its price is just about US$1.
The concept is using 32.768kHz crystal as a clock for the PIC. Therefor, the internal instruction clock is 32768/4 = 8192 Hz. By using the 16 bit Timer1 to count the instruction clock cycles, the interrupt will occur every 8 second. This period can be reduced by setting initial value of the Timer1 (TMR1H:TMR1L). I have to make Timer1 to count up to 8192 for generating overflow interrupt every 1 second. To make Timer1 count up to 8192, the initial value of TMR1 must be 65536-8192 = 57344 or 0xE000. This means TMR1H = 0xE0 and TMR1L = 0x00. In this case, I need to set only the TMR1H=0xE0 and let TMR1L runs continuously. By changing the initial value of Timer1, I can generate almost any frequencies.

An application for this project is a precise 1Hz blinking LED signal :) ha ha. I know that it's not useful but I think it's fun to look at (am I crazy?). Another application is a precise 1Hz time base for a clock.

The source code is written in MikroC.

// PIC12F675
// 1Hz Time Base Osc.
// Timer1 Module
// 32.768 KHz
unsigned short tick;
void Init ();
void interrupt ()
{
        if (PIR1.TMR1IF)
        {
                TMR1H = 0xE0;
                PIR1.TMR1IF = 0;
                tick = 1;
        }
}
void main ()
{
        tick = 0;
        //Initialize Ports and Timer1 Module
        Init ();
        while (1)
        {
                if (tick)
                {
                        tick = 0;
                        GPIO = (1 << 2);
                }
                if (TMR1H > 0xF0)
                {
                        GPIO = 0;
                }
        }
}
void Init ()
{
        TRISIO = 0;
        //Make all pins as output ports
        GPIO = 0;
        //Use Timer1 module
        INTCON.GIE = 1;
        INTCON.PEIE = 1;
        T1CON = 0x01;
        //Overflow every 8192
        TMR1H = 0xE0;
        TMR1L = 0x00;
        //  Enable TMR1 interrupt
        PIE1.TMR1IE = 1;
}



The schematic is as the following image.
1Hz Clock generator using PIC12F675


The PCB:


3D version:

Wednesday, February 11, 2009

Transistor array

I am looking for transistor arrays for my LED projects as I want to reduce number of components on board. After some searches, I have found that there are two candidates for current source and sink transistor arrays as the following:
UDN2981 : 8 channels high current source MAX 500mA
UDN2981 : 8 channels high current source
ULN2003 : 7 channels high current sink MAX 500mA

ULN2003 : 7 channels high current sink
I will use these transistor arrays for driving large 7-segment display panel , bright led dot matrix panel and other LED projects.

Sunday, January 25, 2009

3D Electronics Design

I just found a new thing to play with, 3D Electronics Design. I have seen some great 3D images of electronics component design for sometimes but I couldn't figure how they were made. Below image is one of my favorite. Please see http://www.blueroomelectronics.com/ for more images.


I have been playing with Eagle3D for sometimes. However, I cannot manipulate my design interactively and cannot export models to render in other 3D renderers. Just today, I found that blueroomelectronics's designs were made with Google SketchUp. So, I downloaded and installed it. The software is very easy to use. But, there is no electronics component library. However, there are some components available for you to download from google 3D warehouse. If you want anything that not available in the google 3D warehouse, you have to make it by yourself.
Below is my first try on making a PIC16F887 with TQFP-44 package.

SketchUp PCB Electronics component
I hope that I will come up with complete 3D designs of my clock projects. It's very fun to do these things.

Things to do

There are requests from readers as the following:
1. Complete project of the GPS clock
2. Adding calendar to my Digital Clock
3. Full function DS1307 Clock

And my own to do list:
4. FM Radio
5. Nixie Clock
6. Chronograph (stop watch)
7. Digital clock with 7-segment multiplexing using PIC16F627a or PIC16F628 + DS1307 + DS18S20 (Clock+Thermometer)
8. Digital clock + radio + thermometer (PIC16F887 + DS1307 + DS18S20 + Radio chip)
9. Complete led dot matrix clock
10.16x16 Led Dot matrix display

Wednesday, January 21, 2009

2-digit BCD to decimal conversion

Now, I'm working on the full feature clock using DS1307. In the clock, I use many BCD to decimal (bcd2dec) and decimal to BCD conversions for reading and setting time of the DS1307 RTC. MikroC provides buit-in functions for these conversions but the functions consume modest amount of MCU memory space. I have came up with simple functions that consume less memory for doing 2-digit BCD to decimal and the reverse conversions.

2-digit BCD to Decimal conversion function:
unsigned short myBcd2Dec(unsigned short bcd){
return ((bcd >> 4)*10+(bcd & 0x0F));
}

Example: myBcd2Dec(01000101) = 45

2-digit Decimal to BCD conversion function:
unsigned short myDec2Bcd(unsigned short dec){
return (((dec/10)<<4)(dec%10));
}

Example: myDec2Bcd(45) = 01000101

Sunday, January 11, 2009

Square Wave output from DS1307

For the clock that uses DS1307 RTC chip, I want a blinking led for indication of second. So, I have placed a resistor and an LED to pin 7 (SQW/OUT) of the DS1307 like below schematic:
Schematic for Square Wave Output DS1307

With this configuration (hardware+software), the LED was blinking at 1 time/second but the blink pattern was not my expectation. The LED is Off when the clock is updated and it is On at 0.5 second later. Quoted from the Control Register section of the DS1307's Datasheet:

With the square wave output set to 1Hz, the clock registers update on the falling edge of the square wave.

I want the reverse pattern (the LED is On when the time is updated and it is Off at 0.5 second later). So, I will add an invert logic before the LED like:
Invert logic at the output of DS1307
I have a plan to use this square wave output of the DS1307 for generating an interrupt to instruct the MCU to read time from the DS1307 and I will keep in mind that "The clock is updated at the falling edge of the square wave". The complete clock will be posted here later.

Monday, January 5, 2009

A Simple Clock using DS1307 + PIC16F877A

Even I have posted about "DS1307 + PIC16F877A", I didn't have chance to make a real prototype of the clock. I have done only on the simulation software. Today, I have received a comment about that post. ah_bear followed my code and schematic on that post but the clock didn't work. This is because the code on that post is for reading time from DS1307 so there must be some values in the DS1307 before you can read. The solution is simple. Just place setting time codes before reading codes.

This time, I have made a real prototype to confirm that it's working. There is no setting buttons. If you want to make a real usable clock you have to implement the button interfaces (I may make one and post it here). The photo of my working prototype is featured below. Please check out my flikr at http://flickr.com/photos/punkky/ for more photos.
A simple clock using DS1307 and PIC16F877A
The schematic of the clock is very simple. Please note that the schematic does not show power supply to the PIC16F877A and the DS1307, you have to connect them by youself. If you are new to PIC/LCD interface please see MikroC "Hello World!" LCD example .
Schematic of a simple clock using DS1307 and PIC16F877A

The source code:
//Sample code for
//DS1307 RTC Interfacing with PIC16F877A
//Coded by punkky@gmail.com
//Compiler: mikroC 8.0.0
//http://picnote.blogspot.com
//05/01/2009
//Use with your own risk

unsigned short read_ds1307(unsigned short address );
void write_ds1307(unsigned short address,unsigned short w_data);
unsigned short sec;
unsigned short minute;
unsigned short hour;
unsigned short day;
unsigned short date;
unsigned short month;
unsigned short year;
unsigned short data;
char time[9];
char ddate[11];

unsigned char BCD2UpperCh(unsigned char bcd);
unsigned char BCD2LowerCh(unsigned char bcd);

void main(){

I2C_Init(100000); //DS1307 I2C is running at 100KHz
PORTB = 0;
TRISB = 0// Configure PORTB as output
TRISC = 0xFF;
Lcd_Init(&PORTB); // Initialize LCD connected to PORTB
Lcd_Cmd(Lcd_CLEAR); // Clear display
Lcd_Cmd(Lcd_CURSOR_OFF); // Turn cursor off
Lcd_Out(11"TIME:");
Lcd_Out(21"DATE:");

//Set Time
write_ds1307(0,0x80); //Reset second to 0 sec. and stop Oscillator
write_ds1307(1,0x10); //write min 27
write_ds1307(2,0x01); //write hour 14
write_ds1307(3,0x02); //write day of week 2:Monday
write_ds1307(4,0x05); // write date 17
write_ds1307(5,0x01); // write month 6 June
write_ds1307(6,0x09); // write year 8 --> 2008
write_ds1307(7,0x10); //SQWE output at 1 Hz
write_ds1307(0,0x00); //Reset second to 0 sec. and start Oscillator

while(1)
{
sec=read_ds1307(0); // read second
minute=read_ds1307(1); // read minute
hour=read_ds1307(2); // read hour
day=read_ds1307(3); // read day
date=read_ds1307(4); // read date
month=read_ds1307(5); // read month
year=read_ds1307(6); // read year

time[0] = BCD2UpperCh(hour);
time[1] = BCD2LowerCh(hour);
time[2] = ':';
time[3] = BCD2UpperCh(minute);
time[4] = BCD2LowerCh(minute);
time[5] = ':';
time[6] = BCD2UpperCh(sec);
time[7] = BCD2LowerCh(sec);
time[8] = '\0';

ddate[0] = BCD2UpperCh(date);
ddate[1] = BCD2LowerCh(date);
ddate[2] ='/';
ddate[3] = BCD2UpperCh(month);
ddate[4] = BCD2LowerCh(month);
ddate[5] ='/';
ddate[6] = '2';
ddate[7] = '0';
ddate[8] = BCD2UpperCh(year);
ddate[9] = BCD2LowerCh(year);
ddate[10] = '\0';

Lcd_Out(1,6,time);
Lcd_Out(2,6,ddate);
Delay_ms(50);
}
}

unsigned short read_ds1307(unsigned short address)
{
I2C_Start();
I2C_Wr(0xd0); //address 0x68 followed by direction bit (0 for write, 1 for read) 0x68 followed by 0 --> 0xD0
I2C_Wr(address);
I2C_Repeated_Start();
I2C_Wr(0xd1); //0x68 followed by 1 --> 0xD1
data=I2C_Rd(0);
I2C_Stop();
return(data);
}

unsigned char BCD2UpperCh(unsigned char bcd)
{
return ((bcd >> 4) + '0');
}

unsigned char BCD2LowerCh(unsigned char bcd)
{
return ((bcd & 0x0F) + '0');
}
void write_ds1307(unsigned short address,unsigned short w_data)
{
I2C_Start(); // issue I2C start signal
//address 0x68 followed by direction bit (0 for write, 1 for read) 0x68 followed by 0 --> 0xD0
I2C_Wr(0xD0); // send byte via I2C (device address + W)
I2C_Wr(address); // send byte (address of DS1307 location)
I2C_Wr(w_data); // send data (data to be written)
I2C_Stop(); // issue I2C stop signal
}