This page created with Cool Page.  Click to get your own FREE copy of Cool Page!
LAB X-1 Tutorial and Resource Book
15 April '06
This is the LAB X-1 Board made by microEngineering Labs., Inc.  If you are interested in single chip computers, it is the ideal platform to learn on.  This is the board I used to learn what I know about these fascinating logic engines and this the the board the book is all about.  You learn by learning to use all the many features of this board.
Mailing Address                                Make Paypal Remittances to
H. S. Sandhu                           
Electric Vehicle Corporation
705 West Kirby Avenue                     
Champaign IL 61820-6833 USA          217-359-6751
(8am to 6 pm Central Daylight Time)
Shipping and handling for all US destinations is $4.00  (USPO)
The book is a detailed 190 page Owner's manual and Tutorial on the 40 pin PIC 16F877A microprocessor that fits in the main socket on this board.  The PIC 16F877A is a very powerful computer on a chip and can be intimidating for the first time user.   The tutorial provides the explanations and sample programs you need to get you started.  After going through all the exercises you should be able to design and program your own devices.

Here is an excerpt from the preface:

The workbook is not designed to make you an expert in machine language programming or to prepare you to become a technical expert on PIC microprocessors.  It is designed to give you a solid understanding of what these logical engines can do for you and how you can use them to do it.  I will cover everything in a non-mathematical even somewhat non technical format so that if you have a minimal understanding of things mechanical and electronic, you will be able to use these microcontrollers to do useful work.  With this in mind I have concentrated on using the PicBasic Pro compiler that is provided by the manufacturers of the board to generate the assembly level machine code rather than spending time on teaching you how to use the assembly language resources that are available.  The compiler uses a dialect of BASIC that is easy to use and very powerful in that it does everything that you need done in the context of programming the processors.  The code generated is both compact and fast.  There are times when assembly language subroutines can be added to the programming to make an especially critical task execute faster and if you need to do this there is ample information available on the subject.  The coverage in this workbook of assembly language is minimal and concentrates on suggesting where to use it when such programming is needed rather than actually going into how to do it. 

The workbook teaches you about microprocessors by having you do a number of software and hardware exercises and there are two types of exercises in the workbook.  Exercises of the first type are designed to be executed on the LAB X1 board provided by microEngineering Labs, Inc. so that you do not have to build anything to learn about the software aspects of understand microcontrollers and uses the hardware items that are already on the board.  The projects are designed to make you familiar with dealing with the real world of sensors like switches and potentiometers and how they can be used with microcontrollers to get the results that you want.  The second type of exercises require a few extra pieces of hardware so that you can experiment with and learn about some of the other capability of the microprocessors. 

The workbook starts out with the simple control of light emitting diodes (LEDs) on the board and continues to the control of and writing to the two line by 20 characters display that is on the experimenter board.  In later chapters we learn how to actually display information on the CRT of a computer and how the PIC microprocessors can be a very powerful and useful adjunct to your personal computer via the serial port.

$49.95   for the book only.  Order board from microEngineering Labs.
And here is a short excerpt from the section on using the input/output.

Section 05
Controlling the Input and the Output.


All the programs that we will be discussing in this section are provided on the CD ROM that comes with this manual. You can copy them from the CD to run them. The exercises listed in each section are exercises that are designed to increase your familiarity and competence with the 16F877.  The answers to them are not provided.

In preparation for writing programs, set up the LAB X1 so that it can be programmed with one mouse button click or by pressing F10 as is described in detail in the Appendix.

The I/O that uses ICs in the seven empty sockets on the LAB X1 board is covered separately in the sections on Empty Sockets. See Section 07.   These sections also cover one wire memory, A to D converters and thermometric devices.

The I/O that uses the serial port (as RS-232 or RS485) is covered in the section on communications.  See Section 08.  This covers communications between the PICs and personal computers.

We will learn about input and output by writing simple programs that control the outputs and read the inputs.  We will learn how to control the outputs first because this can be done directly from the software without need for any input. Once we can control the output we will learn how to read the inputs and make them interact with the output.  Here is a list of the programs to be developed..

Output programs

Write a program to blink one LED on the bargraph
Blink all 8 LEDs in the bargraph consecutively
Dim and brighten one LED
Write "Hello World" to the LCD on the two lines
Write binary and decimal values to the LCD
Output a simple tone on the speaker
Output a telephone tone signal on the speaker

Move an R/C servo back and forth

Inputs programs

Write a simple program to read the first column, first row button and turn on one LED while the button is down.
Read entire keyboard and display the binary value of the row and column read on the LCD
Read keyboard and display decimal key number on the LCD
Read one potentiometer and display its 8 bit value on the LCD in binary, hex and decimal notation.   Also display the binary value on the bargraph.
Read all three potentiometers and display their values on LCD
Use three potentiometers to control an R/C servo.  Control the location of the center position, the limit position of the end positions and the rate of movement.  Use three switches to move the servo clockwise, center the servo and move it counterclockwise.


It will be easier if we learn to control the outputs first because we can do this from programs that we write without the need for any additional hardware or input signal.  We will start with the simple control of LEDs and proceed to the control of the two line LCD that is provided on the LAB X1 and then on to using the speaker and an R/C hobby servo.

Let us start with the standard "turning an LED on and off" program.  We will use one of the LEDs in the 10 LED bargraph that is provided on the LAB X1.  We have control of only the rightmost 8 LEDs on this bargraph.  The leftmost LED is the power ON indicator and the one next to it comes ON if we were using a common cathode arrangement (as opposed to the common anode arrangement as if currently configured).

The circuitry we are interested in is shown below. All other circuitry of the LAB X1 is still in place but we have suppressed it so that we are not distracted by it and can concentrate on the LED that is of interest to us. (PORTD.0).  PORTD.0 refers to bit 0 of PORTD.

In our first exercise we want to control the right most LED of the LED array. This is connected to bit 0 of PORTD in the circuitry shown above. Our program needs to turn this LED on and off to demonstrate that we have control of these two functions.

In general the ports on the microcontrollers (MCUs) are designed so that they can be used as inputs or outputs.  In fact the ports can be programmed so that certain pins on a port are inputs and others are outputs.  All we have to do is tell the program what we want done and the compiler will handle all the details.  The compiler not only allows you to define how you will use the pins of each ports but it can also set them as up inputs or as outputs automatically depending on the instructions that you use in your program. You have a choice of setting PORTD to an output port and then setting pin 1 on this port high or you can simply tell the compiler to make pin 1 of PORTD high and it will take care of the details.

The ports can be treated just like any other memory location in the microcontroller.  By name, you can read them, set them, and use them in calculations and manipulations just like you can with any other named or un-named memory location.  If things are connected to the ports and pins, the program will interact with and respond to whatever is connected to them. (Any named port, register or pin can be addressed directly by name for all purposes when using the PBP Compiler.)

Blink one LED

A simple program to control pin 0 of PORT D is as follows:

CLEAR                            'clear all memory locations
HIGH         PORTD.0        'turns LED connected to D0 on
PAUSE      500                 'delay 0.5 seconds
LOW          PORTD.0       'turns LED connected to D0 off
PAUSE      500                 'delay 0.5 seconds
GOTO LOOP                   'go back to Loop and repeat operation
END                                 'all programs must end with END

Section 05.   Program 01   Controlling and LED
Blinking an LED (rightmost LED on bargraph)