Loading...
Showing posts with label Counter. Show all posts
Showing posts with label Counter. Show all posts

Saturday, December 26, 2015

Multi Stage Simple Programmable Timer Circuit - 16F628A

255 Stages Simple Programmable Timer Circuit

Electronic delay timers are devices which are able to count and produce different time delay intervals as per the external settings. The elapsing of the set time is mostly indicated through an audible alarm to alert the user. Timers play an important role in our everyday life, whether it’s your cell phone, wall clock, TV/DVD sets, computers they are present everywhere.

Usually an ordinary electronic timer is able to produce single-shot delay intervals and setting up its initializing point becomes inaccessible. The present simple programmable timer circuit design eliminates this drawback.

Simple Programmable Timer Circuit - 16F628
Simple Programmable Timer Circuit

This is a one of the simple circuit of programmable timer circuit. The time range of this timer is 1 second to 255 hours. The delay time can be change by dip switches. The whole circuit of programmable timer is build using cheap PIC16F628A microcontroller and few passive components.

Circuit Operation

After power applied, the START led will turn on and you need to configure the delay time, timer mode and repeat mode. The delay time of this circuit can change by using dip switches. Those dip switches are represent 8-bit binary number and that number use to set delay time. When the delay time over, RLY ON led will turn on.

Eg:
If you need to set delay time to 150 then, dip switch configuration is 10010110 (RB0-RB7).
1 = Off and 0 = On

When you pressed the START button, START led will begin to blink and you can observe timer status by that.

Time Mode

This circuit can operate in 3 different time modes (Seconds, Minutes and Hours). Those modes can select from MODE buttons.

  1. If both PORTA.F6 and PORTA.F7 are low or high, then circuit is running in seconds’ mode (0 – 255 seconds)
  2. If PORTA.F6 high and PORTA.F7 low, then the circuit is running in minutes’ mode (0 – 255 minutes)
  3. If PORTA.F6 low and PORTA.F7 high, then the circuit is running in hours’ mode (0 – 255 hour)

Repeat Mode

If PORTA.F1 is low then repeat mode will turn on. The circuit running continuously and RLY ON led will turn on and off repeatedly.

To control heavy load, remove RLY ON led and connect 5v relay through NPN transistor. Then connect you device across the relay. Supply voltage for this circuit is 5v and use voltage regulator ic such as LM7805, if you use voltage above that.

Sunday, November 8, 2015

Digital LCD Speedometer and Odometer Circuit - 16F628

speedo odometer
Speedometer


In my previous post, I explained how to build a simple speedometer circuit using a micro-controller and seven segments. Read it from here. This is a further development of that circuit. This circuit indicates both speed and distance.

A speedometer or a speed meter is an instrument that measures and displays the instantaneous speed of a vehicle. An odometer or odograph is an instrument that indicates distance traveled by a vehicle.

speedo odometer circuit
Speedometer + Odometer Circuit


For this circuit I used PIC16F628A micro-controller and 16x2 LCD. You can able to see speed in first line and distance in second line on the LCD. Distance will update every 100 meters and speed updates every one second. Value of distance writes to Eeprom in every 1 km. I also added a button to this circuit. The purpose is, reset the distance to zero.

Same as the Speedometer Circuit, micro-controller count the signals received to RA4 pin and then calculate speed and distance, then display information on LCD. 8 MHz resonator is use to generate clock signals. However, you can always use crystal for it and make sure to add 22pf ceramic capacitors if you use crystal oscillator.

Measure the radius of the wheel and enter it to Eeprom address 0x00. Default value for radius is 30cm (0x1E). I used two magnets to operate reed switch. Please refer my previous post for more details and circuit connection.

Maximum speed is 999 kmh
Maximum distance is 9999 km
Supply voltage is 5v

Friday, November 6, 2015

Digital Seven Segment Speedometer Circuit - 16F628

speedometer1
Speedometer

How Electronic Speedometers Work

In Electronic speedometer, small magnets attached to the vehicle's rotating drive shaft sweep past tiny magnetic sensors (either reed switches or Hall-effect sensors) positioned nearby. Each time the magnets pass the sensors, they generate a brief pulse of electric current. An electronic circuit counts how quickly the pulses arrive and converts this into a speed, displayed electronically on the display. Since the circuit is measuring the number of wheel rotations, it can also keep a count of how far you have traveled, doubling-up as an odometer (distance-measuring meter). Electronic speedometers can also display speeds with analog pointers and dials, just like traditional eddy-current speedos: in that case, the electronic circuit drives a highly controllable electric motor (called a stepper motor) that rotates the pointer through an appropriate angle. Electronic speedometers are more reliable and compact than mechanical ones and the motion sensors can be any distance from the display that shows you your speed, making them suitable for any kind of vehicle!


electronic speedometer
1. A magnet connected to one of the wheels rotates at high speed.

2. Every time it makes one complete revolution, it passes a magnetic sensor and the field from the magnet triggers the sensor.

3. A circuit translates them into your instantaneous speed and distance traveled.

4. A digital display displaying the speed and distance.


Here I will show you how to build simple yet accurate digital speedometer circuit using just a single IC, seven segments and a few external passive components. The design can be used for all vehicles for indicating their speeds.

ssd speedometer circuit
Speedometer Circuit

The main component of this circuit is PIC16F628A. It count signals receive to RA4, then calculate speed and display it on seven segment. A Reed switch used to sense the speed. If the brightness of seven segments is too much, add 220 – 330 Ohms resistors between PORTB and the display. There are two version of hex files are available. In v1 micro-controller use its internal oscillator and v2 used external 4MHz oscillator.

Measure the radius of the wheel and enter it to Eeprom address 0x00. Default value for radius is 30cm (0x1E). You can change update interval by changing the value of Eeprom address 0x01. Default value is 20 (0x14). To increase the sensitivity in this circuit I used two magnets.


speedometer eeprom settings
Eeprom Settings


Maximum Speed is 999 Kmh
Maximum Radius is 255 cm
Supply voltage is 5v


speedometer connection
Circuit Connection

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

Saturday, July 28, 2012

24Hr Digital Clock and Alarm Circuit Using Logic ICs - CD4017 CD4026

[Updated]
06/05/2018 - Added Month and Date Reset Feature


This is my first clock project, and used logic IC such as 4017, 4026 to build this clock circuit. Its include Date, Day, and Hourly alarm.See below picture.

Logic clock preview
Preview

It’s very complicated at first sight. But it is not. First of all you can build main circuit and check it work or not.If the circuit work fine, then add other parts step by step to the circuit.

If it’s not work check all component and connections are correct and also check Seven Segment Displays. In my circuit I used LEDs but it is possible to use Seven Segment Displays.
Add &transistors if you use LED or big Seven Segment Displays because this logic ICs can not handle large current. I connect this circuit with 6v backup battery to prevent time lost when the power is fail. In power failure displays are turned off but time is running using battery power.

Logic clock circuit
Full Circuit Diagram

1Hz Signal Generators

To generate 1Hz clock pulse for this circuit here I used circuit of a ordinary clock machine. you can buy a clock machine very cheap price at electronic shops or you can get it from old clock. In below picture you can see most common circuits of clock circuits. By giving power to this circuit we can able to get 1Hz output across the pins that are connected to coil (motor). (But actually we can get only 0.5Hz pulse in one pin. So get 1Hz we need to connect those pins by two diodes. you can see that in the diagram).

1hz signal generator circuit
Clock circuits

4017 decade counter (1-of-10)

CD4017 pin The count advances as the clock input becomes high (on the rising-edge). Each output Q0-Q9 goes high in turn as counting advances. For some functions (such as flash sequences) outputs may be combined using diodes.

 The reset input should be low (0V) for normal operation (counting 0-9). When high it resets the count to zero (Q0 high). This can be done manually with a switch between reset and +Vs and a 10k resistor between reset and 0V. Counting to less than 9 is achieved by connecting the relevant output (Q0-Q9) to reset, for example to count 0,1,2,3 connect Q4 to reset.

 The disable input should be low (0V) for normal operation. When high it disables counting so that clock pulses are ignored and the count is kept constant.

 The ÷10 output is high for counts 0-4 and low for 5-9, so it provides an output at 1/10 of the clock frequency. It can be used to drive the clock input of another 4017 (to count the tens).

4026 decade counter and 7-segment display driver

CD4026 pin The count advances as the clock input becomes high (on the rising-edge). The outputs a-g go high to light the appropriate segments of a common-cathode 7-segment display as the count advances. The maximum output current is about 1mA with a 4.5V supply and 4mA with a 9V supply. This is sufficient to directly drive many 7-segment LED displays. The table below shows the segment sequence in detail.

 The reset input should be low (0V) for normal operation (counting 0-9). When high it resets the count to zero.

 The disable clock input should be low (0V) for normal operation. When high it disables counting so that clock pulses are ignored and the count is kept constant.

 The enable display input should be high (+Vs) for normal operation. When low it makes outputs a-g low, giving a blank display. The enable out follows this input but with a brief delay.

 The ÷10 output (h in table) is high for counts 0-4 and low for 5-9, so it provides an output at 1/10 of the clock frequency. It can be used to drive the clock input of another 4026 to provide multi digit counting.

cd4026 display chart
4026 display chart

CD4073 triple 3-input AND Gate

CD4073 internal
CD4073 pin

The 4073 has three separate 3-input AND gates which you can use independently.

Truth table

The truth table of each individual gate is:
C B A Output
0 0 0
0 0 1 0
0 1 0 0
0 1 1    0
0    0
1 0 0
1 1 0    0
1 1   1 1

where '0' represents a LOW voltage, and '1' represents a HIGH voltage.

Basic operation

You can investigate the behavior of a single 3-input AND gate using this circuit:

3-input AND gate operation
The inputs of the gate must be connected, either to LOW or to HIGH, and must not be left open circuit. This is the function of the input switches with their pull-down resistors. To avoid loading the output of the gate, a transistor switch indicator circuit should be used. It is good practice with CMOS circuits to insert a decoupling capacitor, 47µF or 100µF, across the power supply. (This helps to prevent the transfer of spikes along the power supply rails.)

UM348X

UM348X  pin
The UM348X series is a mask-ROM-programmed multi instruction melody generator, implemented in the CMOS technology. They are designed to play the melody according to the previously programmed information and capable of generating 16 songs with 3 instrument sounds, the piano, the origin and the mandolin.

The devices also included a per-amplifier which provide simple interface to the driver circuit. The UM348X series is intended for applications such as toys, door bells, music boxes, melody clock/timers and telephones


Month and Date Reset

Month and Date Reset Circuit
Month and Reset Circuit
This is a newly added circuit and use 16F628A micro-controller. you have to program it before use. the purposes of this circuit are show month and reset date according to the month. Ex: Jan 31, Feb 28, Etc. PIC use its internal oscillator and circuit is very simple. To save pins, Month shows binary format.
Ex: 1=0001, 2=0010, 3=0011, etc.
For power supply and more details please refer device datasheet. 


Code

/******************************************************************************* Month and Date Reset - 16F628A Copyright (C) 2014 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 *******************************************************************************/ int count=1, month=1, date=1; const char day_month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31}; // Interrupt Service Routine (ISR) void interrupt() { if (INTCON.INTF) // Check for interrupt { PORTA.F2=1; count=count+1; delay_ms(5); PORTA.F2=0; if(count>day_month[month]) { count=1; if(++month>12) month=1; PORTA.F3=1; Delay_ms(5); PORTA.F3=0; PORTA.F2=1; Delay_ms(5); PORTA.F2=0; } PORTB = month<< 0x07="" a0="" clear="" cmcon="" comparators="" delay_ms="" disable="" flag="" if="" intcon.intf="0;" intcon="0b10010000;" interrupt="" interrupts="" main="" month="" nable="" option_reg.intedg="0;" pcon.oscf="1;" porta.f2="0;" porta="0x00;" portb="month<<4;" rb0="" trisa="0x03;" trisb="0x01;" void="" while="" z="">12) month=1; PORTB = month<< count="" delay_ms="" if=""> day_month[month]) { count=1; PORTA.F3=1; Delay_ms(5); PORTA.F3=0; } PORTA.F2=1; Delay_ms(50); PORTA.F2=0; Delay_ms(400); } } }

Friday, July 27, 2012

Seven Segment Up Counter and Timer Circuit - 16F628

PIC16F628 Counter Circuit
Circuit diagram

The project shows what can be done with a micro and you can modify it to set an alarm at any count-value or set a limit such as 'count-to-60'. You can add a buzzer or relay or increase the display to 3 digits. You need to remember that each additional display will reduce the illumination of each digit as they are 'multiplexed (time-sharing)'. Full circuit diagram including programming socket.

The displays do not affect the 'In Circuit Programming' as they are not active when programming and do not load the outputs. Any 7-Segment displays will work in this circuit. You need to identify the pin-out of any display you use. (Common Anode displays can be used providing you invert the values in the display table. A PNP transistor will need to be used.)

Testing the circuit

Check the circuit by removing the chip and taking pins 6 and 18 to the 5v rail ad make sure segment 'A' illuminates. Do the same for all the other segments.The circuit diagram does not have any voltages marked on it as the circuit is DIGITAL.All the 'lines' or 'wires' or pins of a micro-controller will have rail voltage (5v) on them when they are HIGH and when you come to a resistor, the resistor will drop a certain voltage. The voltage it will drop will be the difference between rail voltage and the voltage developed across the component it is driving. If it is driving a LED, the LED will drop a characteristic voltage of between 1.7v and 3.6v, depending on the color. If the component is a transistor, the voltage developed between the base and emitter will be about 0.7v.

Use Micro C For Compile.

MikroC

PIC16F628A Datasheet

PIC16F628A Pin
pin-out



PIC16F84A Datasheet

PIC16F84A Pin
pin-out


 

on line

Labels

Recent comment

Visitors

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