728x90

728x90

Showing posts with label PIC12F. Show all posts
Showing posts with label PIC12F. Show all posts

Friday, July 11, 2025

DIY PICMicro Low Pin Count DIP Prototype Board

Overview 

Using a prototype board for micro-controller firmware testing could save time and safer. Putting an on-board device programmer with prototype board could be more satisfy for electronic hobbyists.

I have some PIC18 and PIC16 series of micro-controllers left from previous projects. I don't know what to do with them anymore. So I put them on single board to PIC program testing next time I need them without checking their pin diagram, and wiring them on bread board. 

DIY PICMicro Low Pin Count DIP Prototype Board
PCB Front View

DIY PICMicro Low Pin Count DIP Prototype Board
PCB Back View
 

I designed a PCB with a 

  1. PICKit2 device programmer (with AVR ISP header)
  2. +5VDC and +3.3VDC low drop out power supply
  3.  RS-232 to TTL logic converter
  4. I2C DS1307 RTC and 24LC08 EEPROM 
  5. 4-bit LCD (HD4478)
  6. 3-digit 056'common cathode multiplexing display 
  7. One passive buzzer with transistor driver (using CCP1 PWM output pin of PIC16F876A)
  8. 8-LED that connects to PORTC of PIC16F876A
  9. A 4x4 keypad matrix that connects to PORTB of PIC16F876A
  10. Three analog inputs (one LM35 and two potentiometers) that connect to RA0...RA1 of PIC16F876A. 
  11. A 28-pin IC socket for 28-pin PIC devices
  12. A 20-pin IC socket for 20-pin PIC devices
  13. A 18-pin IC socket for 18-pin PIC devices
  14. A 14-pin IC socket for 14-pin PIC devices
  15. And a 8-pin IC socket for 8-pin PIC devices

This board seem to be a large PCB with two copper layer near a size of an A4 paper that I'm not yet fabricate it. It need a PCB fabrication service.

Schematic

I use Protues VSM Release 8.16 SP3 to design draw its circuit diagram. Some components are not in its original libraries. So I find and download some devices symbol, footprints and 3D objects from snapeda website. I separate its schematic into A4 sheets. 



DIY PICMicro Low Pin Count DIP Prototype Board
Sheet #1

DIY PICMicro Low Pin Count DIP Prototype Board
Sheet #2

DIY PICMicro Low Pin Count DIP Prototype Board
Sheet #3

DIY PICMicro Low Pin Count DIP Prototype Board
Sheet #4

DIY PICMicro Low Pin Count DIP Prototype Board
Sheet #5

This board could fit,

  1. 28-pin PIC microcontrollers: PIC16F876A, PIC16F886, etc.
  2. 20-pin PIC microcontrollers: PIC16F1459(USB), PIC16F690, etc.
  3. 18-pin PIC microcontrollers: PIC16F1827, PIC16F84A, PIC16F818, etc.
  4. 14-pin PIC microcontrollers: PIC16F630, PIC16F676, etc.
  5. 8-pin PIC microcontrollers: PIC12F629, PIC12F675, PIC12F683, etc.

These are some mid-range PIC micro-controllers I have at my own workshop.

Printed Circuit Board (PCB)

This board size is 8.02x6.30 inches that could be a little bit expensive to order from any professional PCB fabrication service. But if we need to use it with classmate or friend the share cost is cheaper.

DIY PICMicro Low Pin Count DIP Prototype Board
Top Copper non-mirror


DIY PICMicro Low Pin Count DIP Prototype Board
Bottom Copper


DIY PICMicro Low Pin Count DIP Prototype Board
Top Silk

I preview this PCB on an online Gerber viewer software.

DIY PICMicro Low Pin Count DIP Prototype Board
Gerber View Top Copper

DIY PICMicro Low Pin Count DIP Prototype Board
Gerber View Bottom Copper


 Click here to download its design file.


PCB Fabrication

I have been using PCBWay for many years now. PCBWay fabricate PCBs at low cost, fast processing time for only 24 hours, and fast delivery time using any carrier options. This double side 10cmx10cm can be fabricate at only 5USD for 5 to 10pcs by PCBWay. It's a standard PCB with silk screen and solder mask.

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
10 PCBs for only 5USD
 

For different size of PCB we can instantly quote on PCBWay website using a zip PCB Gerber file without account.


A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
PCBWay Instant Quote
 

We can accurately see the preview of fabricated PCB generated by the company's online Gerber file viewer.

PCBWay also offer PCBA assembly service at reasonable price.

A DIY dsPIC30F2010 and dsPIC30F1010 Prototype Board with Programmer
PCBWay PCB Assembly Service


Tuesday, August 25, 2020

Reading The Digital Input Output From PCF8574 Using PIC12F629

The PCF8574 Overview

NXP PCF8574 is a remote digital inputs outputs expander. The interfacing method is implemented using the two-wire Inter Integrated Circuit (I2C) with the frequency up to 100 kHz. It has an 8-bit digital input output port. It's input output port is quasi-bidirectional. It does not require direction control.


Reading The Digital Input Output From PCF8574 Using PIC16F629
A sample of program PIC12F629 connects to PCF8574 via software I2C Interface

Samples of PCF8574AP I bought from on line store

PCF8574AP Pin Diagram

Each pin of this 16-pin DIP device lists below.

Reading The Digital Input Output From PCF8574 Using PIC16F629
Pin description of PCF8574 (from datasheet)

Supply voltage for this device ranges from 2.5 V to 6 V, typically 5 V for hobbyist prototyping. It's commonly found in input/output driving, keypad, and character LCD interface converter.

Programming For PCF8574

To interface to I2C devices on bus, we must know about it's device read/write address follows by an I2C start condition. It's read/write address varied with three bits A2, A1 and A0. These three pins must pull high or low externally, to make a specific slave address. The address lists below.

PCF8574 slave address

With these three bits, we could make three different slave address.

PCF8574 address map

Writing to the port of PCF8574 make its digital port as output. After a start condition, we must send the device slave address as listed above, follows by an 8-bit output value.

Write mode (output)

To read from this device, we put its read address, follows by data reading. For example, when we connect A2, A1 and A0 to VSS the device write address is 0x40 with the read address 0x41.

The INT (interrupt) pin is an output from PCF8574. It's open drain. This pin create a low signal when there's any logic state changed at input to the port of PCF8574.

Connecting the INT to Microcontroller

CCS PICC Coding

CCS PICC is a C compiler for 8-bit and 16-bit PICMicro. It's fast and easy to use with a lot of library. There are both hardware and software library. In the case of I2C, any device with I2C (for example PIC16F818) we can use hardware library or software library. Hardware I2C library is fast and reliable. Software I2C library work slower because it use program routine. Sometimes, it cause data corrupt. But with software I2C library, we can select any two-pin within the device.

PIC12F629 is an 8-pin 8-bit PICMicro in the Mid-Range family. It doesn't have I2C module shipped. However, we can use software I2C library instead.


Pin Diagram

In this example, I read data from the lower nibble of PCF8574 input and output to its higher nibble to the port.

Reading The Digital Input Output From PCF8574 Using PIC16F629
Schematic Diagram

Source Code.

#include<12F629.h>
/*Use internal RC oscillator*/
#fuses INTRC_IO
#use delay(clock=4M)
/*implementing the software-base I2C*/
#use i2c(scl=pin_a0,sda=pin_a1,FORCE_SW)

void main(void){
   char rcvData=0;
  
   while(1){
      /*Turn on lower nibble high
      for digital input*/
      i2c_start();
      i2c_write(0x40);
      i2c_write(rcvData|0x0F);
      i2c_stop();
      
      /*Read the input state of
      lower nibble*/
      i2c_start();
      i2c_write(0x41);
      rcvData=i2c_read();
      i2c_stop();
      
      /*Shift the inputs right
      to the output*/
      rcvData<<=4;
      
      /*Write Data to output*/
      i2c_start();
      i2c_write(0x40);
      i2c_write(0x0F);
      i2c_stop();
      
      /*Turn on lower nibble high
      for digital input*/
      i2c_start();
      i2c_write(0x40);
      i2c_write(rcvData|0x0F);
      i2c_stop();
      
      /*wait for 100 mS*/
      delay_ms(100);     
   }
}

Click here to download the complete example. This example uses the ATMega32 to interfaces with the PCF8574A using its TWI module.

If you want a standard PCB for ATMega32 micro-controller, you can order my AVR Microcontroller project from PCBWay with a reasonable price. Click here to get a free $5 credit for new account.

Interfacing ATMega32 to 74HC595 shift register
ATMega16 ATMega32 Experiment Board PCB from PCBWay

 


Saturday, May 16, 2020

PIC12F683 reading LM35 analog temperature sensor with 74HC595 driven seven-segment displays

PIC12F685 is an 8-pin DIP PIC microcontroller. However, it has a lot peripherals such as 10-bit ADC, timer, large program memory and EEPROM.

It has up to 6 inputs/outputs, if we internal RC oscillator, and disabling the master clear reset (/MCLR) pin.

Since it has only 6 inputs/outputs, we need more output expanding. I use six 74HC595 shift register to drive 6 digits seven-segment display. 

The overall 74HC595 combination interface to the PIC12F685 with only three pins:

  1. serial clock

  1. serial data

  1. and latch pin

The PIC12F685 shifts data to the display system serially using these three pins.

LM35 is an analog temperature sensor, comes with three pins:

  1. DC supply voltage
  2. analog temperature data out
  3. DC supply ground     

The DC supply voltage ranges from +4 V to +30 V. But it is typically supplied at +5 V.

The analog temperature output is +10 mV per degree Celsius. With a 10-bit ADC module of PIC12F685 could precisely convert the analog temperature.

In this application, I use the temperature sensor to condition a DC fan. The fan will turn on if the temperature exceed 30 degree Celsius. 


PIC12F683 reading LM35 analog temperature sensor with 74HC595 driven seven-segment displays
Schematic diagram,
PIC12F683 CPU supplied at +5 V DC, clocked at 4 MHz
internal RC oscillator.
The display system driven by the 74HC595 shift register,
implementing only three MCU pins.
LM35 supplied at +5 V DC, fed the analog temperature
data to the MCU's pin GP4.
A DC fan output controlled by MCU's pin GP5.
It will turn on at the temperature above +30 degree
Celsius.


In this situation the system could only read the non negative temperature data, due to insufficient analog configuration pins.

The source code is written in CCS PICC compiler. The compiler has a lot of libraries. The 74HC595 is implemented with the compiler ready-to-use library.


Source Code:
#include<12F683.h>
//set the ADC to 10-bit
#device adc=10
#fuses INTRC_IO,NOWDT,NOMCLR
#use delay(clock=4M)
#define EXP_OUT_ENABLE  PIN_A2
#define EXP_OUT_CLOCK   PIN_A0
#define EXP_OUT_DO      PIN_A1
#define NUMBER_OF_74595 6
#include<74595.c>
#define FAN PIN_A5
void main(){
   unsigned char shiftData[6];
   unsigned char ssd[16]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,
0x7D,0x07,0x7F,0x6F,0x77,0x7C,0x39,0x5E,0x79,0x71}; 
   unsigned int16 converter;
   long adcResult;
   float temperature;
   
   setup_oscillator(OSC_4MHz);
   
   output_low(FAN);
   setup_adc_ports(sAN0);
   setup_adc(ADC_CLOCK_INTERNAL);
   set_adc_channel(3);
   delay_ms(10);
     
   read_adc(adc_start_only);
   
   while(1){
      adcResult=read_adc();
      while(!adc_done());
      
      //convert the analog voltage to temperature
      temperature = (5.0*adcResult/1024)*1000;
      
      converter=(int16)temperature;
      
      //display the temperature data
      shiftData[0]=ssd[converter/1000];
      if(converter<1000) shiftData[0]=0;
      shiftData[1]=ssd[(converter%1000)/100];
      if(converter<100) shiftData[1]=0;
      shiftData[2]=ssd[(converter%100)/10]|0x80;
      shiftData[3]=ssd[converter%10];
      shiftData[4]=0b01100011;
      shiftData[5]=0b00111001;
      write_expanded_outputs(&shiftData);
      
      //conditioning the fan
      if((temperature/10)>30) output_high(FAN);
      else output_low(FAN);
      
      delay_ms(1000);
   }
}

The overall program require 44% of the 2048 word of the PIC12F683 program memory.


PIC12F683 reading the temperature from LM35
Simulation screen shot,
The temperature reading is 29.7 degree Celsius.
The DC fan is turned off.

320x50

Search This Blog

Labels

25AA010A (1) 8051 (7) 93AA46B (1) ADC (30) Analog Comparator (1) Arduino (15) ARM (6) AT89C52 (7) ATMega32 (57) AVR (58) CCS PICC (28) DAC (1) DHT11 (2) Display (106) Distance Sensor (3) DS18B20 (3) dsPIC (3) dsPIC30F1010 (3) dsPIC30F2010 (1) EEPROM (5) Environment Sensor (4) esp8266 (1) I2C (29) Input/Output (68) Interrupt (19) Keil (5) Keypad (10) LCD (48) Master/Slave (1) MAX7221 (1) MCP23017 (5) MCP23S17 (4) Meter (3) MikroC (2) Motor (15) MPLABX (73) Nokia 5110 LCD (3) OLED (2) One-Wire (6) Oscillator (8) PCB (10) PCD8544 (3) PCF8574 (5) PIC (108) PIC12F (3) PIC16F628A (3) PIC16F630 (2) PIC16F716 (4) PIC16F818 (11) PIC16F818/819 (3) PIC16F84A (16) PIC16F876A (2) PIC16F877A (9) PIC16F88 (2) PIC16F887 (60) PIC18 (19) PIC18F1220 (5) PIC18F2550 (5) PIC18F4550 (12) PICKit2 (1) PWM (11) RTC (9) Sensor (11) SH1106 (1) Shift Register (11) Shift Registers (3) SPI (24) STM32 (6) STM32 Blue Pill (6) STM32CubeIDE (6) STM32F103C8T6 (6) SysTick (3) temperature sensor (11) Thermometer (21) Timer/Counter (31) TM1637 (2) UART (7) Ultrasonic (4) Voltmeter (7) WDT (1) XC16 (2) XC8 (96)

tyro-728x90