Skip to main content

Posts

Showing posts with the label PIC16F628A

Heart rate measurement through optical sensors

Resting heart rate is an very important health parameter that is directly related to the soundness of human cardiovascular system. This project describes a digital method of measuring heart rate through fingertip. The blood volume inside the finger artery fluctuates with heartbeats. This fluctuation can be measured by transmitting an IR light through the finger. A portion of this light is reflected back. The amount of light reflected back depends upon the blood volume. This small change in the reflected light is amplified through proper signal conditioning circuit and converted into a pulse. Later, a PIC16F628A microcontroller is used to count the pulses at the output of the signal conditioner and display the heart rate on seven segment LEDs. The signal conditioning circuit uses two operational amplifiers to build a two-stage active low-pass filter with a gain of about 10000, and a cut-off frequency close to 2.5 Hz.

Programmable digital timer with a relay switch

This project shows how to make a simple programmable digital timer switch with a PIC16F628A microcontroller. The timing schedule for the relay switch can be programmed through 4 push buttons. The program menu, the status of the relay switch and time information is shown on a character LCD.

00-99 Minutes Timer

Introduction This project describes how to program PIC16F628A to function as a 00-99 min programmable timer. User can set any time between 00-99 minutes and can turn ON a device for that period. The device will be automatically turned OFF after the time expires. For demonstration, the ON/OFF condition of device is simulated by switching LED ON and OFF. With the use of three input switches (unit, ten, start/stop) the user can set ON time of the timer and can also control Start/Stop operation. The two time set switches are for selecting unit and tens digit of minute time interval (00-99). Once you set the value of minute interval, pressing the Start/Stop will turn the timer ON (LED will glow), and pressing the same button again at any point of time during timer operation will interrupt the process (LED will turn OFF) and the timer will be reset. LCD display will provide timer status and user interface for setting time. Setup Connect SW1, SW2, and SW3 to RB0, RB1, and RB2 respectively...

Experiment No. 12: Timer0 Counting AC Line Frequency

Introduction The Timer0 module in PIC16F628A is both 8-bit Timer and Counter. When used as Counter, the Timer0 module will increment on every rising or falling edge of the T0CKI (RA4, pin 3) pin. The incrementing edge is determined by the T0SE bit of the OPTION register.

PIC16F628A + DS1820 + 4-Digit Seven Segment C/F Thermometer

Introduction This project describes how to read temperature from a DS1820 sensor with a PIC16F628A microcontroller and display the temperature value in a multiplexed 4-digit seven segment display. The temperature will be displayed in both Centigrade and Fahrenheit units switching back and forth. The temperature resolution is 1 degree in both the units. Out of 4-digits, the most significant three digits will display numeric temperature values from 00 to 125. The most significant digit will show '-' for negative temperatures, and the least significant digit will display C or F. On my PIC16F628A board, connect D1 to RA2, D2 to RA1, D3 to RA0, and D4 to RA3. DS1820 data will be read at RA4 port. The seven segments a-g will be driven by RB0-RB6. Software /* Project name:      Seven-segment display digital thermometer  * Copyright:      (c) Rajendra Bhatt, 2010.       MCU:             PIC...

Experiment No. 10: Use of UART Library to Communicate with PC

MikroC has two sets of built-in library functions for UART communications: Software UART and Hardware UART . Since PIC16F628A has a built-in hardware USART module, we are going to use the Hardware UART library. Some PICs don't have hardware USART, such as PIC16F84A. In such cases, any digital I/O pins of PIC can be used for Asynchronous Serial Data Transfer using mikroC Software UART libraries. Experimental Setup The UART Rx and Tx pins in PIC16F628A are multiplexed with RB1 and RB2 pins. In this experiment, we are just sending some character data from PIC to a PC as demonstration of the technique. On PC, the HyperTerminal program should be running to receive data from the PIC16F628A. Since our PIC board does not have a TTL to RS232 voltage level shifter, we are going to construct it on a breadboard. Here is my Level Shifter Circuit:

Experiment No. 9: DC Motor Speed Control using PWM

This is an extension of Experiment No. 8 ( Click Here ). The PWM output is here connected to power a DC motor through a NPN driving transistor. The motor driving circuit is built in a breadboard, as shown below. The circuit is pretty straight forward, the PWM output from PIC pin drives the BC547 transistor ON and OFF, and the current to drive the motor is provided by the collector current in the transistor. The diode is for back EMF protection. I am using a small 6V DC motor from an old cassette player. For motors that require more current to drive, a darlington transistor pair or high power transistor is recommended.  

Experiment No. 7: Timers and Interrupts

Background Many microcontroller applications like generating periodic signals, measuring time interval, keeping date and time, use time as their variable. Therefore, microcontrollers need to have some internal resources to accurately measure time. The PIC16F628A has 3 timer modules which are known as Timer0 , Timer1 , and Timer2 . The basic unit of a timer is a free-run 8-bit or 16-bit incrementing synchronous counter which can be programmed to count internal or external pulses. The count number stored by each counter can be read or modified by accessing the special function register associated with that timer. Some of the bits in these registers are also the indicators of timer overflow, which, therefore, can generate interrupt request to the microcontroller. The use of timer modules to keep record of time elapsed allows the microcontroller to carry on with its other operations like controlling outputs, reading inputs, etc. Timers can also have another asynchronour counter, known...

Experiment No. 6: Read/Write Internal EEPROM Memory

An EEPROM (Electrically-Erasable Programmable ROM) data memory is one of the important features of flash-based PIC microcontrollers. It is called non-volatile to indicate that it retains the data even when the power is down. Practically speaking, if you want to design a digital lock system, then the password to unlock the system can be saved into the EEPROM, so that when the power is down, the password will still be saved. And other good thing is that the data can be easily modified or overwritten with software control. In this experiment, I am going to show you how to read and write in to the internal EEPROM memory of PIC16F628A using mikroC EEPROM library functions. Here is what we are going to do: We will write 0s to 10 EEPROM locations. We will read them first, then write 0-9 to these locations, and turn the power off. We will turn the power on, and read the data in those locations and see. I have created a simple menu on LCD with Read, Write and Delete functions. Experimental...

Experiment No. 5: Multiplexed Seven Segment Displays

In this experiment, we are going to learn how to interface more than one 7-segment LED display to a PIC Port using multiplexing technique. We are going to interface a 4-digit common cathode seven segment display to our PIC board. The multiplexing circuit is already built up in the board using 4 transistors and few resistors (Read Make Your Own PIC Development Board ). The basic idea of multiplexing is that all seven segment displays are connected to the microcontroller in parallel and the microcontroller alternately prints ones, tens, hundreds, and thousands digits, selecting one at a time. The switching among the digits is so fast that it gives an impression of simultaneous light emission. Experimental Setup: 1. Connect RA0 through RA3 to 7-Segment Digit Select headers DG1, DG2, DG3, and DG4 using jumper wires. 2. Insert 7FR5641AS 4-Digit Seven Segment module in to its place on the board.

Experiment No. 4 : Reading Temperature Values from DS1820 using 1-Wire Protocol

In this experiment, we are going to build a digital temperature meter using DS1820 connected to our PIC16F628A development board. The temperature value will be displayed on the LCD display. I have modified the sample program that comes with the compiler according to our PIC board requirements. Also I have elaborated comments in the program so that every step will be more clear to the readers. Experimental Setup: The experimental setup is very straight-forward. Place DS1820 device on the three-pin female header that we recently added to our board. And also connect the data pin of DS1820 to RB.0 pin of PIC16F628A using a jumper wire.  

Experiment No. 3: LCD Interface in 4-bit Mode

The objective of this experiment is to interface a 16x2 LCD to PIC16F628A in 4-bit mode. This means the data transfer will use only four pins of the microcontroller. There is no additional hardware setup needed for this experiment, as we have a ready-made LCD interface female header. We only need to define the data transfer and control pins in the software. Remember, the LCD interface in our development board uses the following pins of PIC16F628A: Data Transfer : D4 -> RB4, D5 -> RB5, D6 -> RB6, D7 -> RB7 RS -> RA0, and EN -> RA1