Recent Changes - Search:

Introduction to Microcontroller Programming

About PICmicro Chips

Clocking Your PICmicro Devices


Flowcode Step By Step

PICmicro Projects


Lab 2 - Delay

1. Introduction

Microcontrollers are extremely fast. A PIC that is clocked with an Xtal of 20MHz will execute about 5,000,000 assembly instructions, every second. To let the PIC communicate with ‘slow’ humans, we will need to slow it down at certain times. This is done by adding a Delay instruction.

2. Setting up the equipment
3. Hardware settings
EB006 OptionsSettingJumper settings (EB006)Jumper settings (HP488)
Power supplyExternal, 14VJ29: PSUJ29: PSU
PICmicro device16F1937  
Programming methodUSBJ12,13,14: USBJ20: USB
Clocking methodXTALSW2: XTALS2: XTAL
R/C clock speed   
Xtal frequency19.660.800Hz  
LVP Jumper selectionI/O PortJ11,16,17: I/O PortJ15,16,18: I/O
Port A E-block   
Port B E-blockLED board  
Port C E-block   
Port D E-block   
Port E E-block   
4. Flowcode and download settings
Build > Project Options... > General Options Build > Project Options... > Configure
Clock speed19 660 800 Hz
Simulation speedAs fast as possible
Watchdog timerOff
5. Software learning objectives

Output, Delay, Timing, binary code training, compiling a program to the PIC, clocking the PIC, PIC microcontroller basics.

6. Hardware learning objectives

LED’s, logic output levels, Multiprogrammer basics, speed of a microcontroller, time measurement with an oscilloscope.

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) and Decisions (step 7). 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.

Also 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. You'll learn how delays are used to slow the PIC down. Keep aware that your PIC microcontroller executes approximately at 5,000,000 assembly instructions per second and that the human eye in combination with the brain can only detect and understand approximately 3 stable images per second.

8. Labs
Letter Meaning
L Lab x
B Basic complexity
I Intermediate complexity
E Expert complexity
Open the program [L1-B9] that you wrote in LAB 1 use 'Delay' instructions between the 20 different output instructions to visualise these different outputs, even at HS Xtal speeds. Download the program to the PIC that is clocked by the Xtal.
In the exercise above: start with a delay of 1 sec and make the delay shorter, step by step until the point that it gets too fast for your eyes to detect 2 different LED outputs. Do not test this in simulation mode. The timing in simulation mode is not always correct because it runs under a Windows operating system and this is not ‘real time’. Download the program to the PIC every time you change the delay and test it on the actual E-blocks.
Light LEDs 0-7 one by one, turn them all off and then back on. Use delays to make it all viewable on the actual E-blocks. Clocking of the PIC is done by an Xtal of 19,660,800Hz.
If you have an oscilloscope, use it to measure if the delays you have set up in Flowcode are correct. Make a detailed drawing of the oscilloscope image you see and add correct voltage and timing information to it. Make a note on it what delay-time you used in your Flowcode program.

Print - Search - Login

Page last modified on May 14, 2013, at 02:50 PM