Loading...

Saturday, April 26, 2014

4 Digit Seven Segment Up Counter Circuit - 16F628

In the past I posted a counter and timer circuit and it is used two seven segment displays to display number and it can only count 0-99. you can see it from here. This circuit was developed version of it.

This project shows cheap and accurate up counter and it can count up to 9999 and then it will start from 0. For this circuit i used PIC16F628A micro-controller and four common cathode seven segment displays. Any 7-Segment displays will work in this circuit. You need to identify the pin-out of any display you use. In Proteus schematic i used NOT gate for reduce CPU usage while simulating and you need to replace that NOT gate with NPN transistors such as BC547 and do not connect transistor's base directly with PORTA (A0-A3). Put a 1k-10k resistor for base of each transistor.

4 Digit Seven Segment Counter circuit
Schematic diagram of 4 digit up counter

Operation of Circuit

  • To start counting simply press the 'Count' button and every time you pressed that button the number will increase one by one and displayed on the seven segment displays. if you need to automatic counting, it is also possible to connect this pin with pulse generator.
  • Pressed 'Clear' button to clear the display and start from zero.
  • 'Reset' button is optional and you can omitted it. but you must add pull-up resistor. otherwise device will reset continuously. 'Reset' button is useful when the circuit was stuck or not responded.

The main problem of counter circuit was contact bounce. The contact bounce is a common problem with mechanical switches. When the contacts strike together, their momentum and elasticity act together to cause bounce. The result is a rapidly pulsed electrical current instead of a clean transition from zero to full current. It mostly occurs due to vibrations, slight rough spots and dirt between contacts. This effect is usually unnoticeable when using these components in everyday life because the bounce happens too fast to affect most equipment. However, it causes problems in some analog and logic circuits that respond fast enough to misinterpret on/off pulses as a data stream. Anyway, the whole process doesn’t last long (a few micro or milliseconds), but long enough to be registered by the microcontroller. When only a push-button is used as a counter signal source, errors occur in almost 100% of cases!

To prevent contact bounce I added some extra code. so we can get error less counting from this circuit. When you pressed and hold the Count button this circuit wont count.

PIC16F628A pin
PIC16F628A Datasheet


/******************************************************************************* 4 SSD Up Counter Copyright (C) 2015 Praneeth Kanishka This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses >> Email: scorpionzblog@gmail.com >> Web : http://scopionz.blogspot.com *******************************************************************************/ #define CLR PORTA.F4 #define ssd1 PORTA.F0 #define ssd2 PORTA.F1 #define ssd3 PORTA.F2 #define ssd4 PORTA.F3 void ssdecode(char i); int number=0; char digit1, digit2, digit3, digit4; char Loop=0; char key=0, last_key=0; void Delay_dis(){Delay_ms(5);} void main() { PCON.OSCF = 1; //4MHz CMCON |= 0x07; // Disable Comparators //INTCON = 0b10010000; TRISA = 0x10; TRISB = 0x01; PORTA = 0; PORTB = 0; Delay_ms(10); while(1){ if(!PORTB.F0) key=1; else {key=0; last_key=0;} if(key!=last_key) { if(++number>9999) number=0; last_key = key; } while(Loop <5) { ssdecode(digit1); //Display digit 1 ssd1 = 1; Delay_dis(); ssd1 = 0; ssdecode(digit2); //Display digit 2 if(number>9)ssd2 = 1; else ssd2 = 0; Delay_dis(); ssd2 = 0; ssdecode(digit3); //Display digit 3 if(number>99)ssd3 = 1; else ssd3 = 0; Delay_dis(); ssd3 = 0; ssdecode(digit4); //Display digit 3 if(number>999)ssd4 = 1; else ssd4 = 0; Delay_dis(); ssd4 = 0; Loop++; } Loop = 0; if(!CLR) number=0; digit1 = (number) %10; digit2 = (number/10) %10; digit3 = (number/100) %10; digit4 = (number/1000)%10; } } void ssdecode(char i) { switch (i) { case 0: PORTB = 0b01111110; break; case 1: PORTB = 0b00001100; break; case 2: PORTB = 0b10110110; break; case 3: PORTB = 0b10011110; break; case 4: PORTB = 0b11001100; break; case 5: PORTB = 0b11011010; break; case 6: PORTB = 0b11111010; break; case 7: PORTB = 0b00001110; break; case 8: PORTB = 0b11111110; break; case 9: PORTB = 0b11011110; break; } }

Friday, April 25, 2014

Infrared Remote Control Transmitter and Receiver Circuit - 16F628 12F683

Updated [Sep 14, 2014]
  • Fixed some bugs on IR_Tx.hex
  • Increased Accuracy

This is a general purpose remote control project with 16 channels and using PIC16F628 for transmitter & 12F683 for receiver side. Remote controls usually consist of encoder/decoder parts connected to a transmitter/receiver module which takes care of the transmission of digital signals by radio or infra waves.The transmitter has a varying number of buttons and sends the states of these inputs to the receiver. The receiver device decodes the message and sets the outputs accordingly. To get individual out put from receiver you need to connect 4 to 16 decoder like CD4067, 74HS154 etc or you can use another programming ic. Receiver has two versions. chose better one for your task.
I used Proteus 8 for designing. so if you are already used older version, it is not supported to open this files. All the files can be download from below.

Transmitter Circuit

The TX use 16 pin PIC devices, PIC16F628A is the main part of the transmitter run at 4 MHz crystal. Actually, this device has 4MHz RC internal oscillator but not suitable for use with the project that need critical time as remote control. This ic used to send IR command to receiver. It also generate 38KHz carrier frequency and information bit.

You can use 2xAA size batteries or CR2016 battery or 5v for the circuit. For saving power when use with battery powered we need to increased battery life. Therefore when any keys not pressed within 30 seconds the CPU go to SLEEP mode to reduce battery power consumption and wake-up only when any key pressed. To wake-up the CPU from SLEEP mode the CPU use interrupt on change feature which interrupted when the state on PORTB change, then the program execution after an interrupt is at the interrupt vector, if the global interrupt is not enabled, the program starts executing the first line of code right after the SLEEP instruction.In the interrupt service routine the software will scan the key that pressed and send IR command appropriate with key pressed.

Transmitter circuit
Schematic of Transmitter

Receiver Circuit

The receiver used low cost 8 pin PIC16F683 to control all function of receiver side. The IR was received from TX will demodulated by this ic. When power is applied to circuit the CPU will polling the IR input signal which is the output from IR decoder module (TSOP1736). After IR received the CPU decoding the IR command and then turn on/off appropriate channel.

Ex:
If press 1 on TX then RX out put will be A=1, B=0, C=0, D=0
If press 2 on TX then RX out put will be A=0, B=1, C=0, D=0
If press 16 on TX then RX out put will be A=1, B=1, C=1, D=1

For IR decoder module alternatively you can used TSOP48XX series or any common module.
Connect 4 to 16 decoder with A, B, C and D to get all the out puts.
Supply voltage is 5v (Max).


 Receiver circuit
Schematic of Receiver

PIC12F683 Datasheet
PIC16F628A Datasheet


PIC16F628A pin
Pin Connection

Sunday, March 3, 2013

DS1307 Real Time Seven Segment Clock Circuit - 16F88

DS1307 IC
DS1307 is a low power serial real time clock with full binary coded decimal (BCD) clock/calendar plus 56 bytes of NV SRAM (Non Volatile Static Random Access Memory). Data and Address are transferred serially through a bidirectional I2C bus.

The RTC provides year, month, date, hour, minute and second information. The end date of months is automatically adjusted for months fewer than 31 days including leap year compensation up to year 2100. It can operate either in 24-hour format or 12-hour format with AM/PM indicator.

DS1307 comes with built-in power sensing circuit which senses power failures and automatically switches to back up supply. We can provide a 3V CMOS Battery for that. The DS1307 RTC uses an external 32.768 kHz Crystal Oscillator and it does not requires any external resistors or capacitors to operate.

DS1307 Block Diagram
DS1307 Block Diagram

In this project, I used ds1307 as real time clock ic and PIC16f88 as micro-controller. To save micro-controller pins there are four input keys which are all connected to a single analogue input pin. This pin also drives one of the seven segment display LEDs so it has to be switched between input (to read the analogue voltage) and output (to drive the led). Each key pulls the analogue input to a different voltage level which you can easily read using the ADC (RA0).

DS1307 Real Time Clock circuit
Circuit Diagram

Set Time

Mode : Pressing mode button cycles the display showing 3 different data.

Mode 1 : Time only
Mode 2 : Seconds only
Mode 3 : Stand-by


Set : To change the value, set button must be pressed.

Set 1 :  Edit mode, show Minute
Set 2 :  Edit mode, show Hour
Set 3 :  Return to clock mode


Up and Down : After Pressing set button, you can change the values indicated on clock by using this buttons.

UP :  Values ++
In clock mode it will also change the 12/24Hr format.

Down :  Values --
In clock mode it will do nothing.

Clock Accuracy:

The accuracy of the clock is dependent upon the accuracy of the crystal and the accuracy of the match between the capacitive load of the oscillator circuit and the capacitive load for which the crystal was trimmed. Additional error will be added by crystal frequency drift caused by temperature shifts. External circuit noise coupled into the oscillator circuit may result in the clock running fast.

To ensure the crystal oscillates correctly you must ensure that;
  • Crystal uses 12.7pf load capacitance (correct crystal type).
  • The crystal is close to the IC.
  • The tracks are short.
  • The chip supply has lots of decoupling (capacitors from +5V to GND). e.g. A 100n and a 10n
  • There are no signal tracks near to the crystal.
  • For a PCB: It has a guard ring and a ground plane and away from digital signals.

DS1307 Datasheet
PIC16F88 Datasheet

PIC16F88 pin
Pin Connection


I Used mikroC for compile this project.
Also you can get PCF8583 version from here.

Saturday, March 2, 2013

PCF8583 Real Time Seven Segment Clock Circuit - 16F88

Basic Connection of PCF8583
Basic Connection of PCF8583
The PCF8583 is a clock and calendar chip based on a 2048 bit static CMOS RAM organized as 256words by 8 bits. Addresses and data are transferred serially via the two-line bidirectional I2C-bus.

The built-in word address register is incremented automatically after each written or read data byte. Address pin A0 is used for programming the hardware address, allowing the connection of two devices to the bus without additional hardware.

The built-in 32.768 kHz oscillator circuit and the first 8 bytes of the RAM are used for the clock, calendar, and counter functions. The next 8 bytes can be programmed as alarm registers or used as free RAM space. The remaining 240 bytes are free RAM locations.

Block diagram of PCF8583
Block diagram of PCF8583

Features:

  • I2C-bus interface operating supply voltage: 2.5 V to 6 V
  • Clock operating supply voltage 1.0 V to 6.0 V at 0 °C to +70 °C
  • 240 × 8-bit low-voltage RAM
  • Data retention voltage: 1.0 V to 6.0 V
  • Operating current (at fSCL = 0 Hz): max 50 μA
  • Clock function with four year calendar
  • Universal timer with alarm and overflow indication
  • 24 hour or 12 hour format
  • 32.768 kHz or 50 Hz time base
  • Serial input and output bus (I2C-bus)
  • Automatic word address incrementing
  • Programmable alarm, timer, and interrupt function
  • Slave addresses: A1h or A3h for reading, A0h or A2h for writing

PCF8583 Real Time Clock circuit
Circuit Diagram

This clock circuit is same as DS1307 - Real Time Clock. The only different is here I used PCF8583 RTC clock ic and change firmware. Because registers of DS1307 and PCF8583 are different.

To save micro-controller pins there are four input keys which are all connected to a single analogue input pin. This pin also drives one of the seven segment display LEDs so it has to be switched between input (to read the analogue voltage) and output (to drive the led). Each key pulls the analogue input to a different voltage level which you can easily read using the ADC (RA0).


Set Time:

Mode : Pressing mode button cycles the display showing 3 different data.

Mode 1 : Time only
Mode 2 : Seconds only
Mode 3 : Stand-by


Set : To change the value, set button must be pressed.

Set 1 :  Edit mode, show Minute
Set 2 :  Edit mode, show Hour
Set 3 :  Return to clock mode


Up and Down : After Pressing set button, you can change the values indicated on clock by using this buttons.

UP :  Values ++
In clock mode it will also change the 12/24Hr format.

Down :  Values --
In clock mode it will do nothing.

Quartz Frequency Adjustment:

By evaluating the average capacitance necessary for the application layout, a fixed capacitor can be used. The frequency is measured using the 1Hz signal available after power-on at the interrupt output (pin 7). The frequency tolerance depends on the quartz crystal tolerance, the capacitor tolerance and the device-to-device tolerance. Average deviations of 5 minutes per year are possible. See data sheet for more detail.

Use mikroC for compile.

PCF8583 Datasheet

PIC16F88 Datasheet

PIC16F88 pin
PIC16F88 Pin Connection

Thursday, August 23, 2012

2 Way AC Flasher

Preview

Schematic
you can change speed by adjusting RV1 

Please be careful! This circuit is directly connected with AC !

 

on line

Labels

Recent comment

Visitors

Free counters!
Copyright © 2012 - Scorpionz™.,All rights reserved | Powered by Blogger