Skip to main content

Posts

Showing posts from 2010

PIC16F628A breadboard module for quick prototyping

This breadboard module is for PIC16F628A microcontroller and it provides access to the I/O ports and the power supply pins through male headers that can be easily inserted into a breadboard. This board will make protyping easier as the external oscillator, reset, and ICSP circuits are already implemented in the module. The layout of the module is shown below. You can construct this board on a general purpose prototyping circuit board.

PIC based Diode and BJT tester

If your digital multimeter does not have features for testing diodes and transistors, hold on, here's a project that describes how you can construct one by yourself. This project is based on a PIC16F688 microcontroller and uses the simple concept of unidirectional conduction of PN juction to find if the diode or transistor is good or bad. The test results are displayed on a character LCD. It also shows the type of the transistor (NPN or PNP) as well as which of the PN junctions are open or short in a faulty transistor.   Source: http://embedded-lab.com/blog/

Contact less tachometer using PIC16F628A

Introduction Tachometer is a device that gives you the information about the rotational speed of any shaft or disc. It usually measures the speed in revolutions per minute (RPM). Today we are going to make a simple tachometer that could measure the rotation speed of a disk without making any physical contact (that's why it is contact less) with the rotating object. The range of this tachometer is 0 - 9999 RPM and displays the RPM on a multiplexed 4-digit seven-segment display. Of course, we are going to do this project on our usual PIC16F628A development board. Infrared sensor Contact-less measurement of RPM will be achieved through an IR sensor. An IR diode will send a beam of infrared towards the rotating disc, and any reflected pulse will be received by a photo diode. The resistance of a photo diode drops drastically when exposed to infrared. An infrared is reflected by a white surface and absorbed by the dark ones. The test disc for this project is shown below. You can see

PIC16F688 based Digital Voltmeter

Actually this is the another version of my older DVM project that was based on PIC12F683. The older version displays the measured voltage on a LCD that is driven serially by PIC12F683 using 3 I/O pins. The new one uses PIC16F688 microcontroller that doesn't require the serial driver as it has got enough pins to drive a LCD directly in 4-bit mode. The theory and math is just the same. You can read my PIC12F683 version of this project here . Circuit Diagram Circuit on breadboard

EnerJar: A Digital Energy Meter

This project won the grand prize of 2008 Green Gadgets Design competition. It measures the power consumption of an electrical gadget with high accuracy. The project uses PIC16F877A microcontroller to compute the power and shows the output on a 4-digit multiplexed seven segment display. The power consumed by an electrical appliance is simply the product of voltage across the appliance and the current drawn by it. Voltage measurement is pretty straight forward. Using a resistor divider network, 120 V can be converted down to below 5 V, and can be read through ADC port. However, PIC cannot measure the current directly, it must be converted to voltage first. This is done by a low shunt resistance. This voltage drop across the shunt resistance is too small and requires a precision instrumentation amplifier to boost it to appropriate level.

Digital Voltmeter using PIC12F683

This is a digital voltmeter project based on PIC12F683 microcontroller. It measures and displays input voltage from 0 to 20V with high accuracy. You cannot feed 20V directly to PIC port, so a simple resistor divider network is used for this purpose. A 5.1V zener diode is used to prevent any damage to PIC port in case the input voltage goes way above 20V. Since PIC12F683 does not have sufficient pins to drive a LCD, 3-wire serial discussed before is used to display the measured voltage.

My PIC Projects

Here's the list of all of my PIC Projects posted so far:

Centigrade and Fahrenheit Scale Digital Thermometer with LCD Display

Digital thermometers are cool devices as they show temperatures in human readable formats. This digital thermometer project is based on a PIC16F688 microcontroller and a DS1820 temperature sensor, and it displays temperature on a character LCD screen in both Celsius and Fahrenheit scales. I selected PIC16F688 for this project because it is cheap (I bought one for $1.50). DS1820 is a 3-pin digital temperature sensor from Dallas semiconductors (now Maxim) which is designed to measure temperatures ranging from -55 to +125 °C in 0.5 °C increments. The firmware I have written is able to read and display the entire temperature range of DS1820. In order to test for temperature measurements below 0°C, I put the sensor inside my freezer. While trying this, don’t put the whole unit inside the freezer as LCD display unit may stop working at the freezer temperature. Similarly, bringing a soldering iron tip close to the sensor can do testing for the higher range temperature values.

Make your own Serial LCD for PIC Microcontrollers

HD44780 based character LCD displays are very popular among hobbyists. They are easy to interface with microcontrollers and most of the present day high-level compilers have in-built routines for them. However, the bad part is at least 6 I/O pins of microcontroller are required to use them in your project. Therefore, they are not applicable for 8-pin devices like PIC12F series microchips. The aim of this project is to allow LCD interfacing to such devices using 3-wires. I am going to demonstrate this with PIC12F683 microcontroller. The character data or command from the microcontroller will be transferred serially to an 8-bit serial-in parallel-out shift register (74HC595), and the parallel output will be fed to the LCD driver pins.

Using PIC Timer1 Module for Counting Frequency of an External Clock Source

The Timer1 module inside PIC12F683 is a 16-bit timer/counter. If used as an asynchronous counter, this module can be used for counting the frequency of an external clock source applied to its GP5/T1CKI port. The following example is a 0-65535 Hz frequency counter using Timer1 module of PIC12F683. The Timer1 module is reset first and then turned ON for 1 sec to count the clock pulses arrived at its T1CKI port during that period. The number of pulses arrived in  second is frequency itself. The measured frequency value is sent to PC through serial port and displayed on a hyperterminal receiver window. If the external clock frequency is over 65535 Hz, Timer1 overflows and an interrupt is generated. In case of the overflow, "Frequency out of range " message is displayed on the window. A 555 Timer IC running as an astable multivibrator is used as the external clock source.

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

Neat LED Chaser for Hobbyists

Besides just turning ON and OFF, there are lot of other stuff that you can do with LEDs. In one of my experiments, I showed how to control the intensity of an LED using PWM. Here's a project that uses the similar concept to generate 8-channel PWM signals through PIC16F628A ports and drive 8 LEDs with 4 levels of intensity. A number of visual effects and chase sequences are programmed into the firmware. Enjoy watching this video! 

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 Experiments

Here's the list of all the experiments I have posted on this blog. I have performed these experiments on my PIC16F628A development board. (First read about my PIC16F628A Development Board )

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:             PIC16F628A      Oscillator:      XT, 4.0 MHz */ // Temperature digits unsigned short

Gear Clock Controlled by PIC16F628A

I was browsing internet for PIC16F628A related projects and I saw this. This guy came up with an amazing idea. He made some wooden gears, tied them up, and drove with a stepper motor from a floppy drive, and turn it into a Gear Clock. The stepper motor is controlled by a PIC16F628A Microchip that also keeps track of time. You can set time with the help of two switches that control clockwise and anti-clockwise motion of the minute gear. If both the switches are pressed, the stepper motor is de-energized and the minute gear is free to rotate by hand. Source:  http://alan-parekh.com/projects/gear-clock/

Digital Thermometer on a Nokia LCD Screen

If you have an old Nokia 3310 cell phone, don't throw it away. You can use its LCD screen for this cool project. This project describes the use of such a LCD to display temperature.  It uses PIC12F629 microchip as a brain that reads temperature measurement from a DS18B20 sensor, and displays it on a Nokia 3310 LCD screen. Source:  http://www.ivica-novakovic.from.hr/Nokia%20Lcd%20Termometar-eng.htm

A tiny Temperature Data Logger using PIC12F683 and DS1820

For past few days, I have been working on a PIC12F683 based temperature data logger. I just finished this project and the product is available on my PIC12F683 blog page.This is how the finished product looks like. It reads temperature values from a DS1820 sensor and stores in its internal EEPROM. It has 3 selectable sampling intervals (1 sec, 1 min, and 10 min). Three tact switches provides 7 functions, and this runs with 3  AAA batteries. It can be interfaced to a PC through serial port, and also has an ISCP header for firmware upgrade.

MSP430 LaunchPad: Super Cheap Embedded Design Tool for just $4.30

Texas Instrument is going to make a big move into the hobbyist microcontroller market by introducing MSP430 Launchpad, a development platform for 16-bit MSP430 microcontrollers. Can you guess its price? Yes, $4.30 with free FedEx shipping. It is unbelievable! "What is LaunchPad? LaunchPad is an easy-to-use development tool intended for beginners and experienced users alike for creating microcontroller-based applications. At $4.30, the LaunchPad offers everything you need to get started with your projects.

Variable DC Power Supply (1.25 - 18V) using LM350 IC

Introduction A variable DC power supply is one of the most important tools for an electronics hobbyist. In order to carry out an experiment you need a reliable DC power source that can be varied according to the need of the experiment. Last week I felt I must have one on my workbench, and thought to make one for myself. This design is very simple but is great for powering almost all kinds electronic projects. It uses LM350 (a 3-pin IC) to generate a variable DC power supply. I would recommend to read the datasheet before doing this project. The LM350 is an adjustable 3-terminal positive voltage regulator that is capable of supplying in excess of 3A over a 1.2V to 33V output range. They are exceptionally easy to use and require only 2 external resistors to set the output voltage.

External Interrupt Demonstration with PIC12F683

PIC12F683 has got one external interrupt input which is edge triggered. If you want to learn how to write an Interrupt Service  Routine (ISR) using mikroC compiler, check this out. When an interrpt arrives, the PIC12F683 displays the interrupt arrival information as a part of ISR on a windows PC hyper-terminal through software UART.

Using ADC in mikroC

With mikroC built-in library, use of ADC on PIC microcontrollers has become more simple. PIC16F628A doesn't have in-built ADC in it, so I am going to demonstrate this with my PIC12F683 development board. The analog input will be given through a potentiometer, and the 10-bit digital output will be displayed on a hyperterminal window on PC.

PIC12F683 Development Board

I have recently made a new PIC development board for PIC12F683. It is an 8-pin microcontroller with a lot of good features including 10-bit ADC and PWM. The development board has following features: 1. A Regulated +5V power supply. 2. 3 Red LED outputs which can be connected to any GPIO pins using jumper wires. 3. An ON/OFF power supply switch. 4. A Green LED as a power ON indicator. 5. An 8-pin IC socket for PIC12F683 microcontroller. 6. Two potentiometers: one for providing Vref, and other for simulating analog input to ADC. 7. An ICSP header connector. 8. Two tactile switches for input operation. 9. A TTL to RS232 level shifter using a transistor circuit. 10. A piezo buzzer. 11. A DC motor with driving circuit. 12. Access to individual pins of PIC12F683 through female header pins.

Experiment No. 11: Temperature Data Logger Using PIC16F628A Microcontroller

This project is the combination of the two experiments that we already did in past: Experiment No. 4 and 10. In experiment 4, we demonstrated how to use the mikroC 1-wire library to read temperature data from a digital sensor DS1820, and display the value on a LCD screen. Now we are going to use the hardware UART to transfer the temperature data from the PIC to a PC (Exp. No. 10). The Hyper-Terminal program running on a PC will receive the temperature values and display on screen. The temperature data from the microcontroller will be sent in every 15 sec. Experimental Setup: The setup for this experiment is same as the Experiment no. 10 with a DS1820 inserted in its 3-pin female header receiver on the board. The data output of DS1820 is connected to RB.0 (see articles  Exp. No. 4 and 1-Wire Protocol for detail). You need to rebuild the same TTL to RS232 level shifter circuit on a breadboard and set up a hyper-terminal to receive data at 9600 baud rate.

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.