This is the revision D version of the PICBrain11 module. The status of this project is finished.
This document is also available as a PDF document.
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.
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:
The table below is the inverse table that shows the the connector pins to register bit mapping:
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
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.
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
The hardware consists of a circuit schematic and a printed circuit board.
The schematic for the PICBrain11 module is shown below:
The parts list kept in a separate file -- picbrain11.ptl.
The printed circuit board files are listed below:
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.
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.
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.
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:
In addition, there is a program that provides some simple robototic behaviors:
The documentation for this program is follows:
There are 11 sockets labeled N1, N2, ..., N9, NA, NB.
There are three simple DualMotor1Amp behaviors:
The following fabrication issues came up: