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.
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:
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
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
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
PORTDbits.RD2 = 1;//set buzzer pin RD2 as High, Buzzer ON
PORTAbits.RA4 = 1;//set relay pin RA4 as High, Relay ON
else(PORTDbits.RD0 == 1) // if switch is pressed
PORTBbits.RB0 = 0;//set led pin RB0 as low, led off
PORTDbits.RD2 = 0;//set buzzer pin RD2 as low, Buzzer off
PORTAbits.RA4 = 0;//set relay pin RA4 as low, Relay Off
unsigned int j,k;
- WikiNote Foundation