circuitcellar.com
Magazine Support   Digital Library   Products & Services   Suppliers Directory 
 
 





 

December 2005, Issue 185

Assume Control with the MC104P


by Fred Eady


Start P Is For PC/104 Easy PIC Video MC104P Functions Be A Hero Sources and PDF

P IS FOR PC/104

After arriving at the Calmotion exhibit, the first thing that got my attention was a stack of boards that resembled a PC/104 configuration. I looked closely at the CPU. To my surprise, a PIC18F8722 was sitting where an Intel 80xxx-something CPU should have been. Very clever, I thought.

My eyes then followed a video cable from the middle of the PIC18F8722-based PC/104 stack to a standard flat screen monitor that was displaying a seemingly organized series of multicolored numeric values. Before I saw the video cable, I assumed that a PC was under the table monitoring the PIC18F8722’s movements and translating them to the display. Wrong! I then realized that the bottom board of the PIC-controlled PC/104 stack was driving a hefty motor drive that was attached to a large motor. The motor shaft was rotating and the numbers on the flat panel were representative of what the motor was doing and what the PIC18F8722 was doing to the motor drive. Way freaking cool! At about this time, I figured the PIC-based PC/104 device needed some additional scrutiny.

Check out the MC104P Photo 1. The idea behind the MC104P is simple: bring the multitude of inexpensive PIC development tools to bear on the PC/104 form factor in an effort to meld the MCU and many of the off-the-shelf PC/104 I/O peripherals into a highly functional, inexpensive industry standard PC/104 package based solely on a PIC microcontroller.

(Click here to enlarge)

Photo 1—This is everything you’d want in a PIC-based single board computing platform. The PIC18F8722 features are fully utilized. There’s 128 KB of user SRAM and a real PC/104 interface to boot. The 40-pin right-angle male header provides access to the Calmotion MC104P digital I/O, power, ground, and analog inputs.

Like most PIC microcontrollers, the MC104P is aimed at control applications. Using a PIC instead of a more complex microprocessor or a typical 80xxx-something SBC for certain control applications saves money and time. You don’t need complex operating systems or expensive development tools to successfully deploy a typical PIC microcontroller control application.

To make life easy for the control application programmer and hardware engineer, the MC104P adheres to the 8-bit PC/104 specification and provides a standard Microchip MPLAB ICD2 programming and debugging port. Compatible PC/104 peripherals can be attached physically and logically to the MC104P by way of its stackable 64-pin header. PC/104 peripherals that don’t require DMA transfer operations and don’t use interrupts 2, 3, and 9 are deemed MC104P-compatible. They can be attached to the MC104P via the PC/104 header.

The MC104P takes advantage of the PIC18F8722’s external memory feature. It includes a block of external 128-KB SRAM to augment the PIC18F8722’s 4 KB of internal SRAM. This means the PIC18F8722 must be configured for an extended microcontroller mode and 20-bit addressing in 8-bit Bus mode.

Figure 1 is a representation of the MC104P-to-PC/104 bus memory mapping. The first 128 KB is taken up by the PIC18F8722’s program flash memory. The PC/104 I/O address space is 64 KB deep; it’s memory mapped into the 64 KB of space that immediately follows the PIC18F8722’s flash memory area.

(Click here to enlarge)

Figure 1—This is a no-nonsense memory map that really tells it like it is. The memory spaces that aren’t covered by an established means of access are covered by memory and I/O access functions that come with the MC104P package.

Note that the PC/104 I/O address is converted to range from 0x0000 to 0xFFFF. Reads and writes to the MC104P 0x20000–0x2FFFF memory space will be decoded as PC/104 bus I/O reads and writes that have been offset into the PC/104 0x0000–0xFFFF memory area. As you can see in Figure 1, the PC/104 memory address space, which has nothing to do with PIC18F8722 memory areas, is directly mapped into the memory space beginning at 0x30000. The MC104P programmer can simply read and write to the PC/104 memory area at 0x30000–0xFFFFF. The MC104P automatically generates the necessary PC/104 signals on the PC/104 bus. The 128 KB of external user SRAM is mapped above the upper limit of the defined PC/104 memory and begins at offset 0x100000. The 128-KB block of external SRAM belongs solely to the PIC18F8722.

The MC104P’s COMM1 serial port can be jumpered for either full-duplex RS-232 or half-duplex RS-485 operation. COMM2, which isn’t configurable, is hard-wired as a full-duplex RS-232 port. Because the MC104P is wired as a DTE device, a null modem arrangement must be used if you want your MC104P to communicate directly to the COM ports on your PC.

The MC104P uses the services of the PIC18F877’s native A/D subsystem and provides access to four 10-bit A/D inputs. Each of the four A/D inputs (RA0/AN0, RA1/AN1, RA2/AN2, and RA5/AN4) is buffered with a MCP604 rail-to-rail op-amp. The A/D voltage reference is provided by a 4.096-V reference power supply on the MC104P PCB; it feeds the PIC18F8722’s A/D reference pin RA3. A graphical view of the MC104P’s A/D buffer circuitry is shown in Figure 2.

(Click here to enlarge)

Figure 2—This circuitry is common to all of the MC104P’s A/D inputs. It provides a low-impedance input to the A/D inputs. The PIC18F8722’s ADC for voltages from 0 to 5 V returns a digital value of 0 to 1023, respectively.

On the digital I/O side, eight open-collector digital outputs controlled by the PIC18F8722’s port F pins are available you. The output port pins, which are buffered with a current-sinking transistor, can handle up to 40 V. A typical MC104P digital output circuit is shown in Figure 3.

(Click here to enlarge)

Figure 3—As Forrest Gump would say, “That’s all I’m gonna say about that.”

There is also a complement of eight digital input lines that can be jumpered for pull-up or pull-down operation. If you’re familiar with PIC microcontrollers, you know that PORTB multiplexes digital I/O and interrupt inputs on the four least significant PORTB pins. The MC104P enables you to select either interrupt inputs or standard digital inputs on the lower four PORTB pins with jumpers. When a PORTB pin is jumpered for high-speed input, the pin is basically a standard PIC INTX external interrupt input pin.

As you can see in Figure 4, the PORTB inputs can be shared with the RC0–RC3 input pins. The upper 4 bits of digital input are handled by the upper nibble of the PIC’s PORTH (RH4–RH7). The four PORTB inputs can be shared in yet another way and can be associated with PC/104 interrupts IRQ4 (RB0), IRQ5 (RB1), IRQ6 (RB2), and IRQ7 (RB3).

(Click here to enlarge)

Figure 4—I lumped the four input circuits into a single view. JP1 enables the sharing of the PIC’s B and C I/O ports or the assignment of the PORTB pins to IRQs. JP6 is simply a pull-up or pull-down selector.

If you aren’t hanging any PC/104 current hogs on the MC104P PC/104 bus, you can power the MC104P directly from the MPLAB ICD2 because the MC104P draws only 80 mA. If you’re “all jacked up,” as Gretchen Wilson would say, power for your MC104P and its associated PC/104 peripherals can be had from an external power supply connected to a set of screw terminals on the MC104P.

Now that you have a taste for what the MC104P is all about, let’s move on and talk about coding it using the firmware and software utilities that are provided with its hardware package.