0% found this document useful (0 votes)
121 views4 pages

Lab 5 - Loop: EB006 Options Setting Jumper Settings (EB006) Jumper Settings (HP488)

This document provides instructions for a series of lab exercises to practice using loops in a microcontroller programming environment. Students will create programs that use different looping techniques like counting, running lights, and arrays to output patterns on LEDs. The exercises start basic and increase in complexity, covering topics such as binary counting, bidirectional running lights, multi-port outputs, and manipulating values in arrays within loops. Students will run their programs on a PIC microcontroller evaluation board to demonstrate the looping behaviors.

Uploaded by

John Malgapo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
121 views4 pages

Lab 5 - Loop: EB006 Options Setting Jumper Settings (EB006) Jumper Settings (HP488)

This document provides instructions for a series of lab exercises to practice using loops in a microcontroller programming environment. Students will create programs that use different looping techniques like counting, running lights, and arrays to output patterns on LEDs. The exercises start basic and increase in complexity, covering topics such as binary counting, bidirectional running lights, multi-port outputs, and manipulating values in arrays within loops. Students will run their programs on a PIC microcontroller evaluation board to demonstrate the looping behaviors.

Uploaded by

John Malgapo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Lab 5 - Loop

 
1. Introduction
Repeating a certain set of instructions, for an exact amount of times, while or until a
condition is met is one of the most powerful programming operations known. You
will experience this as you do the lab exercises below. The programs get a lot more
interesting but also more complex to understand from now on. Use the slow
simulation or 'Step Over'   function in the Flowcode simulator to debug your
programs from now on.
2. Setting up the equipment

3. Hardware settings
Jumper settings Jumper settings
EB006 Options Setting
(EB006) (HP488)
Power supply External, 14V J29: PSU J29: PSU
PICmicro device 16F1937    
Programming
USB J12,13,14: USB J20: USB
method
Clocking method XTAL SW2: XTAL S2: XTAL
R/C clock speed      
19 660 800
Xtal frequency    
Hz
LVP Jumper
I/O Port J11,16,17: I/O Port J15,16,18: I/O
selection
Port A E-block      
Port B E-block LED board    
Port C E-block      
Port D E-block      
Port E E-block      
4. Flowcode and download settings
Build > Project Options... > General Build > Project Options... >
Options Configure
Options Setting Options Setting
Clock speed 19 660 800 Hz Device 16F1937
Simulation speed 10 RC/XT XTAL
Watchdog timer Off
5. Software learning objectives
Output, binary code training, Infinite loop, conditional loop, compiling a program to
the PIC, clocking the PIC, PIC microcontroller basics.
6. Hardware learning objectives
LED’s, logic output levels, Multiprogrammer basics, microcontroller speed of
execution.
7. Instructions
Construct the system shown from E-blocks.

In the course navigate to the ‘Flowcode step-by-step’ and review the section on Basic
Loops (Step 4), LCD Display (Step 5) and Goto Connection Point (Step 6). In the
course you will also find the sections on Clocking your PIC, and about PIC
microcontroller basics useful. The descriptions of the Multiprogrammer board and the
LED board are in the E-blocks section.
In lab L5-E7-G, you will need to know about Array variables. You will find info on
this in the help-file of Flowcode 4 and in section String and Memory (Step 11).

Make use of the Help-function in Flowcode to get the info you need.

During these exercises you are going to send different 8-bit codes to Port B of your
microcontroller . The PIC is very fast in Xtal mode. Be aware of this and use correct
delays where needed to slow it down to ‘human’-speed.
8. Labs
Letter Meaning

L Lab x

B Basic
complexity

I Intermediate
complexity

E Expert
complexity

L5-B1
Make an 8-bit binary counter that counts from 0-255, then repeats 0-255 and so
on. Show the counter value on the LEDs of Port B. Use a loop-icon to do this.
L5-B2
Make an 8-bit binary counter that counts from 0-255 then back down from 255
to 0. These 2 loops have to be repeated for ever. Show all of the steps on the
LEDs of Port B. Download the program to the PIC and demonstrate it at full
speed.
L5-B3
Make a simple running light that runs from PB0 to PB7 and starts back from
PB0 and so on. Use the 'multiply by 2' method to do this. Show all of the steps
on the LEDs of Port B.
L5-B4
Make a simple running light that runs from PB0 to PB7 and starts back from
PB0 and so on. Use the 'shift right' method to do this. Show all of the steps on
the LEDs of Port B.
L5-I5
Change the program of the running light so that the light runs back when it
reaches PB7. Use the 'multiply by 2' method. The sequence should now be
PB0-PB7 and back from PB7-PB0 and so on. (Remember KITT From Knight
Rider or the Cylon robots from Battlestar Galactica?).
L5-I6
Change the program of the running light so that the light runs back when it
reaches PB7. Use the 'shift right' method to do this. The sequence should now
be PB0-PB7 and back from PB7-PB0 and so on.
L5-I7
Change the program of [L5-I6] so that this is a 16-bit running light (LEDs at
both Port C and D). Use only loops, no decisions. Save this program as [L5-I7-
G], download it to the PIC
L5-E8
Define an Array of 4 variables called Matrix[x]. Fill the 4 variables of this
Array with these values: Matrix[0]=129; Matrix[1]=66; Matrix[2]=36;
Matrix[3]=24. Use 2 'do While loops' to create this infinite sequence:
Matrix[0]-Matrix[1]-Matrix[2]-Matrix[3]-Matrix[2]-Matrix[1]-Matrix[0]-
Matrix[1]-..... . Show this on the LEDs of Port B. You can only refer to these
separate Matrix-variables as Matrix[x] where x is a separate variable that points
to the variable that is needed at that moment. Save this program as [L5-E8-G],
download it to the PIC.

You might also like