Quantcast
Channel: Clock - Timer Projects - PIC Microcontroller
Viewing all 218 articles
Browse latest View live

PIC16F84A based digital clock using LCD display (Code+Proteus simulation)

$
0
0

This post provides a simple digital clock implementation using PIC16F84A microcontroller and an LCD display. This code is written in C language using MPLAB with HI-TECH C compiler. You can download this code from the ‘Downloads‘ section at the bottom of this page.

PIC16F84A based digital clock using LCD display

In this article, it is assumed that you know,

  • How to interface LCD with PIC16F84A microcontroller. If you don’t then please read this page.
  • How to configure timer0 of PIC16F84A microcontroller.  If you don’t then please read this page.

The result of simulating the code in Proteus is shown below.

The above figure was taken after 1 minute and 6 seconds of code simulation in Proteus. In the code, timer0 is used as the base for digital clock generation. Timer0 is used here to generate 1msec interrupts. After every 1msec a global variable named msCounter increments. When msCounter reaches a value of 1000 then another global variable named secCounter increments and this process repeats itself. Similarly, when secCounter reaches 60, then  minCounter increments. And when minCounter reaches 60 then hrCounter increments. This process continues until hrCounter reaches 24 then all of these variables reset their values. LCD is updated with the new values of hrCounterminCounter and secCounter after every second.

A crystal of 4MHz value is used in this circuit, which makes this PIC16F84A run at a speed of 1MIPS (Million of instructions per second).

Code

The main function code is shown below.

In the main function, firstly LCD is initialized using InitLCD() function. Then Timer0 is initialized to generate 1msec interrupts. After that, in the while(1) loop, whenever msCounter reaches a value of zero[1], then new values of hrCounterminCounter and secCounter are updated on the LCD. UpdateTimeCounters() function is called every time and it corrects the values of every counter variable depending upon the value of msCounter, which is incremented in the ISR function of timer0 (shown below).

 PIC16F84A based digital clock using LCD display schematic

Downloads

Digital clock display code using PIC16F84A was compiled in MPLAB v8.85 with HI-TECH C v9.83 compiler and simulation was made in Proteus v7.10. To download code and Proteus simulation click here.

The post PIC16F84A based digital clock using LCD display (Code+Proteus simulation) appeared first on PIC Microcontroller.


PIC12F675 based digital clock using LCD display (Code + Proteus simulation)

$
0
0

This post provides a simple digital clock implementation using PIC12F675 microcontroller and an LCD display. This code is written in C language using MPLAB with HI-TECH C compiler. You can download this code from the ‘Downloads‘ section at the bottom of this page.

PIC12F675 based digital clock

In this article, it is assumed that you know,

  • How to interface LCD with PIC12F675 microcontroller. If you don’t then please read this page.
  • How to configure timer0 of PIC12F675 microcontroller.  If you don’t then please read this page.

The result of simulating the code in Proteus is shown below.

The above figure was taken after 1 minute and 13 seconds of code simulation in Proteus. In the code, timer0 is used as the base for digital clock generation. Timer0 is used here to generate 1msec interrupts. After every 1msec a global variable named msCounter increments. When msCounter reaches a value of 1000 then another global variable named secCounter increments and this process repeats itself. Similarly, when secCounter reaches 60, then  minCounter increments. And when minCounter reaches 60 then hrCounter increments. This process continues until hrCounter reaches 24 then all of these variables reset their values. LCD is updated with the new values of hrCounter, minCounter and secCounter after every second.

PIC12F675 based digital clock schematic

Code

The main function code is shown below.

Downloads

Digital clock display code using PIC12F675 was compiled in MPLAB v8.85 with HI-TECH C v9.83 compiler and simulation was made in Proteus v7.10. To download code and Proteus simulation click here.

 

For more detail: PIC12F675 based digital clock using LCD display (Code + Proteus simulation)

The post PIC12F675 based digital clock using LCD display (Code + Proteus simulation) appeared first on PIC Microcontroller.

A Real Time Clock using PIC16F88 Microcontroller

$
0
0

This PIC project uses an I2C Real Time Clock IC (DS1307) and a four digit seven segment display to create a standard desk clock.

Note: If you typed DS1703 Real Time Clock to find this page you probably mis-spelled the chip type. Anyway you can find a DS1307 (RTC) Real Time Clock IC project and information here.

A Real Time Clock

Real Time Clock IC : DS1307

Although the PIC16F88 has a built in oscillator for a 32kHz watch crystal a DS1307 is easier to use on a bread board. This is because you can control the layout of the circuit more easily.

The RTC also makes the software easier as it takes care of all calendar functions; accounting for leap years etc.

The DS1307 (RTC) Real Time Clock IC (an I2C real time clock) is an 8 pin device using an I2C interface (although the data sheet does not mention I2C to avoid royalty payments!). It has 8 read/write registers that store the following information:

Address Register function
0 Seconds 0-59
1 Minutes 0-59
2 Hours 0-24,1-12
3 Day 1-7
4 Date 1-31
5 Month 1-12
6 Year 0-99
7 Control

Note: Addresses 0x08 to 0xf3 are user RAM and if you use a backup battery these are then non volatile ram i.e. they will save their contents after the power is off – so you have an extra 56 bytes of ram to play with!

Note: Address 3f is used in this project as a check to see if the clock needs initialising and to store the upper year digit (for easier coding).

The last address 0x08 is the CONTROL address and it determines what is generated at the SQW/OUT pin. You can control the level directly via I2C or set it to 1Hz, 4096Hz, 8192Hz, or 32768kHz.

In the same way as the I2C pins you need to add a pull-up to V+ at the SQW/OUT pin to see any output signal as it is an open drain output!

Real Time Clock IC : Embedded control bits

There are two specific ‘gotcha’ type controls embedded in the addresses which make using the chip slightly more complicated.

Real Time Clock IC DS1307 : Clock halt

The most important is the Clock Halt Bit (CH) which is bit 7 of address 0. This is the regeister that controls ‘seconds’ and the CH bit has to be preserved otherwise the chip stops the clock. Writing zero to this bit resets the CH bit so that the clock runs.

You have to reset the CH bit to zero to let the chip operate!

Real Time Clock IC DS1307 : 24/12 Hour control

The second is the 24/12 hour control which is bit 6 of address 2. It is set high for 12 hour mode and low for 24 hour mode.

The problem with these two bits is that you have to preserve them when accessing the registers to write data and ignore them when reading out values for display. Its not a big problem and you can see how it’s done when you look at the code.

Real Time Clock IC : 32kHz oscillator

Surprisingly making an accurate 32kHz oscillator is a difficult task (much more than a high speed oscillator e.g. a Mhz crystal oscillator). This is because low speed oscillator drivers are designed for low power operation. That means high impedance and therefore low current which makes the driver extremely sensitive to noise (or any nearby signals which can capacitively couple to the crystal wire).

Using the DS1307 lets you put the crystal in the least noisy part of the board. In addition it sets the crystal load capacitance which is critical in making the crystal oscillate at exactly 32kHz – controlling its initial error i.e. for the specified ppm error value the load capacitance must be exact.

Note: A common way of calibrating a crystal (not in this project) is crystal pulling or changing the capacitance at one crystal pin relative to the other – so load capacitance is crucial.

The DS1307 loads the crystal with 12.7pF so you need to buy a crystal that is defined to use this load capacitance. Circuit layout also affects the capacitance at the crystal pins so you must keep the crystal as close as possible to the chip and the tracks from crystal to chip must be short.

For more detail: A Real Time Clock using PIC16F88 Microcontroller

The post A Real Time Clock using PIC16F88 Microcontroller appeared first on PIC Microcontroller.

Making your own Digital Clock using PIC16F887

$
0
0

Small LED dot matrix development board

I was very busy for the past two months so this blog just didn’t move.

Digital Clock using PIC16F887

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 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

The schematic is as the following:

Digital Clock using PIC16F887 schematic

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).

 

For more detail: Making your own Digital Clock using PIC16F887

The post Making your own Digital Clock using PIC16F887 appeared first on PIC Microcontroller.

A Simple Clock using DS1307 and PIC16F877A

$
0
0

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.

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 .

Simple Clock using DS1307 and PIC16F877A schematic

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
}

Source : A Simple Clock using DS1307 and PIC16F877A

The post A Simple Clock using DS1307 and PIC16F877A appeared first on PIC Microcontroller.

Making a Digital Clock using PIC16F628A

$
0
0

Please check the update at === Digital Clock Updated Version ===

— Original Version —
As I am a WIS so I built a clock as my first microcontroller project.

The clock is controlled by PIC16F628A from the PIC book . The idea was making a digital clock with hour, minute and second display. I just wanted to learn about microcontroller so the accuracy of the clock was not an issue (yet). However, I was trying to make it the most accurate as possible by using Timer1 Module of the PIC.

Digital Clock using PIC16F628A
Timer1 Module (TMR1 Register)

The Timer1 Module is a 16 bit counter. It counts from 0x0000 to 0xFFFF and rolls over to 0x0000. The TMR1 interrupt is generated on overflow of the TMR1 register. More information about TMR1 is available in the data sheet of the PIC. In my clock, the PIC is running with 20MHz crystal so the internal clock is 5MHz. So, the duration between each TMR1 increment is 1/5000000 = 0.2 µs . That means TMR1 will overflow every 0.2 µs x 65536 = 0.0131072 s. If I count number of overflows to 77 times, I will get 1.0061744 s which is close to 1 second but the clock will gain about 6ms every second. The result will be a fast running clock (gaining about 9 min/day) .

To get a better accuracy, I make TMR1 counts to 62500 and set prescaler of the TMR1 to 1:8 (How these 62500 and 1:8 come? I did guess and test) . From these settings, the TMR1 will overflow every 1/5000000 x 8 x 62500 = 0.1 s. Counting number of overflows to 10 will yield 1 second. Just perfect huh!

Making Timer1 counts to 62500

It's easy. Just make it starts counting at 65536-62500 = 3036 = 0x0BDC by setting: (MikroC compiler)
TMR1L = 0xDC; //Write TMR1L first to reduce timing error. TMR1H = 0x0B;

Digital Clock using PIC16F628A schematic
Setting TMR0 requires 2 clock cycles but I have no idea about how many cycles required for setting TMR1L. If 2 cycles were required for setting TMR1L, I should set TMR1L to 0xDC+2 = 0xDE so my clock will run more accurate. The frequency drift in the crystal is also a source of inaccuracy of the clock. The time drift from crystal can be calculated by using data from data sheet of the crystal. Normally, it says 20ppm (Part-Per-Million). That means the crystal will produce error about 20 s. in 1,000,000 s. or about 1.7 s./day.

 

For more detail: Making a Digital Clock using PIC16F628A

The post Making a Digital Clock using PIC16F628A appeared first on PIC Microcontroller.

Analog & Digital propeller clock using PIC16C84

$
0
0

An Analog & Digital propeller clock i made!
It isnt Real its just because your so awfully slow!!! 😉

based on an afterimage phenomenon, ie the reaction slowness of the retina, the illusion of reality our brains are “lying”
Picture’s made 12-12-1997 by Luberth Dijkman Clock was actually running 2 weeks earlyer

Bob Blick started the propeller clock

This clock is based on Don Zehnder’s Clock. He made the first analog version (+/- 1996)

Analog & Digital propeller clock

Some technical information!

Assembler Code written by Don Zehnder
This clock has 14 red led’s & 1 Green
(red diffused 200 to 300 Mcd Kingbright L-53-SRD-D)
I prefer difused LEDs as they are better vissible from the side(angle)
Bright LEDs are perfect only when you look/stand straight in front of it
Tommorow (13-12-’97)i wil try red diffused 700 to 1000 Mcd Kingbright L-53-SRD-G
Nowadays(2002)a large choice, back in 1997 it was a bit harder to get ultra bright led’s
The propeller is mounted on a “Mecano”(Kid’s metal construction) base
7 outher led’s are controlled direct from pic’s port
8 inner led’s are together switched by a transistor
The moter comes out a Philips VCR VR 2022 two of them in 1 recorder
A 4mhz pic16c84 is clocked at 10 mhz
Later i made a brush/slipring the balbearing give too much errors
Rotation pulse is given by infrared gate
Time setting is done with a reed switch (when a magnet apears near propellor time speeds up)

Luberth Dijkman Andijk Holland 12-12-1997

 

For more detail: Analog & Digital propeller clock using PIC16C84

The post Analog & Digital propeller clock using PIC16C84 appeared first on PIC Microcontroller.

Interfacing DS1307 Real time clock with PIC16f877

$
0
0

In any advance project we need real time clock synchronize with our work and for this purpose the best option is DS1307 (RTC Ic). Interfacing DS1307 Real time clock with PIC16f877 is done by I2C communication. To know I2C protocol you may refer my previous post “Interfacing external EEPROM with PIC Microcontroller”.  To know about Interfacing DS1307 Real time clock with PIC16f877, we should know something about DS1307 IC.

Real time clock ( DS1307):

The DS1307 serial real-time clock (RTC) is a low-power, full binary-coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM. Address and data are transferred serially through an I2C, bidirectional bus. The clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The date at the end of the month is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The DS1307 operates as a slave device on the I2C bus. Access is obtained by implementing a START condition and providing a device identification code followed by a register address. Subsequent registers can be accessed sequentially until a STOP condition is executed.

Interfacing DS1307 Real time clock with PIC16f877 schematic

Project Description:

In this project we will see how we interfaced DS1307 with pic16f877 via I2C protocol. After interfacing DS1307 we recive the data from DS1307 and display it on LCD. Weall ready know before that DS1307 is send data in full BCD format. So we have to convert this data in digit and send to display on LCD.

Now question is how we convert BCD number to 4 bit number?

For getting higher nibble we use command

return ((bcd >> 4) + ‘0’) : it means the number will be Binary Right Shift 4 times with loading zero on left side.

For getting Lower nibble we use command

return ((bcd & 0x0F) + ‘0’) : it means we did and operation 0F with BCD number.

 

For more detail: Interfacing DS1307 Real time clock with PIC16f877

The post Interfacing DS1307 Real time clock with PIC16f877 appeared first on PIC Microcontroller.


Circuit Digital Clock Using PIC16f628a Microcontroller Schematics

$
0
0
Category : circuit » circuit Electronics » Electronic schematics » electronics » Electronics Board » MICROCONTROLLER » schematics 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://www.circuitlab.org/2008/12/digital-clock-based-on-74ls90.html Read more: http://www.circuitlab.org/2008/04/circuit-digital-clock-using-pic16f628a.html#ixzz3Vw1q4xHz ….

You need to start up you’re clock at exactly 1200am/pm.
Circuit Digital Clock Using PIC16f628a Microcontroller Schematics——————————————-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
}
Circuit Digital Clock Using PIC16f628a Microcontroller Schematicsvoid 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——————————————–

 

For more detail: Circuit Digital Clock Using PIC16f628a Microcontroller Schematics

The post Circuit Digital Clock Using PIC16f628a Microcontroller Schematics appeared first on PIC Microcontroller.

Digital Alarm Clock Schematic using pic microcontoller

$
0
0
Electronics lesson: electronic parts, electronic components, electronic projects, circuit diagram and more

Digital Alarm Clock Schematic

You are browsing the search results for “Digital Alarm Clock Schematic”

Verilog & fpga project : digital clock alarm , Hello friends, here i am going to upload a very simple digital clock project. this system contains all the basic features of a digital clock. Alarm clock – wikipedia, free encyclopedia, An alarm clock (or sometimes just an alarm) is a clock that is designed to make a sound, or some other signal, at a specific time. the primary utility of these clocks. Digital alarm clock / timer 87 led – electronic kits, Digital clock w/ 24 hour timer (kit or assembled) digital clock with 24 hour timer (click picture to enlarge) digital clock with 24 hour timer – kit and assembled.

Lcd based digital alarm clock 8051 microcontroller, An alarm clock clock pre-set time producing sound time. functionality digital clock awaken people remind . http://www.engineersgarage.com/microcontroller/8051projects/LCD-digital-alarm-clock-AT89C51-circuit Parts digital alarm clock | ehow – ehow | , Parts digital alarm clock. alarm clocks awakened patented 1847. today, modern alarm clocks digital. http://www.ehow.com/about_5380906_parts-digital-alarm-clock.html Digital zen alarm clock® | digital alarms clocks | , Digital zen alarm clock ® digital zen clock perfect companion natural lifestyle. long-resonating acoustic chime set solid hardwood case. http://www.now-zen.com/Digital_Zen_Alarm_Clock.html

Digital Alarm Clock Schematicis display is common cathode (the cathode of all segments joined to each other) and connect as follows : anode segment ‘a’ of each of the displays are connected together. anode segment ‘b’ of each of the displays are connected together, the anode of the segment ‘c’ of each of the displays are connected together …. and so on with all the segments. And cathode (common) of each display separately to a different transistors. Continue reading Digital alarm clock project

 

For more detail: Digital Alarm Clock Schematic

The post Digital Alarm Clock Schematic using pic microcontoller appeared first on PIC Microcontroller.

200 Water Street WWVB Clock

$
0
0

A digital LED clock inspired by the building at 200 Water Street in Manhattan, that automatically synchronizes with the 60 kHz WWVB Signal.

Figure: Final Design

High Level Design

Rationale:

The purpose of this project was to design a digital LED clock influenced by the large clock on the building at 200 Water Street in lower Manhattan. Jason has always wanted to create an homage to this clock since he finds the design inspiring. Jason and Eldar decided build a wall clock for their final project using the 200 Water Street Clock design. They were motivated to create a functional piece of technology that adds color, vibrance, and time to any room.

Overview:

This project was implemented on a PIC32 Microcontroller using the Small Development Board used in class, that has an external oscillator keeping time with accuracy of ±1 minute per year, and the WWVB receiver for setting the time whenever the signal can be received. Time is a displayed on a panel in front of 72 Adafruit DotStar LEDs. The clock takes input from three Push-Down Buttons that select the mode of operation: Time, Date, and Temperature.

Standards:

The WWVB signal is transmitted one bit per second, taking 60 seconds to send the current time of day and date within a century. Information is encoded using amplitude modulation with the following scheme:

      • If power is reduced for one-fifth of a second (0.2 s), this is a data bit with value zero.
      • If power is reduced for one-half of a second (0.5 s), this is a data bit with value one.
      • If power is reduced for four-fifths of a second (0.8 s), this is a special non-data “marker,” used for framing.

Markers are sent during seconds 0, 9, 19, 29, 39, 49 and 59 of each whole packet. The start of the second of two consecutive markers indicates the top of the minute, and serves as the on-time marker for the next frame of time code. Markers are important to allow receivers to properly frame the time code.

Figure: WWVB Code2

Hardware and Software Trade-offs:

Originally the focus of the project was on updating the clock using the WWVB signal relying on hardware and its integration. However, after more research and testing it was clear that the signal is quite unreliable due to the fact that it is a very weak signal and too much noise is injected into that bandwidth by our location on a highly technically advanced campus. The only antenna/receiver that was available for purchase was chosen and there were no other hardware options to explore at that point. At this point the focus was shifted to add more hardware in the form of an oscillator – which dramatically improved the accuracy of timekeeping and nearly eliminated the need for updating using WWVB. The updates can now be also provided by an Arduino that sends the correct time to the PIC32. Additionally, since the project was inspired by a piece of visual art, we put in extra effort in making it aesthetically pleasing, e.g. using wood instead of cardboard and eliminating the leaking of light between the LEDs by creating individual housing for each LED. DotStar LED strips were chosen as opposed to the NeoPixels, because they were easier to program, had better documentation, though they were more expensive. Additionally their implementation was complicated due to having to solder them with short wires having researched possible problems with using longer wires between cut strips. Additionally a level shifter had to be added, because the DotStars Clock and Data inputs were 5V and PIC32 outputs were 3.3V.

Patents:

No existing copyrights or trademarks or patents were found similar to our design. The digital clock on the building at 200 Water Street was designed by Rudolph de Harak, an American modern designer who worked in numerous mediums. Our design is an imitation of that of the artist’s, and not original in the visual implementation. However, it is original in it’s electronic and hardware implementation.

High Level Block Diagram:

Figure: Block Diagram

Hardware

Schematic:

Figure: Simplified Schematic

WWVB Receiver5:

In order to receive the WWVB signal, we purchased a 60 KHz WWVB atomic radio controlled clock receiver from Universal-Solder. We chose this part because it is the only WWVB receiver currently available on the market. The receiver is attached to a 100 mm ferrite core antenna.

DotStars6:

DotStar LED strips were purchased from adafruit to light all the number of clock. 30 LEDs per meter strips were purchased in order to space out each in its own box. The DotStars supported 8-bit RGB color, which allows us extreme flexibility for color choice. The other reason we decided to use the DotStars was for their simple and reliable communication protocol via SPI.

For our implementation the clock numbers were displayed on the face of the clock ordered from left to write, top to bottom, wrapping around from the end of right row to the beginning of left. In order to wrap the LED strip, however, we couldn’t have long wires stretching across, and therefore, wrapped the LED strip around alternating sides of the box, see table below. Clock Number (in red), LED number (in blue):

Figure: DotStar Address Table

However, our implementation was more scalable than creating a table and saving it as a constant. We created functions to go from hours and minutes to LED location using modular arithmetic. Thus, if this project were implemented with more LEDs, we could easily extend our functions to address the additional LEDs added to the matrix.

The DotStar strips were driven and powered by 5 V. Powering them was not an issue since all our other components also used 5 V. But in order to drive them from the PIC32, we were required to use a voltage level translator (74LS125AN)7 to convert the 3.3 V signal to 5 V.

Figure: Voltage Level Translator3

Oscillator9:

The DS32KHZS#-ND 32.768kHz oscillator was used in order to implement the Real Time Clock Calendar RTCC functionality.. This specific value is convenient because it is exactly 215 and makes a 16 bit timer overflow exactly once a second. The specifications of the oscillator indicate that it’s error is only ±1 minute per year while operating under moderate climate temperatures (0 – 40 ºC). The oscillator outputs a 5 V square wave, that is connected in series with a 620 Ω resistor to pin12 on the small board. Despite being a 5 V signal the current in the oscillator’s output is only 150 µA. We decided to not use a voltage divider or level shifter to guarantee the fastest time.

Power Supply10:

In our project, nearly all devices use 5 V power. We purchased a 25W single output power supply made by Mean Well. It takes 120 V AC from a wall outlet and outputs 5 V DC. We decided to use a 25 W power supply to give provide a maximum of 5 A of current to power DotStar strip, which can pull a maximum of 4.32 A.

Temperature Sensor8:

When designing our project, we wanted to add functionality in addition to time keeping. We settled on temperature because it is very easy to display room temperature in degrees celsius using the minute boxes. We used a LM35 analog temperature sensor to read ambient temperature. The LM35 uses a linear scale factor of +10 mV/°C and it is has ensured Accuracy of 0.5 °C at normal room temperatures (25 ºF).

Housing:

The housing was built out of a combination of plywood sheets and softwood planks. The front panel was a piece of ¼” plywood that was laser-cut at the Cornell RPL to represent the numbers, it was later drilled from the front and the back to install the buttons. The back face was a piece of ¼” plywood that was drilled in the back for the ventilation of the power supply. The sides of the frame were half inch thick pieces of softwood, drilled on the bottom to hold the power supply in place, and on the left for the 120V AC chord path. The AC chord consisting of line, neutral, and ground cables was additionally secured by zip-ties on either side of the left wall to ensure that if it were pulled it wouldn’t come out of the power supply-causing electrical damage and endangering the user. The LED strips were hot-glued to the back face. A housing was created for each separate LED light in order to prevent light leaking into other numbers when diffusing onto the face. Long horizontal ribs (6 of them) were made out of ¼” plywood and cut on a band-saw gto fit into the box. Short vertical ribs (66 of them) were laser cut out of pieces of leftover scrap ¼” plywood. The rips were fitted in to house the lights and hot-glued in place.

Figure: Clock Front Panel

Software

Input Capture:

The WWVB transmits data by sending an amplitude modulated signal. The length of time the pulse is low determines the value of the symbol being transmitted. We use an input capture module to trigger on the first falling edge and then on every edge after. The input capture begins on a falling edge because the length of a WWVB pulse is determined by the time the signal is at -17dB, which in our case is a digital low value. We set up an interrupt service routine that records the time for a falling edge (the first signal that causes the input capture to trigger) and store sit into an integer, capture1. The input capture will then wait until it sees the next edge (which will be a rising edge) and it records the current time and stores it into another integer, capture2. Then we subtract capture1 from capture2 to calculate the length of the pulse, pulse_time. Additionally, increment counter that keeps track of symbol number in the current transmission. Several flags are also set here. For the falling edge we set ready to 0, indicating that time is not ready to be change. When it receives the rising edge, ready is back to 1. In the timer thread, the new symbol and time can only be set when ready is 1.

The input capture module is not able to determine whether the edge it is capturing on is high or low, therefore we set a bit back and forth to indicate which type of edge is next. This is possible because we defined the first trigger to be on a falling edge.

The input capture is very useful for calculating the time of pulses small pulses using the internal timers. Since we are calculating times in 100’s of milliseconds, even setting up an internal timer with the largest prescaler value when the processor is running at 40 MHz is not sufficient. Therefore, we opted to use the millisecond timer from protothreads12, PT_GET_TIME(), to calculate the time pulses. We feel that PT_GET_TIME() is sufficient because it takes approximately five weeks to overflow. If it does, overflow while decoding pulses, that pulse will be an error, and the Frame will need to restart.

Timer Thread

The timer thread is the heart of the entire program. It begins by checking to see if the input capture has triggered twice, starting with a falling edge followed by a rising edge. If it has, it will then use pulse_time to determine the symbol: 100 ms > pulse_time > 300 ms is a 0; 400 ms > pulse_time > 600 ms is a 1; 700 ms > pulse_time > 900 ms is a marker; Otherwise it sends an error. The symbols are then stored into an integer. If a marker symbol is received, we check if the previous symbol was also a marker, which indicates the start of the next frame. If this is the case, we set the bit number, bit_n, to 0 keep track of the position in the frame. We also check the capture_count to determine if time has been set. If has not been (capture_count == 0), we set capture_count to 1 and call input_time(). Calling this first input_time() sets the time and date to default values (date: 1/1; time 1:02). The yellow seconds indicator will begin to run, and it can be used as a countdown to when the entire dataframe will be received and the proper time and date are set. If the time is being recorded but has not been set (capture_count == 1), we set capture_count to 2 and call input_time(). Calling input_time() now will set the time and date to value it decoded from the WWVB signal.

After the symbol is determined from the pulse duration, the time is set by calling set_time(). The set_time() function takes in two parameters, the symbol and its number in the frame. We use 60 individuals case statements to based on the symbol number to decode time. For example, bits 12, 13, 15, 16, 17 and 18 in the frame are used for the hour values, 20, 10, 8, 4, 2 and 1 respectively (bit 14 is left at 0 ). If the sequence is:

Bit Number 12 13 14 15 16 17 18
Symbol 0 1 0 1 0 0 1

The hour will be 20*0 + 10*1 + 8*1 + 4*0 + 2*0 + 1*1 = 19 or 7 o’clock pm. We also use the set_time() function to check for errors in the received symbols.

The input_time() function mentioned above is what assigns the time and date to the RTCC structures (tm and dt). The function begins by converting the day of the year value to month and day values. Then RTCC the structures for time and date are assigned using the values from the set_time() function and a macro that converts integers to BCD format:

#define int2BCD(a) ((a/10)<<4)|(a%10)

Next, we call RtccSetTimeDate(tm.l, dt.l) to set the time and date for the RTCC periferal. Lastly, we clear the all the global time and date variables for the next time set_time() is run.

The final part of the thread is case statement based the on the mode of operation (time, date, or temperature). Based on which mode is chosen, a corresponding LED function is called to set the DotStar LEDs. Lastly, we call write_pixels() to send the LED color and brightness data via SPI. PT_YIELD_TIME_msec(10) is called to allow the Button thread time to execute.

LED Functions:

The DotStars use SPI to transfer the 32 bit LED data frames. The first frame is 32 bits of 0’s. Then each LED has its own data frame where the first 3 bits are 1, followed by a 5 bit value for the intensity level, then a 8 bit value for blue, green, and red. The last frame that is sent is 32 bits of 1’s, which indicate the end of transmission. Below is a visual representation of the protocol.

Figure: DotStar Protocol4

We use the example code from Bruce Land (brl4) Pixel Strip Displays example (link). The code contained a working SPI function to communicate with the DotStar LED strip of specified size and a data structure to format the color and intensity information of the LEDs. The SPI channel also outputs square wave clock signal for the SK9822 control IC in the DotStars can synchronize with the SPI. Once the LED data array is filled, write_pixels() is called and the DotStars are set.

Before write_pixels() can be called, the LED data array needs to be filled. We use three functions, time_to_led(), date_to_led(), and temp_to_led() to display the time, date, and temperature respectively, on the DotStars. For time_to_led(), parameters for the hour, minute and second are sent. Next we do calculate which LEDs are the hour, minute and second and write a unique color value to each of them, while giving the other LEDs a different color. The function is date_to_led() is identical to time_to_led() except it only takes parameters for month and day. The LED for month is set the same way that hour is set and day the same way minute is set. We black out numbers 00 and 32-59 since those are not possible dates. The last LED function is temp_to_led(), which receives a single parameter for temperature. The LED for temperature is then set the same way same way that minute and day are. An added feature of the temperature LED function is that the temperature “flickers” between the integer values to indicate the value that is nearest.

RTCC:

The real-time clock and calendar (RTCC) periferal on the PIC32MX250 is used to keep the time and date. It is able to keep accurate time using an external 32.678 KHz crystal oscillator. Without the external oscillator, RTCC would need to use the internal oscillator which is not very accurate (add spec?) In the config.h, we add #pragma config FSOSCEN = ON so the PIC knows to use the external oscillator.

Button Debounce Thread:

User input is received via 3 buttons that are connected to the Small Development Board. When depressed the buttons would short the PIC pins with Vcc through a voltage divider 680Ω/1680Ω from the 5V provided by the power supply resulting in approximately 3V. A protothread was used to “debounce” the buttons, to make sure that the input is read correctly. Every 30 milliseconds the buttons were polled to assess whether they had been pressed. The pins were set as digital inputs. Values from the previous poll were also kept to implement the following logic:

Previous Value Current Value Logic
Off Off None
Off On Press
On Off Release
On On Hold

There were 3 buttons that were implemented in this manner. The debounce functionality ended up being more robust than necessary as only the button presses were used to switch between the three different modes.

RTCC:

The real-time clock and calendar (RTCC) periferal on the PIC32MX250 is used to keep the time and date. It is able to keep accurate time using an external 32.678 KHz crystal oscillator. Without the external oscillator, RTCC would need to use the internal oscillator which is not very accurate. In the config.h, we add #pragma config FSOSCEN = ON so the PIC knows to use the external oscillator. The RTCC periferal is initialized in the main() function.

Main:

The main() function was used to set up the peripherals and threads that were used and described above. We set up the ADC channel (for the temperature sensor), SPI channel (to send the DotStar LEDs lighting data), Timer2 and InputCapture1 (to calculate WWVB Pulses), initialized the RTCC (To keep correct time using the external oscillator) and system wide interrupts. The SPI was set up for channel 2 and configured to send 32 bit values The SPI clock speed is divided by 16 to give small relative rise and fall times after the signal is level shifted to 5 V. Finally, we initialized the two threads, pt_timer and pt_buttons, and scheduled them to run in a round-robin format.

Results of the Design

WWVB Receiver:

After waiting for over four and half weeks to receive the WWVB receiver, it finally arrived. Unfortunately, we had tremendous difficulty using it and were unable to pick up any trace of a signal in Phillips Hall. Since the deadline was approaching, we decided to use an arduino board to simulate the WWVB signal. We found code online11 to do this. The arduino code sends a perfectly clear pulse modulated signal, that PIC has not trouble decoding.

Figure: Arduino Signal

From a black box perspective, the signal from the arduino and the signal from the WWVB receiver look totally identical. The arduino is a very powerful tool that we used to test time all types of time and date inputs to fix all errors we could find. Unfortunately, we were not able to build a clock that sets the time with absolutely no user input. We plan to continue working on the clock and find a solution for receiving a WWVB signal.

Time Keeping:

The PIC is able to keep very accurate time. We have left the time run side by side several other clocks for several hour periods and have not seen any difference in the time. This is very important because wall clocks are meant to remain on and function without stopping.

Design of Housing:

The laser cut numbers on the panel of the display make the numbers very sharp and easy to read. The Wood box is very strong, but the ribs that separate the individual number boxes and prevent light from leaking are not totally even. This presents no visual problem, but it would be nice for front and back panels to be totally flat.

Conclusions

Future Additions:

We designed the clock with the intent to upgrade and add new features and settings. Like any good engineering product, it has the ability to be upgraded and improved very easily. We compiled a list of additional functionality that we would like to implement in the future:

    • Add Self Calibration for the Oscillator
    • Add Better Error Correction – For instance, if a marker is the symbol that is supposed to be present at a specific bit, an error will thrown and the entire data frame will be discarded.
    • More Details Using the LEDs
      • AM / PM lighting effects
      • Use ours as a decimal place for temperature sensor
    • Adding Tetris or Connect 4 games
    • Faster Time Setting
      • Using location in frame to set time faster

Ethical Considerations:

Throughout all of the work that has been done on this project all of the limitations were checked and never exceeded. Before using any circuit it was checked for shorts and all soldering connections were double checked before applying voltage. All the data sheets were consulted and double checked to ensure correct connections and safe usage of materials and devices. We are not aware of any factors that might endanger the public or the environment throughout the use of our project. The power supply and it’s temperature and output were tested for prolonged periods of time to ensure safety. The cord connecting the power to the wall AC outlet was secured to the best of our ability to ensure that if it is pulled it does not apply stress to the connection with the power supply which could cause unsafe and unpredictable behavior. All of the concerns and problems faced by our team were disclosed to the instructor and the TAs, there were no conflicts of interest. No bribes of any kind were accepted by any of the team members. All of our findings throughout this project were reported to Bruce Land, the TAs, as well as fellow students. Before undertaking any technological tasks qualifications were taken into consideration and every time there was doubt about training or experience the TAs and the Instructor were consulted prior to carrying out the task. Honest criticism and errors were accepted and corrected respectively, feedback was sought throughout the project from teammates, fellow classmates, TAs, and Instructors. All of the resources that were used by the team were properly credited. All persons on the team were fairly treated regardless of their origin, beliefs, creeds, abilities, and/or identities. Any actions taken relating to this project were taken with caution to ensure safety of all those involved, others, their property, reputation, and employment. Assistance was provided by the teammates to better each others professional development and support them in following this code of ethics.

Legal Considerations:

There are no legal considerations that we are aware of in regards to this project. If this were to become a product that we were going to sell, we would need a legal consult on whether it is too similar to the building to be an original design and whether the artist/their family has that design copyrighted.

Safety and Usability:

The LED strip can draw a maximum of 4.32 A of current (60 mA per LED), which our 25 W power supply can provide. This can raise several concerns about the temperature when running for a long time. Changing the different functions will be done by pressing one of the three buttons on the bottom bar (see diagram ??). A model of the panel is given in ??. The antenna for the WWVB receiver is currently not in the clock because we unable to receive any type of signal from it. But if we are able to pick up a WWVB signal, it will most likely be placed at the top of the device.

Source: 200 Water Street WWVB Clock

The post 200 Water Street WWVB Clock appeared first on PIC Microcontroller.

Wooden LED clock using PIC16LF876A microcontroller

$
0
0

Wooden LED clock

I really like concept. So many different types of wooden clock have been already built. I’ve seen many of them but I still don’t have my own.

Wooden LED clock
What a shame. I’m going to fix it right now.
Project is very simple and requires only few common wooden materials and hand tools.
Well, part cabinets and scrap bin are over there… What can we use for this project?

– microcontroller (any kind);
– cheap real time clock;
– low power MOSFET transistors;
– bunch of super bright LEDs;
– pieces of plywood or MDF;
– few sheets of different veneer;

Clock case is not solid wood but MDF frame laminated by veneer.
Regular maple veneer is transparent enough and bright LED can shine through wooden surface.

Nicely finished wooden block is a beautiful decoration for geek’s room.
Multicolored lights glow deep inside wood constantly form different “alien” symbols an make device very unusual and attractive.
Yes, this clock has no digits. Instead lights of different color represent ones and tens of minutes and hours.

Step 1

Microcontroller

Clock controller assembled on a single sided PCB, made by  using proven heat toner transfer method.
Clock’s brain is based on PIC16LF876A microcontroller running at 10MHz.
Only function of microcontroller is to monitor two buttons and occasionally read data from real time clock and display time and date.

Clock displays current time by turning ON and OFF predefined number of LEDs of the same color. LED pattern is chosen randomly and microcontroller generates new LED pattern every second.

If button 1 is pressed clock shows current day and month in the same manner for a 30 seconds then switches back to time showing mode. Button 2 is used to activate time or date setting mode.

Real time clock is NJU6355 chip with 4-line serial interface and operating voltage 2 – 5V.
RTC is bundled with 32768 Hz watch crystal and 3V lithium coin cell battery CR 2032 as a backup power source.

Clock’s button are normally open tactile switches.
Buttons inputs are pulled up by 10K resistors and microcontroller reads logic “1” (high level) when button’s  released and logic “0” when button’s pressed.

LM7805 voltage regulator supplies 5V for whole unit. Since controller consumes low current and all LEDs are working in pulse mode, regulator stays cool and doesn’t need radiator.

Step 2

LED matrix

schematics Wooden LED clock

Bright LEDs of 4 different colors (amber, green, red and blue) are organized into 3 x 9 matrix.
3 columns are controlled by dedicated 2N7000 low power MOSFETs.
Maximum DC current for this type of MOSFET is 200 mA and all 9 LEDs in a column can be ON simultaneously.
9 rows are connected directly to microcontroller’s digital outputs.
LED matrix is assembled on a perforated board. All wiring is done by 24 gauge stranded wire.

Step 3

MDF box

Simple frame is made from narrow panels of 1/2″ MDF.
Before joining pieces together I’ve applied some carpenter’s glue to matching surfaces. Glue fills gaps and add extra strength to joint.

All parts fastened with 1″ wooden screws. To avoid material splitting I’ve drilled 1/8″ pilot holes for screws and made countersinks.

Front and back panels are made from 1/4″ MDF and attached to frame with glue and screws. Wooden putty can be applied over top of screw heads to make surface even and smooth.

As front window I’ve used piece of plastic grid from luminescent light fixture.
Window grid physically isolates LEDs, eliminates color mixing, forms nice illuminated dots and prevents front sheet of veneer from flexing inward. For better contrast grid is painted black.

Window frame is mounted flush with front surface and secured with hot glue.

For more detail: Wooden LED clock using PIC16LF876A microcontroller

The post Wooden LED clock using PIC16LF876A microcontroller appeared first on PIC Microcontroller.

Cooking Timer using PIC16F819 microcontroller

$
0
0

Cooking Timer

This is a school project but I thought it can be fun to all of you cooking people out there, that still use old stoves without timers.
The timer uses different formula for meat, chicken or egg, but also has a separate timer that can be activated manually.

Meat cooking time formula:
1 pounds – 35 min
2 pounds – 45 min
Every extra pound add 15 min
*500f for 15 min. buzzer bips once. than 380f for the rest of the cooking.

Chicken cooking time formula:
1 pounds – 40 min
2 pounds – 60 min
Every extra pound add 10 min
*400f for the whole time. ignor buzzer bip after 15 first min.

Egg cooking time formula:
Soft egg – 5 min
Hard egg – 11 min

Cooking Timer

Step 1: Materials

6 * small buttons – radio shack
switch – radio shack
back lit LCD display – parallax.com
buzzer
potentiometer
knob
a box

Universal Solderless Breadboard
6 * 470 Kohms resistors (red, black, orange, gold)
1 * 2 Kohms resistors (red, black, red, gold)
2 * .1�µF capacitors
1 * voltage regulator (7805)

For more detail: Cooking Timer using PIC16F819 microcontroller

The post Cooking Timer using PIC16F819 microcontroller appeared first on PIC Microcontroller.

1Hz Clock Generator using PIC12F675

$
0
0

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.

Clock Generator
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.
Schematic Clock Generator
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 ()

 

For more detail: 1Hz Clock Generator using PIC12F675

The post 1Hz Clock Generator using PIC12F675 appeared first on PIC Microcontroller.

A DCF77 Clock with RS232 Interface using PIC16F84

$
0
0

Description:

The clock is synchronised via the German time signal DCF77. It has a display with automatic brightness control and a RS232 computer interface.

Design Overview:

The clock is built around a PIC16F84 microcontroller from Microchip. I chose this microcontroller since its FLASH memory is easy to program and assembler and programmer software is freely available for GNU/Linux. It has 13 general input/output pins which is just enough to implement all the feature I wanted.

  • Display with Brightness ControlThe 6 7-segment LEDs are multiplexed with a frequency of 100 Hz. A simple combination of a 74138, 74247 and some transistors is used. With more I/O pins on the microcontroller, one could save the two chips but the current might be to high for a microcontroller.

    The brightness of the LEDs is controlled by the ambient light. This is achieved by varying their illumination time, also known as Pulse Width Modulation. Whenever a new 7-segment LED is switched on, a capacitor is discharged. The capacitor is then slowly charged. When the voltage at the capacitor gets higher than the reference voltage determined by the A1060 photocell, the display is blacked out.

DCF77 Clock

  • RS232 InterfaceThe hardware part of the RS232 interface is straightforward. Two pins of the PIC16F84 act as RX/TX, and MAX232 does the conversion from TTL to RS232 signal level.

    The software part is more interesting. Since the PIC16F84 does not have an USART, the coding and decoding of the serial signal is entirely done in software. This is suboptimal since the PIC16F84 does not have interrupts for any I/O pins, so the software must constantly poll the RX pin. You can get example code from Mircochip for this. But as a consequence, the main code for analysing the radio signal and driving the display is called from the RS232 code and is only allowed to use a limited amount of time. This amount of time available decreases with higher serial speeds, so the highest possible speed with this design is 1200 Baud. Next time I would definitely use a microcontroller with a build in USART.

  • Radio Signal ReceiverThe radio signal is demodulated with an U4224B by TEMIC Semiconductors. The digitised serial signal is displayed by a LED and fed into to PIC16F84. The U4224B together with the ferrite antenna are placed in a separate box to keep circuit noise emission from the antenna and to allow perfect alignment of the antenna.

 

For more detail: A DCF77 Clock with RS232 Interface using PIC16F84

The post A DCF77 Clock with RS232 Interface using PIC16F84 appeared first on PIC Microcontroller.


Precision Delay Timer for PIC16F628A

$
0
0

Description

This project is a crystal controlled precision timer providing accurate delays from 1 second to 15 hours 45 minutes.  The timer delay is set using a 10-way DIP switch.  The timer is started by pressing a switch on the main PCB or from an external switch connected via the terminal block connection.  A second switch and terminal block connection allow the timer delay to be cancelled.

There are two LEDs on board, one provides indication of the timer delay active, and the other is a blinking ‘heartbeat’ LED to show the timer is running.

The circuit provides a logic level timer output via a terminal block connection as well as the on-board relay for switching external loads.

Operation

The timer delay period is set using the 10-way DIP switch.  The DIP switch is used to select a time interval and multiplier to give the actual delay time.  As the length of the delay time increases the adjustment interval gets courser.

Precision Delay Timer

The timed delay is started by a falling edge at the Start input and can be cancelled at any time by taking the Clr input low.  In re-trigger mode, the time delay can be restarted while the timer is active.

Timed delay is started by a falling edge on the ‘Start’ input. This can be done in several ways:

  • Press the S1 ‘start’ switch on the board.
  • By external switch connected between the ‘Start’ and ‘Gnd’ connection of the terminal block
  • Logic level input at the terminal block

The Timed delay can be cancelled at any time by taking the ‘Clr’ input low.  This can be done in several ways:

  • Press the S2 ‘clr’ switch on the board.
  • By external switch connected between the ‘Clrt’ and ‘Gnd’ connection of the terminal block
  • Low logic level input at the terminal block

Examples below illustrate Precision Timer operation (examples use 5 second timer period)

Timer delay triggered by falling edge at Start input
While timer delay active, heartbeat LED blinks at 1Hz

Time Delay Restart mode

When the timer is running it can be set to re-trigger (restart) using DIP Switch 10.

When re-trigger is enabled, a falling edge (Start button pressed) while the timer is running will reset the timer back to the start of the delay period.  For example, if the delay period is 45 minutes and the timer is re-triggered after 20 minutes, the time period will be 20 minutes + 45 minutes giving a total timed delay of 65 minutes.  The timer can be re-triggered at any time while it is active and it can be re-triggered multiple times.

If the timer is set to Non-retriggerable, once the timed delay is active it cannot be retriggered and will time out when the preset delay period has elapsed.

 

For more detail: Precision Delay Timer for PIC16F628A

The post Precision Delay Timer for PIC16F628A appeared first on PIC Microcontroller.

Seven Segment Multiplexing using PIC18F4550 Microcontroller

$
0
0

As explained earlier, a seven segment interfaced with PIC uses almost an entire port (minimum 7 pins) to display a value. But a real time application, like watch, calculator etc., usually requires at least 3-4 seven segments. In such a case it is not advisable to use a port of the controller for each seven segment. In these cases, multiplexing technique is used to work with more than one seven segment. Here multiplexing of four seven-segments has been explained with PIC18F4550 to display four-digit count from 0000 to 9999.

The data pins (a-g) of all the seven-segments are connected to a single port (Port D*) as shown in the circuit diagram. Transistors BC547 are connected to COM pins of seven-segment for switching. The switching of COM pins is controlled by four pins of PortA.

 Seven Segment Multiplexing
*Please note that the pins of PortD are not continuous and care has to be taken while making the connection.
The multiplexing concept is based on the principle of persistence of human vision. A human eye cannot detect a visual change if the frames change at a rate of 25 (or more) frames per sec. This means that if events occur continuously with a time difference of less than or equal to 0.04 sec (1/25 sec), then we cannot notice the transition between those events.
Considering this, the seven-segments are switched on one by one with a very small time delay. Thus, even though only one segment glows at a time, it appears that all the segments are glowing together. (See video) Thus the key factor in multiplexing is switching time of the segments.
Programming steps:
·         The count value to be displayed is stored in a variable.
·         Extract the individual digits from the count value into different variables.
·         Turn on the seven-segments one by one with a small time delay.
·         Send the hexadecimal values corresponding to individual digits to PortD.

The post Seven Segment Multiplexing using PIC18F4550 Microcontroller appeared first on PIC Microcontroller.

Lift Counter using PIC12F629 Microcontroller

$
0
0

This project has been developed due to a request from Mr Moshweunyane (dmoshweunyane8@gmail.com). He asked for a circuit that would count up when someone entered a lift and count down when someone exited, using two infra-red sensors.
All we had to do was take the 2-digit up/down counter and add two optical sensors.
These sensors could be any type of detector and we have shown two LDR’s (Light Dependent Resistors) and two amplifying transistors mounted on a sub-board. You can use infrared or photo-transistors as the sensors to get equal results.
All the “detection” is done via the software and the program “polls” the detectors and works out if a person is entering or leaving the lift.

Lift Counter
The reason for polling the sensors is clever. It prevents the micro being caught in a loop and allows the program to display numbers at the same time.
The same design can be used for a shop or any activity where you need to know if a room is getting too crowded.
This arrangement has been requested for bathrooms in an attempt to control and avoid unsavory behavior.
The circuit is designed around a PIC16F628A. It has been presented on an experimental PC board using surface-mount components and was built in less than 1 hour, with about 2 hours to write and finalise the program.
It uses “In Circuit Programming” via PICkit-2 or Talking Electronics Multi-Chip Programmer, plus the adapter (specific to each programmer) shown below.
You can add an alarm feature if the lift gets overcrowded or if someone is in the bathroom when the shop is closing.

This project has been created as an add-on for the 2-Digit Counter. We placed the two transistors, LDR’s and pots on a small PC board and connected it to the 2-Digit Counter via a plug and socket.

The light detectors have to be set up for the application. The best is to use infra-red detectors as they are not upset by ambient light.
Each detector has to be set up so that light falling on the detector makes the input line LOW.
When the beam is broken, the line goes HIGH.
We have directly coupled the output of the detector to the micro however you could use capacitor coupling  and breaking the beam will produce a pulse.

The files for Lift Counter
LiftCounter.asm  
LiftCounter.hex
LiftCounter-asm.txt (.asm)
LiftCounter-hex.txt (.hex)

 

For more detail: Lift Counter using PIC12F629 Microcontroller

The post Lift Counter using PIC12F629 Microcontroller appeared first on PIC Microcontroller.

Homemade Scope Clock DG7 tube and PIC16F876

$
0
0

Powersupply and CRT deflection and microcontroller test circuit.
I was lucky to purcase two used but working DG7 tubes and a transformator cheap, one from Mullard and one from Phillips.
Other CRT Cathode Ray Tube types can be used, you can even rip one from an old and maybe dead oscilloscope,
then you also get the powersupply and stuff, if you are lucky the deflection amplifiers also work 🙂
Then your own home made Scope Clock is soon up and running, good luck.

Scope Clock

Here is the complete scope clock Powersupply schematic and PCB layout. Board with parts.
This powersupply uses an old tube gear transformator, so series resistors was used to make all the different voltages.
Voltages written on the schematic are optimal values for a DG7-32 CRT.. but other tubes can also be used, read below.
Download PSU PCB layout for easy homemade Height = 105mm, Width = 85mm.

Powersupply using special made transformator, using no series resistors:
See schematic the huge capacitors can be changed !
New Powersupply board first test of transformator
New special trafo close up picture.
Trafo in hand see the small size.

This is the schematic over the blanking circuit, and PCB layout over Deflection and blanking circuit.
Baord with parts and here also
Download Deflection PCB layout for easy homemade Height = 50.8mm, Width = 111.7mm

PIC16F876 board schematic, using ZN508 DAC download and print out (updated May 2003)
PIC16F876 board schematic, using AD7302 DAC download and print out (updated Okt 2005)
See a closeup of my PIC16 demo board this board was easy to change into a scope clock controller.
I use an old ZN508 dual 8 bit parallel input DAC (see glitches), if you want a little bit better picture I suggest you use AD7302 or DAC8229 or AD5332.
If your scope tube is small or maybe a little bit out of focus, you will not notice the glitches.

 

For more detail: Homemade Scope Clock DG7 tube and PIC16F876

The post Homemade Scope Clock DG7 tube and PIC16F876 appeared first on PIC Microcontroller.

Digital Thermometer and Clock Project (Version 1.0)

$
0
0

This device uses two digital sensors (DS1620 or DS1820), measures the ambient temperature with 0,1 °C (0,2 °F) resolution and displays it on LCD 2×16 (LM016 etc.) screen. It have a clock, which is based on DS1302 timekeeping chip. This chip stores current date and time. The main CPU used in this project is PIC16F877. The additional 8-digit 7 segment LED display can be used. It is based on PIC16F870 microcontroller. RS232C interface is applied to transmit the information from the main CPU to remote LED display. No calibration required!

Digital Thermometer and Clock Project (Version 1.0)Main characteristic:

  • Displays Inside and Outside Temperature.
  • Celsius and Fahrenheit scales selectable.
  • Temperature range: -55 °C to 125 °C (-67 °F to 257 °F).
  • Temperature resolution: ± 0,1 °C (± 0,2 °F).
  • Clock (24-hour format).
  • Local LCD display.
  • Additional LED display (optional).
  • Digital sensors: DS1620 or DS1820 (optional).
  • Power supply: DC 9 V from adaptor.

Digital Thermometer and Clock Project (Version 1.0) BoardSchematic diagrams:

Firmware Files

 

For more detail: Digital Thermometer and Clock Project (Version 1.0)

The post Digital Thermometer and Clock Project (Version 1.0) appeared first on PIC Microcontroller.

Viewing all 218 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>