Skip to main content

Posts

Showing posts from September, 2009

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.

DS18S20 : 1-Wire Digital Thermometer and mikroC OneWire Library

Introduction
The DS18S20 is a 1-Wire digital thermometer device from MAXIM that provides 9-bit Celsius temperature measurements and communicates over a 1-Wire bus with a central microprocessor. It also has in-built alarm function with nonvolatile user-programmable upper and lower trigger points. The operating temperature range of the device is –55°C to +125°C with an accuracy of ±0.5°C over the range of –10°C to +85°C. Each DS18S20 has a unique 64-bit serial code, which allows multiple DS18S20s to function on the same 1-Wire bus. Thus, it is simple to use one microprocessor to control many DS18S20s distributed over a large area.


The 1-Wire Communication Protocol

The 1-Wire is a registered trademark of Dallas Semiconductor Corp (now Maxim) for a serial communication protocol using a single data line and a ground reference. A 1-Wire Master (a microcontroller) initiates and controls the communication with one or more 1-Wire Slave devices (usually sensors). Each 1-Wire slave device has a unique, factory-programmed , 64-bit identifier, which serves as device address on the 1-Wire bus. This globally unique address is composed of eight bytes divided into three main sections. Starting with the LSB, the first byte stores the 8-bit family codes that identify the device type. The next six bytes store a customizable 48-bit individual address. The last byte, the most significant byte (MSB), contains a cyclic redundancy check (CRC) with a value based on the data contained in the first seven bytes. This allows the master to determine if an address was read without error. With a 248 serial number pool, conflicting or duplicate node addresses on the net are n…

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

About PIC16F628A

PIC16F628A is a powerful (200 nanosecond instruction execution) yet easy-to-program (only 35 single word instructions) CMOS FLASH-based 8-bit microcontroller from Microchip. It comes into an 18-pin package and is upwards compatible with the PIC16F628, PIC16C62XA, PIC16C5X and PIC12CXXX devices.

Experiment No. 2 : Push Button and Seven Segment Display Interface

In this experiment, we will program the PIC16F628A as an UP/DOWN Decade Counter. The count value will be displayed on a Seven-Segment Display and will be incremented/decremented by two push buttons on the board.

Experimental Setup:
The board has built in interface for a multiplexed 4-digit seven segment display (HS-5461AS2 from www.futurlec.com).We will select only one digit by connecting a Digit Select pin to Vcc, as shown in figure below. A black jumper wire is used for this purpose. The seven segments will be driven through PORTB (already wired on the board). Connect Push Buttons (PB3 and PB4) to RA1 and RA0 female headers using jumper wires.


PIC microcontrollers: Nebojsa Matic (Free Online Book)

If you are a beginner to PIC microcontroller, I would recommend you to read this free e-book on PIC16F84 microcontroller. PIC16F84 is one of the most popular PIC family microcontrollers that resembles very much with PIC16F628A.
In this book you will find:
Introduction to microcontrollers Learn what they are, how they work, and how they can be helpful in your work.Practical connection samples for  Relays, Optocouplers, LCD's, Keys, Digits, A to D Converters, Serial communication etc.How to write your first program, use of macros, addressing modes...Instruction Set Description, sample and purpose for using each instruction...MPLAB program package How to install it, how to start the first program, following the program step by step in the simulator...

Ready to read now? Click Here

Experiment No. 1 : 4-Bit Binary Counter

Experimental Setup:
The first experiment that we are going to do with our PIC16F628A board is a 4-bit binary counter that counts from 0(00h) to 15(0Fh) with 1sec delay between each count. The output will be at RB.0 through RB.3 and will be displayed on 4 LEDs. Use four jumper wires to connect RB.0 through RB.3 to LEDs. The picture below shows these connections.


Figure 1. Jumper Connections for a 4-bit Binary Counter

PIC16F628A Development Board

The development board we are going to make for our experimental microcontroller PIC16F628A will look like this. Here are the features it is going to have:
Access to all I/O pins through female header pins4 Push Buttons for Input4 LEDs for OutputAn LCD Interface PortA 4-digit Seven-Segment Display InterfaceLCD Backlight Switch and Contrast AdjustmentICSP Programming (Very Important)

Why use the PIC?

Source:PICmicro MCU C : An introduction to programming the Microchip PIC in CCS C by Nigel Gardner