Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use PIC: Examples, Pinouts, and Specs

Image of PICDesign with PIC in Cirkit Designer

Introduction

A PIC (Peripheral Interface Controller) is a family of microcontrollers developed by Microchip Technology. These microcontrollers are widely used in embedded systems due to their simplicity, low power consumption, and flexibility. PIC microcontrollers are available in a variety of configurations, making them suitable for a wide range of applications, from simple hobbyist projects to complex industrial systems.

Explore Projects Built with PIC

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Raspberry Pi Pico and OV7670 Camera-Based Robotic System with TFT Display: A project utilizing PIC in a practical application
Raspberry Pi Pico and OV7670 Camera-Based Robotic System with TFT Display

This circuit features two Raspberry Pi Pico microcontrollers interfacing with various peripherals including an OV7670 camera module, a TFT display, and an OLED display. It also includes a multiplexer and a motor driver to control two planetary gearbox motors, powered by a battery and regulated through buck converters. The setup is designed for image capture, display, and motor control applications.

Open Project in Cirkit Designer
Image of ESP32-Based Security System with RFID, PIR Sensor, and Laser Detection: A project utilizing PIC in a practical application
ESP32-Based Security System with RFID, PIR Sensor, and Laser Detection

This circuit features an ESP32 microcontroller as the central processing unit, interfaced with a variety of sensors and modules. It includes a PIR sensor for motion detection, an RFID-RC522 module for RFID communication, a 4x4 membrane matrix keypad for user input, and an ESP32-CAM module for capturing images or video. Additionally, the circuit uses a PCF8575 I/O expander to increase the number of available I/O pins, a KY-008 laser emitter, and a corresponding laser receiver module to detect laser beam interruptions.

Open Project in Cirkit Designer
Image of ESP32-Based Security System with RFID, PIR Sensor, and Laser Detection: A project utilizing PIC in a practical application
ESP32-Based Security System with RFID, PIR Sensor, and Laser Detection

This circuit features an ESP32 microcontroller as the central processing unit, interfaced with a variety of sensors and modules. It includes a PIR sensor for motion detection, an RFID-RC522 module for RFID communication, a 4x4 membrane matrix keypad for user input, and an ESP32-CAM module for capturing images or video. Additionally, the circuit integrates a PCF8575 I/O expander to increase the number of available I/O pins, a KY-008 laser emitter, and a corresponding laser receiver module to detect laser beam interruption.

Open Project in Cirkit Designer

Common Applications and Use Cases

Technical Specifications

Below are the general technical specifications for a typical PIC microcontroller. Note that specific models may vary in their features and capabilities.

Key Technical Details

Pin Configuration and Descriptions

The pin configuration of a PIC microcontroller depends on the specific model. Below is an example of a typical 8-pin PIC microcontroller (e.g., PIC12F675):

Pin Number Pin Name Description
1 VDD Positive power supply (2.0V to 5.5V)
2 GP5 General-purpose I/O pin
3 GP4 General-purpose I/O pin
4 GP3/MCLR General-purpose I/O or Master Clear pin
5 GP2 General-purpose I/O pin
6 GP1 General-purpose I/O pin
7 GP0 General-purpose I/O pin
8 VSS Ground (0V)

For larger PIC microcontrollers, refer to the datasheet for the specific model to understand the pinout and functionality.

Usage Instructions

How to Use the Component in a Circuit

  1. Power Supply: Connect the VDD pin to a regulated power source (e.g., 3.3V or 5V) and the VSS pin to ground.
  2. Clock Source: Configure the internal oscillator or connect an external crystal oscillator to the appropriate pins (if required).
  3. Programming: Use a PIC programmer (e.g., PICkit 3 or PICkit 4) to upload your code to the microcontroller. Ensure the programming pins (e.g., ICSPDAT and ICSPCLK) are correctly connected.
  4. I/O Configuration: Configure the I/O pins as input or output in your code. Use pull-up or pull-down resistors if necessary.
  5. Peripheral Setup: Initialize peripherals (e.g., ADC, UART, PWM) in your code based on your application requirements.

Important Considerations and Best Practices

Example Code for Arduino UNO Integration

While PIC microcontrollers are standalone devices, they can communicate with an Arduino UNO via protocols like UART. Below is an example of how to send data from an Arduino UNO to a PIC microcontroller using UART:

Arduino UNO Code

void setup() {
  Serial.begin(9600); // Initialize UART communication at 9600 baud
}

void loop() {
  Serial.println("Hello, PIC!"); // Send a message to the PIC
  delay(1000); // Wait for 1 second
}

PIC Code (Using MPLAB XC8 Compiler)

#include <xc.h>

// Configuration bits (adjust based on your PIC model)
#pragma config FOSC = INTRCIO // Internal oscillator, I/O on RA6/RA7
#pragma config WDTE = OFF     // Watchdog Timer disabled
#pragma config PWRTE = ON     // Power-up Timer enabled
#pragma config MCLRE = ON     // MCLR pin enabled
#pragma config CP = OFF       // Code protection disabled
#pragma config BOREN = ON     // Brown-out Reset enabled
#pragma config IESO = OFF     // Internal/External Oscillator Switchover disabled
#pragma config FCMEN = OFF    // Fail-Safe Clock Monitor disabled

void UART_Init() {
    TXSTAbits.BRGH = 1; // High-speed baud rate
    SPBRG = 25;         // Baud rate = 9600 for 4 MHz clock
    TXSTAbits.SYNC = 0; // Asynchronous mode
    RCSTAbits.SPEN = 1; // Enable serial port
    TXSTAbits.TXEN = 1; // Enable transmitter
}

void UART_Write(char data) {
    while (!TXSTAbits.TRMT); // Wait until the transmit buffer is empty
    TXREG = data;            // Transmit data
}

void main() {
    UART_Init(); // Initialize UART
    while (1) {
        UART_Write('H'); // Send 'H'
        UART_Write('i'); // Send 'i'
        UART_Write('\n'); // Send newline
        __delay_ms(1000); // Wait for 1 second
    }
}

Troubleshooting and FAQs

Common Issues Users Might Face

  1. Microcontroller Not Responding:

    • Ensure the power supply voltage is within the specified range.
    • Verify that the MCLR pin is properly configured (pull-up resistor connected).
    • Check the connections to the programmer and ensure the correct programming pins are used.
  2. Incorrect UART Communication:

    • Verify that the baud rate settings match between the PIC and the external device (e.g., Arduino).
    • Check the TX and RX pin connections.
  3. Code Not Running as Expected:

    • Double-check the configuration bits in your code.
    • Ensure the oscillator settings match your hardware setup.

Solutions and Tips for Troubleshooting

By following this documentation, you can effectively use a PIC microcontroller in your projects and troubleshoot common issues. Always refer to the specific model's datasheet for precise details and configurations.