Showing posts with label Microcontroller. Show all posts
Showing posts with label Microcontroller. Show all posts

Saturday, April 30, 2011

Digital Clock Using PIC16f628a Microcontroller

This is a very basic digital clock that can be done using a microcontroller. I particularly used a PIC16f628a.

You can also check my digital clock based on 74ls90
here --> http://circuitdesolator.blogspot.com/2010/12/digital-clock-based-on-74ls90.html

Here's the picture of my digital clock prototype




This is the schematic of the device:



 Notes to remember:

1. Put resistors from 7447 to the seven segment display pins(a-g) as current limiter resistors
2. You need to start up you're clock at exactly 1200am/pm.



-------------------------------------------SOURCE CODE-----------------------------------------------
//Digital Clock using PIC16f628a microcontroller
//Design by: circuit_desolator
//Date: April 2011

#include<htc.h>

#define _XTAL_FREQ 4000000

__CONFIG(INTIO & WDTDIS & PWRTDIS & UNPROTECT & BORDIS & LVPDIS);

unsigned int hours = 0;
unsigned int mins = 59;

unsigned int timer = 0;
unsigned char mpx_cnt = 0;
static unsigned char mode = 0;

void interrupt ISR(void)
{   
       
            {       
            timer++;
           
            if(timer > 19650)
            {
                mins++;   
                if(mins == 60)
                {           
                    mins = 0;
                    hours++;
                    if(hours == 13)
                    hours == 1;                   
                }
               
                timer = 0;
            }
        }
       
        switch (mpx_cnt)
        {
            case 0:
                PORTB = hours/10;
                RA0 = 1;       
                mpx_cnt = 1;
               
            case 1:
                PORTB = hours%10;
                RA1 = 1;       
                mpx_cnt = 2;
           
            case 2:
                PORTB = mins/10;
                RA2 = 1;       
                mpx_cnt = 3;
           
            case 3:
                PORTB = mins%10;
                RA3 = 1;
                mpx_cnt = 0;
        }
   
        T0IF = 0;                //clear TMR0 interrupt flag   
}


void init_Timers(void)
{
    GIE = 0;               
   
    T0CS = 0;               
    PSA = 0;                                           
    PS2 = 0;              
    PS1 = 0;              
    PS0 = 0;

    T0IF = 0;               
    T0IE = 1;                  
    TMR0 = 6;                                                                                               
   
    GIE = 1;             
}

void main()
{
    TRISA = 0x00;
    TRISB &= ~0x0F;
    TRISB |= 0xF0;
   
    init_Timers();
   
    while(1);
}

---------------------------------------SOURCE CODE--------------------------------------------

Monday, February 7, 2011

Quiz Bee Buzzer Circuit using PIC16f628a

This is a simple simulation on implementing a Quiz Bee Buzzer using a PIC microcontroller. 




*source code to be followed..

Tuesday, January 18, 2011

PIC Uart to PC's Serial Port Communication Circuit

This is a simple circuit for communicating PIC to PC's Serial Port

It uses a hardware UART of PIC16f628a. A level converter used is a max232 chip.

Please refer to the datasheet of both IC to check its vcc and ground pins.

Here's the schematic:

Sunday, January 9, 2011

PIC based PS/2 AT Keyboard Decoder

I constructed a simple PIC based PS/2 AT Keyboard Decoder that is frequently used as an input device to different electronic projects.

Tuesday, December 28, 2010

Terminal by bray(br@y++)

It's been a while since I play around UART communication between a microcontroller and PC's COM Port.I always use the Hyperterminal in Windows XP(Windows 7 doesn't have a default terminal application) but when I found the terminal created by bray. I find it better to use.

You can download it here.

Terminal by bray