                 LAB-X4 Documentation
                           
      Copyright (c) 2002 microEngineering Labs, Inc.


Introduction

The LAB-X4 is a platform for experimenting with PICmicro microcontroller
(MCU) applications.  It contains the circuitry required by the PICmicro MCU
to operate: 5-volt power supply, oscillator, reset circuit, as well as
additional application circuits including a switch, potentiometer, LED,
LCD module and an RS232 interface.  A prototyping area is also included in
case we missed your favorite circuit.

Many different projects may be created using the LAB-X4.  Some examples
include a LCD clock, servo controller, LCD backpack and many more.  The
LAB-X4 can run programs written in assembler, C and PicBasic or PicBasic Pro.
It includes an in-circuit programming connector so the resident PICmicro MCU
may be reprogrammed on the fly (requires flash device) using programmers
that support this feature like the EPIC Programmer.

All of the PICmicro MCU I/O pins are brought out to a header.  This allows
connection to off-board circuits.

The LAB-X4 is available in either assembled or bare-board form.  A parts list
and schematic, along with PicBasic and PicBasic Pro example programs, are
included.  It has the following features:

14-pin dip socket for 8- or 14-pin PICmicro MCU
5-volt regulator
Reset/push button
Potentiometer
LED plus power LED
2 line by 20 character LCD module
LCD serial controller
RS232 interface
EPIC in-circuit programming connector
Layout for oscillator
Layout for I2C serial EEPROM
Prototyping area for additional circuits

A parts list and assembly instructions, along with a PICmicro MCU pin
connection list, are found towards the end of this document.

Each of the circuits on the LAB-X4 are described below.  Refer to the
schematic and sample programs on the disk for additional information.  It is
also a good idea to have the data sheets available for each of the devices
used on the LAB-X4.  These data sheets can usually be found on the
manufacturers web site.

It is recommended that you start with a simple program like BLINKX4.BAS to
get familiar with the operation and programming of the LAB-X4.


Power Supply

The power supply section provides regulated +5 volts DC for use by the LAB-X4
components.  An AC adapter that provides between +7.5 and +16 volts DC is
recommended to power the LAB-X4 through J2.  The center pin on the connector
is positive.

The regulator will get quite warm.  It may be desirable to attach a heat sink
to it at higher input voltages.

There is no power switch.  The AC adapter should be unplugged when the LAB-X4
is not in use.


Processor

The LAB-X4 includes a 14-pin dip socket to support both 8-pin and 14-pin
PICmicro MCUs.  A PIC12F675 or PIC16F676 is recommended where available.
These flash devices may be reprogrammed in-circuit using the EPIC Programmer.
Alternatively, other 8- or 14-pin PICmicro MCUs may be used.  These devices
may need to be removed from the socket for erasing but may be programmed on
the LAB-X4 board using the in-circuit connector with an EPIC Programmer.

Depending on the processor used, the first port on it may be referred to by
several names: GPIO, PORTA or PORTB.  This document and schematic will use
the name PORTA.  It is the same as GPIO and PORTB, however, the appropriate
name for the specific device must be used in the program.

The PICmicro MCU must be placed in socket U1 with pin 1 toward the left,
bottom of the LAB-X4 board.

The LAB-X4 must be powered-up in order to program a PICmicro MCU in the
dip socket U1.

A reset button, S1, is provided to restart a running program or may be used
as a general purpose switch if the master clear pin is disabled in the
programmer software.

Header J4 may be added to the LAB-X4 below the 14-pin dip socket.  This
allows connections to external circuits.


Oscillator

The LAB-X4 includes traces for an oscillator (not included) that can provide
the clock source to the PICmicro MCU.  Most 8- and 14-pin PICmicro MCUs have
an on-chip oscillator that is usually used.  An external crystal and
capacitors may be added if more accuracy than the internal oscillator
provides is required.

The external crystal uses the same pins used by the serial EEPROM and
potentiometer.  If an external crystal is to be used, jumper JP2 must be
removed to disconnect the potentiometer.  Any serial EEPROM in U4 must also
be removed, along with resistors R6 and R7, if present.


ICSP

The PICmicro MCU in the LAB-X4 14-pin socket may be programmed in-circuit
using an EPIC Programmer.  A short 10-pin cable should be attached between
connector J3 on the EPIC Programmer and J3 on the LAB-X4 (pin 1 is located on
the lower right of J3 on the LAB-X4).  The EPIC software should be started
and the proper device selected. The PICmicro MCU should then be placed into
the 14-pin socket on the LAB-X4 with pin 1 toward the left, bottom of the
LAB-X4 board.  The LAB-X4 must be powered up during programming.  The
PICmicro MCU may now be programmed in-circuit on the LAB-X4.

If the PICmicro MCU is a flash device, it may be reprogrammed without being
removed.  If it is a windowed EPROM (JW) device, it must be removed from the
LAB-X4 to be UV erased before reprogramming.  An OTP device cannot be erased.

Since the LAB-X4 TX pin is shared with the in-circuit programming clock
function, the LCD will display all kind of characters during programming.
If a serial device is connected to the RS232 port, it will also be sent
unintended data.

The push button should never be pressed during device programming.


Potentiometer

The LAB-X4 includes a potentiometer connected to PORTA.4.  The potentiometer
can be read using the PicBasic Pro Compiler's ADCIN command.

The potentiometer pin is shared with the serial EEPROM and the crystal.  If a
serial EEPROM or crystal is used, jumper JP2 must be removed to disconnect
the potentiometer and it may not be used.

See ADCINX4.BAS for a programming example.


Pushbutton Switch

Push button switch S1 is connected to the master clear (reset) line on the
PICmicro MCU.  If the external master clear configuration option is enabled
when the device is programmed, pressing this button will cause the PICmicro
MCU to reset.  The reset function of this pin can be disabled and the pin can
be used as an input pin.  See the Microchip data sheet special functions
section for information on this option.

A closed switch will show a 0 and an open switch will show a 1.

See BUTX4.BAS for a programming example.


LEDs

The LAB-X4 includes a power LED that is on any time the power is on and one
programmable LED: LED1.  Each LED includes a 470 ohm series resistor.

To turn on LED1, set pin PORTA.0 to output low.

See BLINKX4.BAS for a programming example.


LCD Module

A 20 character by 2 line LCD module is included on the LAB-X4.  It may be
used to display all manner of text information.  The module includes a
Hitachi 44780 (or equivalent) controller.

The LAB-X4 also contains a serial LCD controller, U3.  This controller is a
preprogrammed PICmicro MCU that can take serial information from the PICmicro
MCU in U1 on pin PORTA.1 and display it on the LCD.  It operates at 2400
baud, true data level.  PORTA.1 is also connected to the TX pin on the MAX232
chip.  Any data transmitted to the LCD will also appear at the RS232 output.

The LCD includes a small command set for controlling the cursor on the
display and erasing the display.  Commands are sent by preceding the command
byte with a $fe (decimal 254).  Some of the available commands are:

	Command		Operation
	$FE, 1		Clear display
	$FE, 2		Return home
	$FE, $0C	Cursor off
	$FE, $0E	Underline cursor on
	$FE, $0F	Blinking cursor on
	$FE, $10	Move cursor left one position
	$FE, $14	Move cursor right one position
	$FE, $80	Move cursor to beginning of first line
	$FE, $C0	Move cursor to beginning of second line

An example to send "Hello" to the display using the PicBasic Pro Serout
instruction is:

	Serout PORTA.1, 0, [$fe, 1, "Hello"]

The LCD can also be controlled directly from a 14-pin PICmicro MCU in U1.
Jumpers JP7-12 would need to be added and the serial LCD controller in U3
would need to be removed from its socket.  Once the jumpers are added, the
LCD data bus is connected to PORTC.0 - 3 of the PICmicro MCU in U1.  The
register select line is connected to PORTC.4.  Enable is connected to
PORTC.5.  The read/write line is connected to ground to select write at all
times.

The LCD contrast is set with a single resistor to ground, R1.  Another
resistor, R8, may be used to power an LCD backlight through connector J6.
The supplied LCD module does not include a backlight.

Since the LAB-X4 TX pin is shared with the in-circuit programming clock
function, the LCD will display all kind of characters during programming.

See LCDX4.BAS for a programming example.


RS232

The LAB-X4 includes an RS232 interface to connector J5.  This allows
asynchronous serial communication with other devices, including PCs.  A
MAX232 IC in socket U2, along with several capacitors, generates the required
RS232 voltages.

The serial TX line (pin 2 on J5) is connected to PORTA.1 through the MAX232. 
The serial RX line (pin 3 on J5) is connected to PORTA.2 through the MAX232. 
RTS is connected to CTS (pin 7 to pin 8) on J5.  DTR is connected to DCD and
DSR (pin 1 to 4 to 6) on J5.  These jumped connections make most comm
programs think the LAB-X4 is online and ready to communicate.

The serial TX line, PORTA.1 is also connected to the serial LCD controller.
Any data transmitted to the RS232 output will also appear on the LCD.  If
the use of the LCD is undesirable, remove the LCD controller, U3, from its
socket to disable the LCD.

See HELLOX4.BAS for a programming example.


I2C Serial EEPROM

The LAB-X4 includes traces for an I2C interfaced serial EEPROM, U4.  The
serial EEPROM (not included) must be inserted into the socket with pin 1
towards the bottom of the board.

The serial clock line is connected to PICmicro MCU pin PORTA.4.  The serial
data line is connected to PORTA.5.  Both the serial clock and data lines are
connected to 4.7k pull-up resistors R6 and R7.  These resistors are not
included on the LAB-X4 and must be added if a serial EEPROM is used.

The serial EEPROM clock and data lines are shared with the potentiometer and
crystal.  If a serial EEPROM is used, jumper JP2 must be removed to
disconnect the pot and a crystal must not be used.

Some of the possible serial EEPROMs are:

Device		Architechture		Digi-Key Part Number
24LC01B		1K (128 x 8)		24LC01B/P-ND
24LC02B		2K (256 x 8)		24LC02B/P/ND
24LC04B		4K (2 x 256 x 8)	24LC04B/P-ND
24LC08B		8K (4 x 256 x 8)	24LC08B/P-ND
24LC16B		16K (8 x 256 x 8)	24LC16B/P-ND
24LC32A		32K (4K x 8)		24LC32B/P-ND
24LC256		256K (32K x 8)		24LC256-I/P-ND

See I2CX4.BAS for a programming example.



PICmicro MCU Port Pin Connections

The table below lists the pre-wired connections to each of the PICmicro MCU
port pins.  Off-board circuits may also be connected to the PICmicro MCU
using header J4.

PORTA (GPIO)
A0   LED1
A1   TX
A2   RX
A3   S1
A4   POT1/SCL/OSC2
A5   SDA/OSC1

PORTC - LCD if jumpers connected to JP7-12
C0   LCD DB4
C1   LCD DB5
C2   LCD DB6
C3   LCD DB7
C4   LCD RS
C5   LCD E



LAB-X4 Standard Parts List**

Designator	Description				Jameco Part Number*
R1		470 ohm 1/4W resistor (yellow-violet-brown)	31165
R2		270 ohm 1/4W resistor (red-violet-brown)	30605
R3,4		1k 1/4W resistor (brown-black-red)		29663
R5		100 ohm 1/4W resistor (brown-black-brown)	29946
R6,7		470 ohm 1/4W resistor (not included)		31165

POT1		5k thumbwheel potentiometer			94705

C1		10uf 50-volt radial electrolytic capacitor	29891
C2,7-11		1uf 35-volt radial electrolytic capacitor	29831
C3,6		.1uf monolythic capacitor (104)			25523
C4,5		22pf ceramic disk capacitor (not included)	15405

POWER, LED1	T-1 3/4 LED					152864

Y1		4.000MHz crystal (not included)			14592

LCD		20x2 LCD module w/ Hitachi controller
		Double-sided foam tape

REG1		7805T 5-volt regulator				51262

U1,3		14-pin dip socket
U2		16-pin dip socket
		MAX232CPE IC					24811
U4		8-pin dip socket

S1		6.5mm x 4.5mm push button			153251

J1		14-pin dual-row header				118455
J2		2.1mm DC power connector			10178
J3		10-pin dual-row header				67820
J4		26-pin dual-row header (not included)		53495
J5		DB9S female right angle connector		104951
J6		2-pin header (not included)			108337

JP1,3-12	2-pin header (not included)			108337
JP2		2-pin header					108337
JP13		3-pin header (not included)			109575

4 rubber feet

* Jameco Electronics
(800) 831-4242
www.jameco.com

** Items marked (not included) are not included with the standard version and
may be user supplied.



Assembly Instructions

All components must be placed on the top side of the board (the side with the
silk-screened labeling) and soldered from the under side of the board using a
good quality resin-core solder.  While the LAB-X4 is not difficult to
assemble, some experience with assembling previous projects is desirable.

1. Solder in the resistors.

2. Solder in the IC sockets, observing polarity.

3. Solder in the push button switch.

4. Solder in the LEDs, observing polarity.

5. Solder in the capacitors, observing polarity where necessary.

6. Solder in the headers, including J1 for the LCD module.

7. Solder in the DC power connector, DB9S connector and 4.000MHz crystal (if
used).

8. Solder in the 5-volt regulator, observing polarity (flat heat-sink side
toward board).

9. Solder in the thumbwheel potentiometer.

Before proceeding, it is a good idea to check the power supply.  Attach a
suitable DC power source to J2.  Measure for 5 volts between Vdd, pin 1, and
Vss, pin 14, on U1.  If 5 volts is not present, recheck all your work.

10. Place the double-sided foam tape onto the back of the LCD module.  Slide
the LCD module, face up, onto the LCD header, J1, and solder into place from
the top side of the LCD.

11. Install the MAX232 IC, observing polarity.

12. Stick the rubber feet to each corner of the board.



Test Program

A test program, TESTX4.BAS, has been included to provide a quick operational
test of the LAB-X4.  It must be programmed into an appropriate device and the
LAB-X4 powered up.

The top line of the LCD will display the potentiometer value.  When push
button S1 is pressed, LED1 will light up.


microEngineering Labs, Inc.
Box 60039
Colorado Springs CO 80960
(719) 520-5323
(719) 520-1867 fax
http://www.melabs.com
email:support@melabs.com
