PIC18F2550 Project Board

Wichit Sirichote, kswichit@kmitl.ac.th



The new PIC18F2550 Project Board was designed as the development platform for student projects.

The board features

MCU: PIC18F2550 with external xtal,
ADC: one channel 0-2.5V sigma-delta converter, Linear Technology LTC2400/LTC2420,
6-channal 10-bit ADC 0-5V,
Display: Two connectors for text LCD or GLCD,
USB: onchip USB port with type B connector,
Power supply: onboard low dropout regulator, rechargeable battery,
Code programming: 10-pin header for In Circuit Loader.

The board platform is suitable for developing the microcontroller based instrumentation. Students may build the signal conditioning board, plugs it to PIC project board, develops the code and programs it with loader cable easily.

Figure 1. PIC18F2550 Project Board (click to enlarge) Figure 2. Text LCD displays analog input.

Hardware

The MCU is 28-pin PIC18F2550 with external xtal as the option. We can use internal oscillator. The loader uses only three pins, PGD, PGC and MCLR. J1 is ICSP header, we can plug it to the application board for both code loading and running. The user I/O ports is 6-channel analog input RA0-RA5. PORTB, RB0-RB7 is for LCD interface. User can choose either text LCD at JR1 connector or GLCD at JF1 connector. PORTC, RC0-RC2 is used to interface the LTC2400/LTC2420 SPI bus, sigma delta converter. RC4 and RC5 is USB port signal. RC6 is also available at J2. RC7 is debug LED. J1 is ICSP header. D2 protects VCC from high voltage programming at MCLR pin. U2 can be 20-bit or 24-bit resolution, sigma-delta converter, LTC2420 or LTC2400. J3 is jumper for selecting rejection of the common mode noise frequency, 50Hz or 60Hz. The reference voltage, +2.5V is generated by U3 LM336. The board can be powered by rechargeable battery, BT1.

 
Figure 3. Hardware Schematic and BOM

 

Figure 4. TOP Layer Layout Figure 5. BOTTOM Layer Layout


Figure 6. Component Layout

Figure 7. PCB with blue solder mask

Sample Code: Interfacing LTC2400

The sample c program shown in Figure 8 demonstrates interfacing to sigma-delta converter, LTC2400. The MCU uses 4MHz Xtal with HS oscillator, no division option. The program reads 24-bit data from LTC2400, performs digital filtering and displays input voltage in 0.1uV unit.

// PIC Project Board
// PIC18F2550 + LTC2400 + LCD + USB
// Sample code demonstrates the use of sigma-delta converter.
// The program prints analog input 0-2.5V on LCD in micro Volts unit
// source code was compiled with Mikro-C compiler
// Copyright 2006 Wichit Sirichote, kswichit@kmitl.ac.th          
#define ADC_CS1 PORTC.F0 //            output bit
#define ADC_SDO PORTC.F1 // input bit
#define ADC_SCK PORTC.F2 // output bit

char *text = "PICProject Board";
unsigned long x1,x2,x3,x4,x5;
/* read 32-bit data from LTC2400            */
unsigned long read_ADC1(void)
           {
           char k;
           long n;
           n= 0;
           ADC_CS1 = 0;
           for(k=0; k<32; k++)
           {
           n<<= 1;
           ADC_SCK = 1;
           n |= ADC_SDO;
           ADC_SCK = 0;
           }
           ADC_CS1 = 1;
           n&=0x01fffffff; // maskout sign bit
           n>>=4; // get 24-bit conversion result
           return n;
           }
/* 5-point moving average */
// return data that scaled with reference voltage in uV unit

unsigned long filter_ADC(void)
           {
           x5 = x4;
           x4 = x3;
           x3 = x2;
           x2 = x1;
           x1 = read_ADC1();
           return ((((x1+x2+x3+x4+x5)/5)*148)/100); // x 149 E-9 convert to 2.479V
           }

 void main() 
{
           char buffer[20];
           long d;
           ADCON1 = 0x0E;
           TRISB = 0; // PORTB is output
           PORTC = 0xFF;
           TRISC = 0x02; // PORTC.1 is input bit
           Lcd_Init(&PORTB); // Initialize LCD connected to PORTB
           Lcd_Cmd(Lcd_CLEAR); // Clear display
           Lcd_Cmd(Lcd_CURSOR_OFF); // Turn cursor off
           Lcd_Out(1, 1, text);
          while(1)
           {
           PORTC.F7 ^= 1;
           d = filter_ADC();
           sprintl(buffer,"%08ld x0.1%cV",d,0xe4);
           Lcd_Cmd(LCD_SECOND_ROW);
           Lcd_Out_CP(buffer);
           Delay_ms(200);
            }
           
}
Figure 8. Sample code listing

Download

Schematic and BOM PICprojectboard.pdf
C source code and hex file PICProjectBoard.c PICProjectBoard.hex



3 December 2006