Design of PIC test Board

Design a PIC 18Fxxxx  test board to test the LED, Buzzer and Relay connected to ports and control them using keys or switches


Note : While designing the PIC test Board  look into the problem carefully and start working accordingly, program is mandatory

Answer: Following fig. shows the design of PIC test board for verifying the LED connected to port B, with switches and Buzzer to port D, with relay interface for Port A.

Step1: Design of Power Supply:


The microcontroller selected is PIC 18F4550 which works on the frequency of oscillator ranging from 0 to 20 MHz and requires power supply of ± 5 or ±12 V. A simple circuit design for +5 V is shown in Fig. 

power-supply


Fig. Design of  +5V Power Supply 

Step2: Design of Clock Circuit:


The Quartz crystal is connected to OSC1 and OSC2 pin in order to synchronize the operation of all components connected with internal and external means. The values for C1 and C2 are selected according to the crystal frequency for stabilizing the oscillator pulses. In general with quartz crystal 22-33 µF is preferred.

Step3: Design of Reset Circuit:


The RC high pass filter with C=0.1µF along with 20 kΩ register is connected to MCLR pin. When high pulse appear on it, resets the contents of inter registers and SFRS to initial value.

Step4: Configuration of Port


PIC has 33 I/O lines which can be configured as input and output using TRISX register as

  • If TRISX = 0 —Ports (A-E) are configured as output ports 
  • If TRISX = 1 —Ports (A-E) are configured as input ports.

Step 5: Connection Diagram:

PIC-Test-board



Fig.Minimum connection Diagram PIC Test board

Step 6 : Algorithm


Step 1 : Initialize TRIS SFR for direction control
Step 2 :Check status of switch
Step 3 : If closed,  turn on LED, buzzer should sound and energizes the relay.
Step 4 :Otherwise wait till switch gets closed
Step 5 : if switch is open, led off, buzzer off, relay off
Step 6 : keep monitoring status of switch

​​​Step 7 : End

Step 7: Embedded C Program


#include<P18F4550.h>
void delay(void);
void main()
{
unsigned char i, key;
TRISDbits.TRISD0 = 1;//set RD0 as input
TRISBbits.TRISB0 = 0;//set LED pin RB0 as output
TRISDbits.TRISD2 = 0;//set buzzer pin RD2 as output
TRISAbits.TRISA4 = 0;//set relay pin RA4 as output
while(1)
{
LATDbits.LD0 = 1; // RD0 pin as continuosly High
if(PORTDbits.RD0 == 0)  // if switch is pressed
{
PORTBbits.RB0 = 1;//set led pin RB0 as High
delay();
PORTDbits.RD2 = 1;//set buzzer pin RD2 as High, Buzzer ON
delay();
PORTAbits.RA4 = 1;//set relay pin RA4 as High, Relay ON
delay();
}
else(PORTDbits.RD0 == 1)  // if switch is pressed
{
PORTBbits.RB0 = 0;//set led pin RB0 as low, led off
delay();
PORTDbits.RD2 = 0;//set buzzer pin RD2 as low, Buzzer off
delay();
PORTAbits.RA4 = 0;//set relay pin RA4 as low, Relay Off
delay();
}
}
void delay()
{
unsigned int j,k;
for(j=0;j<=10;j++)
for(k=0;k<=3000;k++);
}

References


  • WikiNote Foundation

Last modified: Tuesday, 17 September 2019, 2:51 PM