Wichit Sirichote, kswichit@kmitl.ac.th
The new PIC Project Board is specially designed to be the controller board for student projects.
The board features
MCU: PIC 40-pin DIP package e.g. PIC16F887, PIC18F458, PIC18F450,
Display: KS0108 compatible 128x64 graphic LCD,
Communication port: RS232, RS485,
Onboard keypad: 4-key switch,
Onboard screw terminal: 4-channel ADC input, +5V and RS485,
Expansion headers: Two 26-pin headers for student hardware board,
Onboard power supply: +5V and +3.3V regulator,
Debug LED: one bit dot LED,
MCU program loading: ICSP header for program downloading.
Figure 1 Large font displayed on graphic LCD.
The board platform is suitable for developing the microcontroller based instruments. Students may design the front-end circuit that can be easily plugged to the MCU board.
Figure 2 The MCU board without LCD. Hardware
The MCU can be any Microchip having 40-pin DIP package. Most of 40-pin DIP package MCUs have the same functions and pin-to-pin signal compatible. Only some alternate functions on port C may be different. This design recommends the PIC16F887 or PIC18F458. The new Microchip MCU with nano watt technology will include the oscillator in the MCU. However as shown in the schematic, at the oscillator pins, main external osc or low power oscillator, the PCB provides XTAL connecting pads. This makes the uses of external XTAL can be done easily. For the new MCU having internal oscillator, we can use such pin for port functions.JF1 is 20-pin sip socket for connecting the 128x64 graphic LCD. R7 can be 100 Ohms or smaller, you may adjust the value for suitable brightness. The graphic LCD is selected for application that needs graphical display.
Communications port using UART has two drivers, the RS232 by U1, MAX232 and the RS485 by U4, 75176. TXD is tied to both drivers. However the RXD will need selector by J2.The keypad has 4-switch, SW1, SW2, SW3, SW4. JP1 and JP2 are 26-pin header. Both headers provide port signals, power supply for expansion board.
The board also provides the screw terminal for analog input and +5V supply.
The +5V voltage regulator is U3, LM2940. And the +3.3V is U2, LM1117.As shown the schematic, the circuit in the dash box is optional. User may populate it depending on theirs applications. For example suppose we will develop the controller that uses PIC16F887 for sending the analog reading using RS485. We then need only MCU: PIC16F887, RS485 driver: 75176, +5V supply: LM2940, and screw terminal, J3.
Figure 3 Schematic.
Figure 4 Two 26-pin headers for plugging the front-end or power circuits. The header shown in Figure 4 is designed for plugging the student hardware in the back. The signals are I/O PORT and power supply.
Figure 5 Multiple lines text display using 5x8 font.
Figure 6 Component placement.
Program loading with ICSP
J1 is the header for ICSP loading. The pin signal is compatible with MRT PICKit2.
Figure 7 Program loading with MRT PICkit2.
Student expansion board
The student expansion board size is approx. 4100x3850mils. The position of header JP1 and JP2 are shown in Figure 8. Carefully check the pin designation for both headers. Shown the header's footprint are placed in bottom layer. Student may chooses the component placement on the top layer, or bottom but the header (male type) must be soldered on the top layer. Four mounting holds are provided for fixing the board into the box. The PIC project board can then be plugged to the expansion. The layout of the expansion board is saved as the template file using Orcad 9.1. You can download it and use it as your expansion board easily.
Figure 8 The layout shows position of the expansion headers, JP1 and JP2.
Sample Code 1: Interfacing the 128x64 graphic LCD
The sample c program shown in Figure 9 demonstrates how to interface the 128x64 graphic LCD to the PIC18F458. The built-in LCD functions are included with the Mikro-C for pic compiler.
/*
Test code with GLCD, the MCU is PIC18F458 8MHz
*/// ------------------------------------------------------
// GLCD Picture name: pic1.bmp
// GLCD Model: KS0108 128x64
// ------------------------------------------------------unsigned char const pic1_bmp[1024] = {
0, 0, 0, 0, 0,240,240,240,112,112,112,112,240,240,224,192,
0, 0,240,240,240, 0, 0, 0,192,224,224,240,112,112,112,112,
224,224,192,128, 0, 0, 0, 0, 0, 0, 0, 0, 0,240,240,240,
112,112,112,112,240,240,224,192, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48,
48, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128,192,224, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0,255,255,255, 28, 28, 28, 28, 30, 31, 15, 7,
0, 0,255,255,255, 0, 0,127,255,255,193,128, 0, 0, 0, 0,
128,193,193,128, 0, 0, 0, 0, 0, 0, 0, 0, 0,255,255,255,
28, 28, 28, 28, 30, 31, 15, 7, 0, 0,255,255,255, 6, 3, 3,
3, 0,248,254,254, 7, 3, 3, 3, 7,254,254,248, 0, 0,255,
255,255, 0, 0,248,254,254, 55, 51, 51, 55,190,190,184, 0, 0,
248,254,254, 7, 3, 3, 7,142,142,136, 0, 3,255,255,255, 3,
3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0,224,224,224,
224,224,231,231,231,224,192,128, 1, 3, 3, 7, 7, 7, 7, 7,
3, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0,
0, 0, 0, 3,227,231,230, 6, 6, 7, 3, 3, 0, 96, 96,127,
127, 63, 0, 0, 0, 3, 3, 7, 6, 6, 7, 3, 3, 0, 0, 0,
0, 3, 3, 7, 6, 6, 7, 3, 3, 0, 0, 0, 3, 7, 7, 6,
6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255,255,255,
56, 56, 56, 56, 56, 63,255,231,192, 0, 0,240,252,252, 14, 6,
6, 6, 14,252,252,240, 0, 0,136,204,230,102,102, 54, 54,254,
252,248, 0, 0,254,254,254, 12, 6, 6, 6, 0,240,252,252, 14,
6, 6, 6, 12,255,255,255, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, 15, 15,
14, 14, 14, 14, 14, 14, 15, 7, 3, 0, 0, 1, 7, 7, 14, 12,
12, 12, 14, 7, 7, 1, 0, 0, 3, 7, 15, 12, 12, 12, 6, 7,
15, 15, 8, 0, 15, 15, 15, 0, 0, 0, 0, 0, 1, 7, 7, 14,
12, 12, 12, 6, 15, 15, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,224,224,224,224,224,224,224,224,224,
192,128, 0, 0,224,224,224, 0, 0, 0,128,192,192,224,224,224,
224,224,192,192, 0, 0, 0, 0, 0,128,128,192,224,224, 0, 0,
0, 0,128,192,224, 96, 96, 96,224,192,128, 0, 0,224,224,224,
224,224,224,224,224,224,224, 0, 0, 0, 0, 0,192,224,224,224,
0, 0, 0, 0, 0,128,224,224, 96, 96, 96, 96, 0, 0, 0,128,
192,224, 96, 96, 96,224,192,128, 0, 0, 0,192,192,224, 96,224,
192,192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,255,255,255, 56, 56, 56, 56, 61, 63,
31, 15, 0, 0,255,255,255, 0, 0,126,255,255,129, 0, 0, 0,
0,129,195,195,129, 0, 0, 0, 7, 3, 1,255,255,255, 0, 0,
0, 0,195,231,255, 60, 24, 60,255,231,195, 0, 0,255,255,255,
28, 28, 28, 28, 28, 28, 0, 0,224,240,220,207,195,255,255,255,
192,192, 0, 0,140,143,143, 7, 6, 14,254,252,248, 0, 0,195,
231,255, 60, 24, 60,255,231,195, 0, 0,255,255,255, 0, 0, 0,
255,255,255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 7, 7, 7, 0, 0, 0, 1, 3, 3, 7, 7, 7,
7, 7, 3, 3, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 0, 0,
0, 0, 1, 3, 7, 6, 6, 6, 7, 3, 1, 0, 0, 7, 7, 7,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7,
0, 0, 0, 0, 1, 3, 7, 7, 6, 7, 7, 3, 0, 0, 0, 1,
3, 7, 6, 6, 6, 7, 3, 1, 0, 0, 0, 3, 3, 7, 6, 7,
3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};// ------------------------------------------------------
// GLCD Picture name: pic2.bmp
// GLCD Model: KS0108 128x64
// ------------------------------------------------------unsigned char const pic2_bmp[1024] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,192,224,
224,240,112,112,112,240,240,224,192,128, 0, 0,128,192,224,240,
240,112,112,112,240,240,224,192,128, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,128,224,224,240,112,112,112,240,224,224,128, 0,
0, 0, 0,128,224,224,240,112,112,112,240,224,224,128, 0, 0,
0, 0, 0, 0, 0,128,192,224,240,240,240, 0, 0, 0, 0, 0,
0, 0,128,192,224,224,240,240,240,240,240,240,240,224,224,192,
128, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 3,
3, 0,128,192,224,240,255,127, 63, 15, 0, 0, 7,143,223,255,
248,112,112,112,248,255,223,143, 7, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0,254,255,255,255, 1, 0, 0, 0, 1,255,255,255,254,
0, 0,254,255,255,255, 1, 0, 0, 0, 1,255,255,255,254, 0,
0, 0, 30, 15, 15, 7, 3,255,255,255,255, 0, 0, 0, 0, 0,
252,255,255,255, 7, 1, 1, 0, 0, 0, 0, 0, 1, 3, 7, 7,
3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,192,240,252,
254,255,239,231,227,225,224,224,224,224, 0, 0, 31, 63,127,127,
240,224,224,224,240,127,127, 63, 31, 0, 0, 0,240,240,240,240,
0, 0, 0, 7, 31,127,127,248,224,224,224,248,127,127, 31, 7,
0, 0, 7, 31,127,127,248,224,224,224,248,127,127, 31, 7, 0,
0, 0, 0, 0, 0, 0, 0,255,255,255,255, 0, 0, 0, 0, 0,
3, 15, 31, 63,126,120,248,240,240,240,240,248,248,126,127, 63,
30, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,240, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,255, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0,128,128,128,128,128,128,128,128,128,192,112, 16, 16,
16, 16, 16, 16, 16, 16, 16, 48, 32, 32, 32, 32, 32, 32,224,128,
128,128,128,128,128,128,128, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0,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 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0
};
void delay2S(){
delay_ms(2000);
}char buffer[32];
void main() {
int j;Glcd_Init(&PORTB,3,2,4,5,7,6, &PORTD);
while(1)
{Glcd_Fill(0); // Clear screen
Glcd_Image( pic1_bmp );
delay2S(); delay2S();Glcd_Fill(0); // Clear screen
Glcd_Image( pic2_bmp );
delay2S(); delay2S();Glcd_Set_Font(FontSystem5x8, 5, 8, 32);
Glcd_Fill(0); // Clear screen
Glcd_Write_Text("PIC Project Board", 0, 0, 1);
Glcd_Write_Text("PIC18F458 8MHz", 0, 1, 1);
Glcd_Write_Text("PIC18F4580", 0, 2, 1);
Glcd_Write_Text("PIC16F887", 0, 3, 1);
Glcd_Write_Text("Channel1=0.008827V", 0, 4, 1);
Glcd_Write_Text("Channel2=1.272637V", 0, 5, 1);
Glcd_Write_Text("PIC terminal", 0, 6, 1);sprinti(buffer,"DATA=%XH",0xFFFF);
Glcd_Write_Text(buffer, 0, 7, 1);
delay2S(); delay2S();}
}
Figure 9 Sample code for testing the 128x64 LCD and the PIC18F458. Sample Code 2: UART Testing with PIC16F887
The sample c program shown in Figure 10 demonstrates how to use the UART using internal oscillator 4MHz with the PIC16F887.
/*
Test code for UART of the PIC16F887 using internal 4MHz oscillator
UART is set to 9600 8n1
Fuse settings
INTOSC, WDT_OFF, MCLR_OFF, LVP_OFF*/
unsigned int count=0;
char buffer[32];char *print_terminal(char *str)
{
unsigned char i;
for(i=0; str[i] != 0; i++)
USART_Write(str[i]);
return str;
}void main() {
USART_Init(9600); // Initalize USART (9600 baud rate, 1 stop bit, no parity...)while(1)
{
//USART_Write('X');
sprinti(buffer,"\r\n%d",count++);
print_terminal(buffer);
Delay_ms(500);
}Figure 10 Sample code for testing the UART on PIC16F887.
Download
Schematic and BOM schematic.pdf C source code and hex file GLCD.c GLCD.hex UART887.C UART887.HEX Expansion board template file Orcad 9.1 EXPANSION.TCH Orcad library for PIC chip
<BACK9 November 2008
Recovered 19 January 2016