Thursday, November 13, 2014

DS1302 Real Time LCD Clock Circuit - 16F88

DS1302 Real Time Clock circuit
Clock Schematic

This clock use DS1302 as timekeeping chip and this was my first time I used this IC for my project. It used three wires for communication. It communicates with a microprocessor via a simple serial interface. Three wires are required to communicate with the clock/RAM: CE, I/O (data line), and SCLK (serial clock). The real-time clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The DS1302 will run with a voltage from 2.0V to 5.5V.

Here I used PIC16F88 micro-controller and 16x2 LCD. No switches were added to edit time and date. To add switches you have to modify the code and it is not difficult. The DS1302 uses an external 32.768kHz crystal. The oscillator circuit does not require any external resistors or capacitors to operate. 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. Please refer datasheet for more information.

DS1302 Features

  • Real-Time Clock Counts Seconds, Minutes, Hours, Date of the Month, Month, Day of the Week, and Year with Leap-Year Compensation Valid Up to 2100
  • 31 x 8 Battery-Backed General-Purpose RAM
  • Serial I/O for Minimum Pin Count
  • 2.0V to 5.5V Full Operation
  • Uses Less than 300nA at 2.0V
  • Single-Byte or Multiple-Byte (Burst Mode) Data Transfer for Read or Write of Clock or RAM Data
  • Simple 3-Wire Interface
  • DS1202 Compatible

MikroC used as programming language but you can easily convert it to MikroC Pro. Micro-controller is running by its internal clock at 8MHz.The project files can be download from below with Source files, Proteus and Hex file.

Tuesday, November 11, 2014

Seven Segment Simple Digital Clock Circuit - 16F628

Simple Clock circuit
Clock Schematic

This is a very simple clock circuit. The only IC used in this circuit was 16F628A pic micro-controller. This IC is very cheap and you can get it from any electronic spare parts shop. Four common cathode seven segment displays used to display time. We cannot get much accurate time using this. However, we can able to get reasonable accurate if we calibrate this circuit correctly. You can calibrate this clock by changing value of ‘Drift’. The ‘Drift’ variable is use to set calibration and it value should be in 0 to 255. In my code, value of ‘Drift’ is 198 and that is not the perfect value for it. You can get 0.5Hz frequency from RB7 if your ‘Drift’ value is correct.

Totally four buttons are used in this circuit and RESET button is optional. Min and Hour buttons used to update time and Mode button change the display mode. Two display modes are available. At the beginning, it will show hour and minutes on display. You can view seconds by pressing Mode button. Please replace NOT gate with NPN transistors such as BC547 and put 1k-10k resistors for base before connect with micro-controller.

MikroC used as programming language but you can easily convert it to MikroC pro or any other language. Because the code very simple. Micro-controller is running by its internal clock at 4MHz.The project files can be downloading from below with Source files, Proteus and Hex file.

Monday, November 10, 2014

Common Remote Control Receiver Circuit (RC5 SIRC NEC) - 16F683

General Remote Controller
General Remote Controller

The cheapest way to remotely control a device within a visible range is via Infrared light. Almost all audio and video equipment can be controlled this way nowadays. Due to this wide spread use the required components are quite cheap, thus making it ideal for us hobbyists to use IR control for our own projects.

If you ever want to open your gate or run any other device via remote controller you can use this circuit for that. IR remote control receiver for controlling home appliances can be easily made using PIC micro-controller. By using below circuit you can easily control your home appliances using your TV remote, DVD Player remote control or any other remote.

Remote Control Receiver Schematic
Remote Control Receiver Schematic

The main part of this remote control receiver circuit is PIC16F683. It is cheap and tiny. For infrared receiver I used TSOP1730. However, you can use any other infrared receiver for it (TSOP12xx, TSOP48xx and TSOP62xx product series).

The TSOP1730 used to capture infrared ray from the remote. This infrared receiver changes its output according to the received infrared ray. The output of TSOP1730 then connected to the micro-controller and it decodes the IR signal and gives necessary output according to the IR signal. This circuit is support to Sony, Philips and NEC (I hope, only tested with Sony and Philips) protocols and you can use any remote controller to operate this circuit.

When power is applied, D1 LED will light up. This LED indicates that power is applied. When receiver get IR signal from remote controller then D2 LED light up for 250ms and then off and D3 LED toggle its state. If you need to control heavy load then remove D3 LED and connect transistor and/or relay with this pin. And if you need to switch something like counter then you can used pin 7 (D2 LED) for that.

Sony SIRC Protocol

Sony Protocol
Sony Protocol

The SIRC protocol uses a pulse width encoding of the bits. The pulse representing a logical "1" is a 1.2ms long burst of the 40kHz carrier, while the burst width for a logical "0" is 0.6ms long. All bursts are separated by a 0.6ms long space interval. The recommended carrier duty-cycle is 1/4 or 1/3.

NEC Protocol

NEC Protocol
NEC Protocol

The NEC protocol uses pulse distance encoding of the bits. Each pulse is a 560µs long 38kHz carrier burst (about 21 cycles). A logical "1" takes 2.25ms to transmit, while a logical "0" is only half of that, being 1.125ms. The recommended carrier duty-cycle is 1/4 or 1/3.

Philips RC-5 Protocol

Philips Protocol
Philips Protocol

The protocol uses bi-phase modulation (or so-called Manchester coding) of a 36kHz IR carrier frequency. All bits are of equal length of 1.778ms in this protocol, with half of the bit time filled with a burst of the 36kHz carrier and the other half being idle. A logical zero is represented by a burst in the first half of the bit time. A logical one is represented by a burst in the second half of the bit time. The pulse/pause ratio of the 36kHz carrier frequency is 1/3 or 1/4 which reduces power consumption.

Sunday, November 9, 2014

7 Band Real Time Audio Spectrum Analizer Circuit - 16F818 BA3834 MSGEQ7

Audio Spectrum Analyzer
Audio Spectrum Analyzer

Spectrum analyzers are built in most of the modern signal processing systems for measuring the distribution of signal energy in frequency. An audio spectrum analyzer is used for measurements in the audible frequency spectrum (from 20Hz to 20 kHz) and can be a very powerful tool for keeping a studio well tuned. A Digital, real-time Audio Frequency Spectrum analyzer circuit for audio devices is presented in this project. This circuit aims to professionals or hobbyists who would like to embed it in an audio device or use it as a stand-alone unit. This Digital, real-time Audio Spectrum analyzer circuit for audio devices can be connected to any audio device.

The circuit is based on a PIC16F818 (or PIC16F88) and BA3834S/F (or MSGEQ7).

Audio Spectrum Analyzer circuit
Analyzer with Pattern 1

Operation

The input audio signal is directly connect to the BA3834S/F (or MSGEQ7). The BA3834S/F and MSGEQ7 are 7-band, band-pass filter ICs that use microprocessor time division to produce serial output for spectrum analyzer displays. Those are divides the audio spectrum into seven bands, 63Hz, 160Hz, 400Hz, 1kHz, 2.5kHz, 6.25kHz and 16kHz and out serially from its output pin. That signal then connected to micro-controller. It digitizes and processes this audio signal using an 12-bit ADC module and it computes the distribution of the audio signal energy and displays it on a 7×7 LED display in real time.

Audio Spectrum Analyzer circuit
Analyzer with Pattern 5

After 10 seconds delay this circuit is start to work. User can select display mode by pressing ‘MODE’ button and it support seven display modes. You can use either BA3834S/F or MSGEQ7 as band-pass filter IC and PIC16F88 or PIC16F818 as micro-controller. In my circuit, I used PIC16F818 and BA3834S.
Both versions are available in download section.

Technical details

Display: LED Bar-graphs, 7 Bar-graphs, 49 LEDs, RED Monochrome
Bands: 7 bands
BA3834 - 68, 170, 420 Hz, 1, 2.4, 5.9, 14.4 KHz
MSGEQ7 - 63, 160, 400 Hz, 1, 2.5, 6.25, 16 KHz
Display modes: 7 - user selected
Power Supply requirements: 5V DC

Saturday, November 8, 2014

DS1307 Real Time Seven Segment Alarm Clock Circuit - 16F88

Updates
  • 31/01/2016 - Added: Hourly chime restriction function
  • 27/10/2019 - Fixed: Hourly chime delay error (v3)
  • 27/10/2019 - Fixed: Auto mode data showing time increased (v3)

DS1307 Alarm Clock
Alarm Clock

This is the newest clock I made using DS1307 real time clock IC. Not like other clock circuits I posted, this clock circuit built in all necessary function such as hourly chime, alarm, time drift correction, etc. In addition, it also include temperature sensor as optional function.

This clock has eight display modes (including standby mode).
  • Mode 1 – Display Seconds
  • Mode 2 – Display Time
  • Mode 3 – Display Date
  • Mode 4 – Display Year
  • Mode 5 – Display Alarm
  • Mode 6 – Display Temperature
  • Mode 7 – Show Time, Date and Temperature continuously
  • Mode 8 – Stand By Mode

DS1307 Alarm Clock
DS1307 Alarm Clock

This PIC project uses PIC16F88 micro-controller, DS1307 Real Time Clock, LM35 temperature sensor, and SSD-5461AG common cathode seven segment display. (If you cannot find that display then use four common cathode seven segment displays).

The PIC16F88 used its internal oscillator and it runs at 8MHz. We can reduce cost and complexity of circuit and can save micro-controller’s pin by using internal oscillator.RA0 and RA1 configured as digital and analogue alternatively to drive seven segment and read voltage of LM35.

The DS1307 (RTC) Real Time Clock is an 8-pin device using an I2C interface. It has eight read/write registers that store the information. This IC will do the timekeeping and it not only keeps track of time but also the date and the day of the week. DS1307 RTC is fully Binary Coded Decimal (BCD) clock/calendar. Therefore, the data read from DS1307 should be converted to BCD format. The most important is the Clock Halt Bit (CH), which is, bit 7 of address 0. This is the register 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. So when the first usage we must set ‘seconds’. Otherwise clock fail to run.

DS1307 Alarm Clock circuit
Alarm Clock's Internal

Time Setting

Using MODE button you can change the display mode and the current status will save to Eeprom.
SET button can be used for edit the time, date, alarm etc. When you pressed the SET button, clock entered to the Edit mode and two displays will turn off. You can be able to edit values on other display by pressing UP and DOWN buttons. To edit turn off displays value pressed SET button again. Press the SET button again to return clock to normal mode. If the clock is in normal mode UP button also can used to change the time format (12hr or 24hr) and DOWN button can used to turn on or off alarm.

When time changed to 12hr mode LED will indicate the AM/PM status. Alarm on will indicated by the decimal point of last seven segment display. If you wish, you can also connect separate LED for it.

Error correction

Surprisingly making an accurate 32kHz oscillator is a difficult. 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 capacitive couple to the crystal wire). Because that when using DS1307 we cannot get accurate time. Therefore, I added simple error correction mechanism for this clock

First, set the clock to current time (time of computer or internet) and keep it run up-to 24 hours.
After 24 hours, check the time of clock with time of computer. If time is drift, check how many seconds are drifted..?  (Use clock mode 1 to view seconds)

E.g. 1:  PC time:  16:30:00 Clock time:  16:30:05
+5 seconds drifted. So we have to reduce time.

I used Eeprom (2) to store this values and default value is 30 (0x1E).  See the Eeprom figure.
Now simply overwrite it with 25 (0x19). You must use hex values for it.

E.g. 2:  PC time:  16:30:00 Clock time:  16:29:58
-2 seconds drifted. So we have to increase time.
Overwrite Eeprom (2) value with 32 (0x20).

Hourly Chime Restriction

You can able to stop hourly chime function for specific time period using this setting. Device Eeprom address 6 and 7 use for this. default values are 0x00 and 0x18 (0 and 24)

Eeprom(6) ≤ Chime Restriction < Eeprom(7)

Eg: Stop Chime from 21.00 to 6.00
Eeprom(6) = 0x06 and Eeprom(7) = 0x15
6 ≤ Chime Restriction < 21

Eeprom of 16F88
Eeprom of 16F88

Saturday, August 30, 2014

LM35 Simple Thermometer Circuit with LCD - 16F818

Thermometer
Thermometer

In modern world, analog equipment and device are converting in to digital format. To do this mostly used sensors. There are many cool sensors available now days, ranging from IR distance sensor modules, accelerometers, humidity sensors, temperature sensors etc. but many of these sensors are analog in nature. That means they give a voltage output that varies directly (and linearly) with the sensed quantity. For example in LM35 temperature sensor, the output voltage is 10mV per degree centigrade. That means if output is 300mV then the temperature is 30 degrees. Or else, if the temperature changed one degree then its output voltage varied by 10mv.

In this post, I show you how to build temperature sensor (Thermometer) circuit easily. It uses the PIC 16F818 micro-controller, LM35 temperature sensor and a 16x2 LCD.

LM35 Temperature Sensor Schematic Diagram
Schematic Diagram

LM35

The LM35 series are precision integrated-circuit temperature sensors, whose output voltage is linearly proportional to the Celsius (Centigrade) temperature. The LM35 thus has an advantage over linear temperature sensors calibrated in ' Kelvin, as the user is not required to subtract a large constant voltage from its output to obtain convenient Centigrade scaling. The LM35 does not require any external calibration or trimming to provide typical accuracies of 1/4°C at room temperature and 3/4°C over a full -55 to +150°C temperature range. It can be used with single power supplies, or with plus and minus supplies.

Features
  • Calibrated directly in Celsius (Centigrade)
  • Linear + 10.0 mV/°C scale factor
  • 0.5'C accuracy guarantee-able (at +25°C)
  • Rated for full -55° to +150°C range
  • Operates from 4 to 30 volts

Operation


The LM35 outputs an analog voltage proportional to the temperature. This analog voltage then read by the PIC and processed to display the corresponding temperature value on the LCD. The PIC ADC module does the analog to digital conversion. The PIC MCU’s ADC gives us the value between 0-1023 for input voltage of 0 to 5v. So if the reading is 0 then input is 0v, if reading is 1023 then input is 5v.In the code, I have used the mikroC library function for ADC.

The temperature range for this circuit is 0°C to 150°C.
You can download project files form below and it used MikroC

/************************************************************************

    LM35 Temperature Sensor
    Copyright (C) 2015 Scorpionz

    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  : scopionz.blogspot.com

************************************************************************/

char temp;

void main()
{
OSCCON= 0x70; // 8MHz internal osc
ADCON0=1;
ADCON1=0b10001110;
TRISA = 0x01; // AN0 input
TRISB = 0x00;
PORTA = 0;
PORTB = 0;

Lcd_Init(&PORTB);

Lcd_Cmd(Lcd_CLEAR);
Lcd_Cmd(Lcd_CURSOR_OFF);
Delay_ms(10);

Lcd_Out(1, 3, ".:SCORPIONZ:.");
Delay_ms(1000);
Lcd_Out(2, 2, "Temp is 000.0ßC");

while(1) {

temp = Adc_Read(0)/2.048;

Lcd_Chr(2, 10, ((temp/100)%10 +48));
Lcd_Chr(2, 11, ((temp/10)%10  +48));
Lcd_Chr(2, 12, ( temp%10      +48));
Delay_ms(100);
}
}


Friday, August 29, 2014

Simple LCD Spectrum Analizer Demo Circuit - 16F628



Spectrum analyzers are widely used within the electronics industry for analyzing the frequency spectrum of radio frequency, RF and audio signals. Looking at the spectrum of a signal, they are able to reveal elements of the signal, and the performance of the circuit producing them that would not be possible using other means.

Audio spectrum analyzer shows you a detailed picture of what you are hearing in real-time, that is, as it happens. You can easily built very cheap spectrum analyzer circuit using below diagram. However, this is not a real-time and it is just a visualizing model. But this work as real one and you can add this to your audio projects to get a nice appearance and add extra value for it.

You can able to download MikroC source and other files from the below link

Simple Spectrum Analizer circuit
Schematic Diagram of Analyzer

Thursday, August 28, 2014

Digital Combination Lock Circuit with Keypad and LCD - 16F628

Digital Lock
Digital Lock

Now day’s ordinary locks are replace with digital locks. Those have very advanced features such as digital display, keypad, fingerprint recognized etc. Therefore, I decided to build basic digital lock with LCD display and keypad.

This is a micro-controller based digital lock circuit and it used PIC16F628A. 16x2 LCD is used for the display information and keypad is used for enter the code. (#) will clear the code and (*) will enter the code to initialize process.

Default code for this lock is 2468 and this code was stored in device Eeprom memory. You can change the default code by changing value of device Eeprom memory. Address 1 for first number, Address 2 for 2nd number, so on. You can change Eeprom value from zero to nine.

Digital Lock circuit
Schematic Diagram of Digital Lock

Lock code = Eeprom Address 1 & …. & Eeprom Address 4

Ex:
Eeprom Address 1=3,  Address 2=1,  Address 3=0,  Address 4=7 then,
Lock code  =>  3 & 1 & 0 & 7  => 3107

Eeprom Address and lock code
Eeprom Address and lock code

Wednesday, August 27, 2014

Scrolling Seven Segment Display Circuit - 16F628

Scrolling Seven Segment Display preview
Preview

Many electronic hobbyists are very much interested about build scrolling displays. Most of the time this circuits used matrix displays. However, its cost is high and almost complex to build. Therefore, I try to build a scrolling displays circuit using the seven segments displays because these are cheaper than matrix displays and we can be easily build circuit. This circuit is very simple.

To build this circuit I used PIC16F628A micro-controller and four common cathode seven segment displays. To save micro controller's pin and reduce the cost I used internal oscillator. Massage on ‘scrl_txt’ array will run continuously. You can change the length by changing the value of ‘scrl_len’ according to your text.

A seven-segment LED display is an special arrangement of 7 LED elements to form a rectangular shape using two vertical segments on each side with one horizontal segment on the top, middle, and bottom. By individually turning the segments on or off, numbers from zero to nine and some letters can be display, but we cannot display all characters. However, it is possible to display all the numbers and many characters. See below picture to recognized how seven segment displayed characters.

Seven Segment Characters
Seven Segment Characters

In this picture, you can see some characters like K, M, V, W, X and Z cannot displayed properly. If you need to display all the characters then you need to use 14 or 16 segment displays instead of seven segments. To use this type of display you need to modify the firmware and circuit.

Scrolling Seven Segment Display circuit
Schematic Diagram of Circuit

In Proteus diagram, I used NOT gates to connect the Seven Segment and micro controller. However, in practical you have to use NPN transistor such as 2SC1815 or transistor array IC such as ULN2003 instead of NOT gates. When you are using transistor do not forget to add resistor 1k-10k between micro-controller and base of transistor.

Thursday, May 22, 2014

Multi Function Digital Meter Demo Circuit - 16F88

Multi Function Meter
Generic Multi Function Meter

This project is about a build simple digital multi function meter using a PIC16F88 micro-controller and a 16x2 LCD display. The range of voltage can measured is 0 - 50V, but you can change it easily. This circuit, operation and below code was not tested and only simulated one using Proteus software. you can download full project files including MikroC source file and Proteus schematic. This is only a model of multi function meter and below code for educational purpose. but you can modify and used this code any time for your future projects.


/**************************************************************************

Multi Tester (V, I, F, R)
Copyright (C) 2015 Scorpionz

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.

>> Email: scorpionzblog@gmail.com
>> Blog : scopionz.blogspot.com

***************************************************************************/

int v_in, i_in, r_in;
unsigned f_in;

char *vin = "V=00.0v I=00.00A";
char *fin = "F=00,000Hz 00%";

void main()
{
OSCCON = 0x70; //8MHz
ANSEL = 0x07; // AN0, AN1
T1CON = 0x0A; //1:1
OPTION_REG = 0x80; //WPUB

TRISA = 0x07;
TRISB = 0x40;

PORTA = 0;
PORTB = 0;

Sound_Init(&PORTA, 6);
Lcd_Config(&PORTB, 0, 1, 7, 5, 4, 3, 2);
delay_ms(10);

Lcd_Cmd(LCD_CURSOR_OFF);

Lcd_Out(1, 3, ".:SCORPIONZ:.");
Lcd_Out(2, 1, "Lab Multi Tester");
delay_ms(2000);
Lcd_Cmd(Lcd_Clear);

while(1) {

TMR1H=0;
TMR1L=0;
T1CON.TMR1ON=1;
Delay_ms(1000); // Wait for 1 sec
T1CON.TMR1ON=0;

f_in = 256*TMR1H+TMR1L;
v_in = Adc_Read(0);
i_in = Adc_Read(1);
r_in = Adc_Read(2);

if(v_in>1020 || i_in>1000) PORTA.F3=0;
else PORTA.F3=1;

v_in = v_in/2.05;
vin[2] = (v_in/100)%10 + 48;
vin[3] = (v_in/10) %10 + 48;
vin[5] = (v_in%10) + 48;

i_in = i_in/.2;
vin[10] = (i_in/1000)%10+ 48;
vin[11] = (i_in/100) %10+ 48;
vin[13] = (i_in/10) %10+ 48;
vin[14] = (i_in%10) + 48;

fin[2] = (f_in/10000)%10+ 48;
fin[3] = (f_in/1000)%10 + 48;
fin[5] = (f_in/100) %10 + 48;
fin[6] = (f_in/10) %10 + 48;
fin[7] = (f_in%10) + 48;

r_in = r_in/.205;
r_in = (4790/r_in);
if(r_in) Sound_Play(r_in*30, 100);
fin[13] = (r_in/10) %10 + 48;
fin[14] = (r_in%10) + 48;

Lcd_Out(1,1,vin);
Lcd_Out(2,1,fin);
}
}


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

 

on line

Labels

Recent comment

Visitors

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