You are on page 1of 2

EE 483 Lab #4: Position Sensor & PWM

Due April 6th, 2000

Purpose:
The purpose of this lab is to control the speed of a DC motor using
A PIC microcontroller,
A potentiometer as an input, and
Using an optical encoder as an input.

Equipment:
10k potentiometer
PIC16F876 Microcontroller,
MPLAB & PICSTART PLUS programmer,
12VDC Muffin Fan
ZTX718-ND Transstor (300 < β < 1200 , I CE < 3A )
HP Oscilloscope
Cadet Board

Circuits:
A PIC16F876 is connected to an LCD display, a 10k potentiometer, and a 12V DC motor as shown below. Most of this
(save the motor ) are a part of the PIC evaluation board in Room 227.

+5
PIC16F876 LCD
28 1
PB7 gnd
27 2
PB6 Vdd
26 3
PB5 Contrast
25 4
PB4 E
24 5
PB3 R/W
23 6
PB2 R/S
22
PB1
21 11
PB0 D4
12
D5
13
1.3k ditto for D6
14
each output D7
on Ports A, B, & C
LED
+12
18
PC7
17
PC6
16
+5 PC5
15
1
PC4
14
Motor
MCLR
20
PC3
Vdd 13
PC2
12
4MHz 9 PC1

22pF
OSC1
PC0
11
300
+5
ZTX1055A
22pF 10 6
PA4
OSC2
8 5
Vss
PA3
19 4
Vss
PA2 10k
3
PA1
2
PA0
Procedure:
Step 1: Turning On and Off a Motor using a PIC Microcontroller
In room 227 are three PIC stations. Under the directory C:\MPLAB\EE483\LAB4 are files STEP1.ASM to STEP4.ASM.
Copy STEP1.ASM to another name (like JAKE.ASM). Start MPLAB and create a new project with the same nake
(JAKE.PJT) and include your file (JAKE.ASM).
Modify this file so that it
Sends a '1' to Port C for 64ms and then
Sends a '0' to Port C for 64ms and repeats
Download this program to a PIC microchip (directions on the wall or similar to Homework #7).
What value do you need to use in Subroutine Sec01 for a period of 128ms?
Step 2: Reading the A/D Input
Modify this program so that it
Reads PA0 as a 10-bit number,
Converts this to an 7-bit number, N , and
Displays this 7-bit number on the LCD display, and
repeats
Step 3: Controlling the Fan Speed using PWM Based Upon the A/D Input
Once you can read the A/D input, modify it so that it
Sends a '1' to Port C for 1ms * N, (minimum = 1ms)
Sends a '0' to Port C for 1ms * (128 - N), and
repeats
Step 4: Calibration Curve
Program a PIC chip with your program and record the
Voltage applied to the PIC chip,
The fan speed (blades / second)
for voltages between 0V and +5V. Plot this data on a graph.

You might also like