This is the revision D version of the PICBrain11 module. The status of this project is finished.

PICBrain11 Module (Revision D)

Table of Contents

This document is also available as a PDF document.

1. Introduction

The PICBrain11 module can control up to 11 sensor and actuator modules. It uses a PIC16F876A microcontroller from MicroChip®. There is on board RS-232 level conversion circuitry so that the PICBrain11 can be directly connected to a PC serial port. There is an on-board 5 volt regulator for supplying regulated voltage to other sensor and actuator modules.

2. Programming

You are free to program the PICBrain11 in any fashion you so desire. There are many compilers and assemblers available for the PIC microcontroller family. A search of Google® for terms such as "PIC Basic Compiler" and "PIC C Compiler" will yield many possible compilers. The MPLab® software from Microchip® provides an excellent assembler that is free.

All 22 I/O pins of the the PICBRain11 are available on connectors N1 through N11. There is no requirement that you use the pins to only talk to the sensor and actuator modules. For example, RC4 and RC3 can be used to access an I2C bus with the addition of external pull up resistors.

However, we do expect many people to want to connect to sensor/actuator modules. This is done by providing a routine that can bit bang (a technical term) serial protocol in and out on a pair of pins at 2400 baud using an 8N1 (1 start bit, 8 data bits, No parity, 1 stop bit).

The table below shows the mapping of I/O register bits to connector pins:

Pin Location Direction
RA0 N2 Pin 5 Input
RA1 N2 Pin 4 Output
RA2 N4 Pin 5 Input
RA3 N4 Pin 4 Output
RA4 N6 Pin 5 Input
RA5 N6 Pin 4 Output
RB0 N7 Pin 5 Input
RB1 N7 Pin 4 Output
RB2 N5 Pin 5 Input
RB3 N5 Pin 4 Output
RB4 N3 Pin 5 Input
RB5 N3 Pin 4 Output
RB6 N1 Pin 5 Input
RB7 N1 Pin 4 Output
RC0 N9 Pin 5 Input
RC1 N9 Pin 4 Output
RC2 N8 Pin 5 Input
RC3 N10 Pin 5 Input
RC4 N10 Pin 4 Output
RC5 N8 Pin 4 Output
RC6 N11Pin 4 Output
RC7 N11 Pin 5 Input
The table below is the inverse table that shows the the connector pins to register bit mapping:
Connector Pin 4 Pin 5
N1 RB7 RB6
N2 RA1 RA0
N3 RB5 RB4
N4 RA3 RA2
N5 RB3 RB2
N6 RA5 RA4
N7 RB1 RB0
N8 RC5 RC2
N9 RC1 RC0
N10 RC4 RC3
N11 RC6 RC7
Note that most connectors are of the form where pin 5 is connected to PortN@BitN, where BitN is even and pin 4 is connected to PortN@BitN+1. Connects N8, N10, and N11 are the exceptions to this rule. N11 is connected to the TX and RX pins of the PIC16F876A hardware USART. N8 is connected to the SCA and SCL pins PIC16F876A I2C support hardware.

3. Hardware

The hardware consists of a circuit schematic and a printed circuit board.

3.1 Circuit Schematic

The schematic for the PICBrain11 module is shown below:

PICBrain11 Schematic

The parts list kept in a separate file -- picbrain11.ptl.

3.2 Printed Circuit Board

The printed circuit board files are listed below:

picbrain11_back.png
The solder side layer.
picbrain11_front.png
The component side layer.
picbrain11_artwork.png
The artwork layer.
picbrain11.gbl
The RS-274X "Gerber" back (solder side) layer.
picbrain11.gtl
The RS-274X "Gerber" top (component side) layer.
picbrain11.gal
The RS-274X "Gerber" artwork layer.
picbrain11.drl
The "Excellon" NC drill file.
picbrain11.tol
The "Excellon" tool rack file.

3.3 Download Cable

More and more computers are shipping without serial ports. If your computer does not have a serial port, it will be necessary to purchase a USB to serial adaptor. Some converters appear to be better than others. In general, we have been pretty satisfied with adaptors based on FTDI chips. You may have to experiment until you find one that works for your system.

There are two download cables for the PICBrain11 -- the 4-wire cable and the 3-wire cable. The 4-wire cable is identical to the cable used for the MicroBrain8. The 3-wire cable is the same as the 4-wire cable, with the exception that the DTR signal is not hooked up. Both these cables end in a six pin 1×6 male header where pins 3 and 5 have been removed to provide polarization when plugged into N15. The two different cables are described in the two tables below:

4-wire Download Cable
DB9 Direction N15 PIC
Label Pin Label Pin Label Pin
RX 2 <== SOUT 1 RC6/TX 17
TX 3 ==> SIN 2 RC7/RX 18
DTR 4 ==> ATN 4 MCLR 1
GND 5 <=> GND 6 VSS 8,19
RTS 7 Short 7 to 8
DSR 8 Short 8 to 7
3-wire Download Cable
DB9 Direction N15 PIC
Label Pin Label Pin Label Pin
RX 2 <== SOUT 1 RC6/TX 17
TX 3 ==> SIN 2 RC7/RX 18
GND 5 <=> GND 6 VSS 8,19
RTS 7 Short 7 to 8
DSR 8 Short 8 to 7

Why are two different cables needed? The answer starts with the Parallax® Basic Stamp. Parallax decided to use DTR in a very non-standard fashion. They use DTR for reset. The MicroBrain8 must adhere to this Parallax "standard".

The goal for the PICBrain11 is to use the same identical cable as the Parallax cable. Thus, on the PICBrain11, DTR is also used for reset. Unfortunately, most terminal emulators assert DTR as part of their normal behavior. (DTR means Data Terminal Ready, which is properly asserted by a terminal emulator.) This causes the PICBrain11 to jam in the reset state. The more advanced terminal emulators allow you to independently set the DTR pin; alas, Microsoft's Hyperterminal is not one of them. My recommended solution is to disconnect DTR for these non DTR settable terminal emulators. Hence, the two cable flavors -- Parallax (4-wire) and Dumb Terminal Emulator (3-wire).

The next release of our µCL programming language has a full fledged IDE (Integrated Developement Environment) that talks to the PICBrain11. This developement environment uses the Parallax cable (4-wire) connected to the PICBrain11. Whenever the uCL IDE needs to reset the PICBrain11, it asserts DTR to force a reset. Thus, it would be wrong to remove the DTR circuitry on PICBrain11.

3.4 Using the HyperTerminal Terminal Emulator

MicroSoft Windows XP, ships with the HyperTerminal terminal emulator. This terminal emulator can be used to talk to the PICBrain11.

To start HyperTerminal, perform the following:

[Start] => [All Programs] => [Accessories] => [Communications] => [HyperTerminal]

Give the session a name like "RoboBRiX". COM1 is the usual port to talk to.

For Port Settings, select the following:

Port Settings
Baud Rate 19200
Data Bits 8
Parity None
Stop Bits 1
Flow Control None

Now go to the tool bar and select [File] => [Properties]. Select the [Settings] tab and click on the [ASCII Setup...] button. Set line delay to 50 milliseconds.

HyperTerminal Configuration is now complete.

Plug the 3-wire cable into PICBrain11 and the other end into a serial port of the PC running Windows XP. Power up the PICBrain11. If everything is working properly, you should see "PICBrain11-C" followed by "4 3 2 1" in the HyperTerminal window. Press the [Enter] key before the boot loader outputs the final "1" to get it to enter the command prompt.

The boot loader commands are described in the next section.

In order to download a program into the PICBrain11 using HyperTerminal you need to do the following. First, generate an Intel .hex file that contains the program to be downloaded. Next, get the PICBrain11 to the point where a ">" command prompt is showing. Finally use the [Transfer] => [Send Text File ...] command to force the .hex file to be downloaded into the program memory of the PICBrain11. See the ":" command for the boot loader for a little more detail.

4. Software

There is a boot loader preprogrammed into the PICBrain11.

You talk to the boot loader via the serial cable and some sort of terminal emulator running on your preferred host platform (e.g. HyperTerminal for various versions of Microsoft® Windows operating system, minicom for Linux, etc.) Configure your terminal emulator for 19200 baud, 8N1 (1 start bit, 8 data bits, No parity, 1 stop bit) and no hardware or software flow control.

When the PICBrain11 Boot loader is powered up it it prints an announcement message of "PICBrain11-C'. Then it counts down for 4 seconds "4 3 2 1". By typing an [Enter] key during the count down, the command prompt is entered. If no [Enter] is depressed, control is transferred to address 0008 after 4 seconds have elapsed.

The command program has the commands listed below. All numbers are in hexadecimal, upper and lower case is unimportant, and commands must be initiated by typing an [Enter] key.

V
Print version number of software (i.e. "1.0")
K n
Set the socket to n, where n must be between 1 and A inclusive.
I
Talk to the module on the socket specified by the K command (see above.) Print out the module identifier information. The first 24 bytes are in hexadecimal followed by two strings -- the module name and module vendor.
C aa
Perform a clock adjust on the selected socket (see K command above.) aa should be specified as 00. This command will ensure that the clock speed of the selected module is tweaked to be as close to optimal as possible.
P pp
Show the page of program memory at pp00 to ppFF. For the PIC16F876, pp can range from 00 to 1F.
E rrrr cc
Show the cc bytes of data from file registers starting at rrrr. For the PIC16F876A, rrrr can range from 0000 to 01FF. Not all register locations are active.
S rrrr vv
Set register rrrr to vv. As with the E command (see above), rrrr can range from 0000 to 01FF.
G aaaa
Transfer control to address aaaa.
X
Transfer control to address 0008.
R cc
Send byte cc to the currently selected module (see K command above.) Print up to two bytes of response back. FC is returned for a timeout.
: ...
Program one line of Intel® Hex file format into program memory. All memory from 0004 through 1800 can be programmed. Any attempts to program outside the range are silently ignored. At the end of the download, the number of errors is printed. It should be Err=00. If not, the address where the problem occured is listed. Be sure that your terminal emulator is configured to delay about 50 milliseconds after each line is sent.

The boot loader is written in a programming language called µCL. It currently resides in code bank 3 of the PICBrain11 starting at address 1800. The following files are available:

picbrain11.ucl
The µCL source code for the PICBrain11 boot loader.
picbrain11.asm
The PICBrain11 boot loader assembly code listing
picbrain11.lst
The PICBrain11 boot loader listing file.
picbrain11.hex
The µCL PICBrain11 boot loader Intel® Hex file.

In addition, there is a program that provides some simple robototic behaviors:

robobrix_test.ucl
The µCL source code for the Robobrix_Test test program.
robobrix_test.asm
The Robobrix_Test test program assembly code listing.
robobrix_test.lst
The Robobrix_Test test program listing file.
robobrix_test.hex
The µCL Robobrix_Test test program Intel® Hex file.

The documentation for this program is follows:

There are 11 sockets labeled N1, N2, ..., N9, NA, NB.

There are three simple DualMotor1Amp behaviors:

DualMotor1Amp plugged into N2:
Turns on left motor in forward direction.
DualMotor1Amp plugged into N3:
Turns on right motor in forward direction.
DualMotor1Amp plugged into N4:
Turns on both left and right motors in forward direction.

The next set of behaviors requires the DualMotor1Amp to be plugged into N1:
Proximity2 plugged into N2:
Implements a follow behavior. It does nothing until it sees some object in front of it. Then it turns toward the object and trys to keep a fixed distance from the object.
IRProximity2 plugged into N3:
This is "attack" behavior. I find it to be pretty lame. It waits until an object shows up and runs after it until it runs into it. t is not smart enough to stop. Frankly, this is the lamest behavior in the program right now.
IRProximity2 plugged intO N4:
This is called push-pull behavior. The robot tries to to stay a fixed distance from an object. If object comes closer to the robot, it will back away from the object. Alas, its forward motion is a little too timid right now, so it is mostly a backup robot.
IRPRoximity2 plugged into N5:
This is an object avoider. The jittery nature of the sensor means that it tends to go into circles pretty easily.
IRProximity2 plugged into N6:
This is a right wall follower. The right IR LED needs to be canted about 45 degrees to the right. The trim pot should be cranked way up. It turns left when sees something in front with the left sensor, it turns left; otherwise, it tries to stay in a zone with the wall on the right using the right sensor.
With Servo4 plugged into NA (i.e. N10):
The gripper is plugged into servo0 and the wrist is plugged into servo1. The two trim pots a jumpered on the left. The first trim pot specifies the wrist position when gripping an object. The second trim pot specifies the wrist position when the gripper is searching for an object. While the robot is following a wall, it opens and closes the gripper. If the gripper closes on something, it stays closed until a "corner" is found; then it releases it.

5. Issues

The following fabrication issues came up:


Copyright (c) 2001-2005 by Wayne C. Gramlich. All rights reserved.