PIC DESIGN (version 1) 2/11/2009 The decision to design and construct a custom microcontroller was dictated by both practical and educational reasons. Although microcontroller development boards are readily available, they are expensive and would have required significant modification to interface with the required peripherals. The additional educational value of starting from scratch made it an easy choice. The design of the microcontroller began by completing the specifications for the devices it would control. This list of peripherals, shown in table 1, was used to select the proper PIC to meet the I/O demands. Table 1: Peripheral Devices Peripheral Requirements Number required LCD 1 serial transmit pin 1 Keypad 8 pins with 4 pull ups 1 Switch 1 pin with pull up 5 Solenoid On/Off 12V and 2oo ma 8 Motor On/Off 12V and 3oo ma 1 The PIC16f877 was selected because it supplied an ample number of I/O pins without the need for complications such as multiplexing. This chip has the added advantage of being identical to those used in E15 laboratories and is therefore well supported by the departments development infrastructure and knowledge base. With the chip selection complete, the supporting architecture was developed in Multisim. For the PIC to operate, it must be provided with proper power and ground connections to the chip as well as the necessary programming connections through the RJ12 connection. This chip model also requires an external oscillator. Figure 1 shows the PIC with only these supporting features in place.
Figure 1: Minimum PIC microcontroller circuit. The LCD display operates on by serial communication and therefore requires only 1 pin and is relatively easy to program. The draw back is that that Serial Transmit pin must be reserved for it. The remainder of the pins was assigned in blocks to operate either the input switches of the solenoid and motor outputs. The switch connections required the addition of weak pull up resistors to ensure a stable signal, shown in figure2. The purpose of these resistors is to maintain a high voltage to the input pins until the switch is closed and they are grounded. This prevents the pins from floating at intermediate values while the switch is open. Although the PIC contains several internal pull ups, there were not a sufficient number.
Figure 2: pull up resistor and switch. The keypad also requires that half of its inputs be connected to pull ups. It operates on a matrix encoded system where pressing a key shorts two of the inputs, the schematic and decoding table is include in figures 3 and 4. Input is sensed by successively setting each column high and scanning the row outputs, this procedure will be discussed in greater detail in the software discussion. Figure 3: matrix code
Figure 4: Keypad schematic The solenoid and motor outputs all require significantly more current than the 25 ma each PIC pin can supply. These channels were equipped with simple MOSFET amplifier circuits to boost the available current, shown in figure 5. The diode, acting as a snubber diode, prevents the high inductance loads from damaging the system when they are shut off.
Figure 5: amplifier schematic. Once the entire microcontroller circuit was designed in schematic form it had to be transferred to the Ultiboard CAD tool to develop a design for the printed circuit board (PCB). Components from the standard Multisim library contain their physical footprint, which is used by Ultiboard to place the necessary Thru holes. Custom components and footprints can also be defined. The user then places each component footprint in the desired location within Ultiboard. The wire traces are generally routed automatically, although the user can intervene. The trace thickness is calculated with any number of simple online applets (http://www.circuitcalculator.com/wordpress/2006/01/31/pcb trace widthcalculator/). This design required the use of separate digital and analog ground networks because the high current sent to ground by the solenoids and motors. The completed Ultiboard CAD drawing is shown in figure 6. The PCB design flies were then sent to a Advanced Circuits for fabrication. Upon receipt of the board the requisite components were soldered into place.