Professional Documents
Culture Documents
PW3 Pic
PW3 Pic
PRACTICAL WORK 3
16 JAN 2023
Course
Prepared by: Coordinator
Head of Programme /Head of Dept. 6 FEB 2023
Verified by:
PW3: PIC TIMER PROGRAMMING
INSTRUCTIONS:
i. Implementation in groups (max. 4 students) ii. Each student must
answer the questions that have been prepared in their respective
sections.
iii. Make a group discussion to produce and share ideas to solve
the question.
iv. Conclusion and discussion must be written as a group v. All
program code must be written in handwriting.
vi. Groups need to submit this practical work along with the cover sheet,
answers, and rubric ONLY to the lecturer before the due date.
LEARNING OUTCOMES (LO):
OBJECTIVES
Upon completion of this course, students should be able to:
i. Write C program for PIC timer and counter.
ii. Draw and simulate PIC timer and counter in Proteus.
iii. Build timer and counter hardware circuit.
EQUIPMENT / TOOLS
SAFETY PRECAUTIONS
The following safety precaution shoul be taken when using equipment. Precaution
are most important for safety from accident :
DEE40053/PW3/REV00/16JAN2023 Page 2 of 23
PW3: PIC TIMER PROGRAMMING
ii. Keep proper discipline in the laboratory. iii. Turn off the electricity when
not in use, especially the computer. iv. In the event of any
emergency/circuit leakage, please inform the lecturer. v. Students are
not allowed to eat or drink in laboratory. vi. Students must wear
appropriate attire when in the laboratory.
THEORY
DEE40053/PW3/REV00/16JAN2023 Page 3 of 23
PW3: PIC TIMER PROGRAMMING
TUTORIAL
T0CON = 0b________;
Find values to be loaded into TMR0H and TMR0L for creating 500 mili-second
delay using steps below.
Step 1
Time for 1 cycle,
𝟏
𝟏𝑻𝒄𝒚 =
𝑭𝒐𝒔𝒄 𝒙 𝟒 𝒙 𝒑𝒓𝒆𝒔𝒄𝒂𝒍𝒂𝒓
Step 2
Get the number of counts by Dividing the desired time delay by 1Tcy
Step 3
Perform 65,536 - n, where n is the decimal value we got in Step 2.
Step 4
Convert the result of Step 3 to hex, where yyxx is the initial hex value to be loaded
into the timer’s registers.
xxyy10 → xxyy16
DEE40053/PW3/REV00/16JAN2023 Page 4 of 23
PW3: PIC TIMER PROGRAMMING
Step 5
Set TMR0H = yy16 and TMR0L = xx16
Tutorial 2: (Timer as a time delay)
Create a new file. Write a program in Figure 2 into your Untitled window. Fill the red
box using suitable instructions. Then build the program until successful. If any error
occurs, fix it.
DEE40053/PW3/REV00/16JAN2023 Page 5 of 23
PW3: PIC TIMER PROGRAMMING
• Timer0 OFF
• Timer0 is configured as a 8-bit timer/counter
• Transition on T0CKI pin
• Increment on low-to-high transition on T0CKI pin
• Timer0 prescaler is NOT assigned
• 1:2 Prescale value
T0CON =
DEE40053/PW3/REV00/16JAN2023 Page 6 of 23
PW3: PIC TIMER PROGRAMMING
S1 NAME:
S1 ID:
S1 QUESTION: Find values to be loaded into TMR0H and TMR0L for creating
100 millisecond delay using steps below.
DEE40053/PW3/REV00/16JAN2023 Page 7 of 23
PW3: PIC TIMER PROGRAMMING
S1 ANSWER:
(using proteus simulation capture dan observing the simulation result for each changing process
changing in Tutorial 2)
BEFORE
AFTER
DEE40053/PW3/REV00/16JAN2023 Page 8 of 23
PW3: PIC TIMER PROGRAMMING
DEE40053/PW3/REV00/16JAN2023 Page 9 of 23
PW3: PIC TIMER PROGRAMMING
S2 NAME:
S2 ID:
S2 QUESTION: Find values to be loaded into TMR0H and TMR0L for creating
200 millisecond delay using steps below.
S2 ANSWER: (Write your calculation values of TMR0H and TMR0L here)
DEE40053/PW3/REV00/16JAN2023 Page 10 of 23
PW3: PIC TIMER PROGRAMMING
DEE40053/PW3/REV00/16JAN2023 Page 11 of 23
PW3: PIC TIMER PROGRAMMING
S2 ANSWER:
(using proteus simulation capture dan observing the simulation result for each changing process
changing in Tutorial 2)
BEFORE
AFTER
DEE40053/PW3/REV00/16JAN2023 Page 12 of 23
PW3: PIC TIMER PROGRAMMING
DEE40053/PW3/REV00/16JAN2023 Page 13 of 23
PW3: PIC TIMER PROGRAMMING
S3 NAME:
S3 ID:
S3 QUESTION: Find values to be loaded into TMR0H and TMR0L for creating
300 millisecond delay using steps below.
S3 ANSWER: (Write your calculation values of TMR0H and TMR0L here)
DEE40053/PW3/REV00/16JAN2023 Page 14 of 23
PW3: PIC TIMER PROGRAMMING
S3 ANSWER:
(using proteus simulation capture dan observing the simulation result for each changing process
changing in Tutorial 3)
DEE40053/PW3/REV00/16JAN2023 Page 15 of 23
PW3: PIC TIMER PROGRAMMING
DEE40053/PW3/REV00/16JAN2023 Page 16 of 23
PW3: PIC TIMER PROGRAMMING
S4 NAME:
S4 ID:
S4 QUESTION: Find values to be loaded into TMR0H and TMR0L for creating
300 millisecond delay using steps below.
S4 ANSWER: (Write your calculation values of TMR0H and TMR0L here)
DEE40053/PW3/REV00/16JAN2023 17 of 23
PW3: PIC TIMER PROGRAMMING
S4 ANSWER:
(using proteus simulation capture dan observing the simulation result for each changing process
changing in Tutorial 3)
DEE40053/PW3/REV00/16JAN2023 18 of 23
PW3: PIC TIMER PROGRAMMING
DISCUSSION:
(Discussion refers to the findings of practical work through observation, problems
encountered during performance practical work and suggestions for improvement)
CONCLUSION:
(Write a conclusion based on the objective of the practical work that has been done)
The conclusion that I can make from this practical work are I can write
C program for PIC timer and counter. After that, I can draw and stimulate
PIC timer and counter in proteus.Lastly, I can build timer and counter
hardware circuit.
DEE40053/PW3/REV00/16JAN2023 19 of 23
PW3: PIC TIMER PROGRAMMING
DEE40053/PW3/REV00/16JAN2023 20 of 23
PW3: PIC TIMER PROGRAMMING
CRITERIA 1 2 3 4 5 weight S1 S2 S3 S4
Average Excellent
Weak Satisfactory Good
Write Program Unable to type a Able to type Able to type all Able to type all Able to type all
program program but totally parts of the parts of the parts of the
)
06 %
using MPLAB are incorrect. program, but less program, but less program correctly. x5
X IDE than 60% of the than 80% of the
PRACTICAL SKILL (
Compile Student cannot Student cannot fix Student cannot fix Student cannot fix Execute all
program using fix the error after the error after being the error after the error after program
MPLAB X IDE being assisted by assisted by lecturer being assisted by being assisted by successfully without x5
lecturer many 3 times. lecturer 2 times. lecturer 1 time assistance
times.
Student cannot Student cannot fix Student cannot fix Student cannot fix Student can sketch
Construct fix the circuit the circuit the circuit the circuit all connection of
circuit using connection by connection by itself connection by connection by circuit correctly x4
hardware or itself after being after being assisted itself after being itself after being without
software assisted by by lecturer 3 times. assisted by assisted by assistance.
Proteus lecturer many lecturer 2 times. lecturer 1 time.
simulation. times.
CRITERIA 1 2 3 4 5 weight S1 S2 S3 S4
Average Excellent
Weak Satisfactory Good
Handwritten Unable to write a Able to write program Able to write all parts Able to write all parts Able to write all parts
coding program but totally are of the program, but of the program, but of the program
)
0%
incorrect. less than 80% of the less than 80% of the correctly. x2
REPORT (4
Observation The changing Student can display Student can display Student can display Student can show all
process of or prove less than or prove less than or prove less than of the simulation’s
simulation cannot 30% of the 50% of the 80% of the changing processes
be displayed by the simulation’s changing simulation’s simulation’s correctly.
student. process. changing process. changing process.
x2
Very incomplete or Some of the results Almost of the results Almost all the results All-important trends x1
incorrect have been correctly have been correctly have been correctly and data comparisons
Discussion
interpretation of interpreted and interpreted and interpreted and have been interpreted
trends and discussed; partial but discussed, only discussed, only correctly and
comparison of data incomplete minor improvements minor improvements discussed; good
indicating a lack of understanding of are needed are needed understanding of
understanding of results is still evident results is conveyed
results
Conclusion No conclusion was A statement of the A statement of the Accurate statement Accurate statement of x1
included or shows results is incomplete results of the lab of the results of the the results of lab
little effort and with little reflection on indicates whether lab indicates indicates whether
reflection on the lab the lab results support the whether results results support
hypothesis support the hypothesis. Possible
hypothesis Possible sources of error and
sources of error what was learned
identified from the lab discussed
Total 100
DEE40053/PW3/REV00/16JAN2023 Page 13 of 13