728x90

728x90

Showing posts with label PIC16F628A. Show all posts
Showing posts with label PIC16F628A. 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


Wednesday, June 3, 2020

Interfacing ds1621 digital thermometer to PIC16F628A

Introduction

In industrial control or consumer electronic product, measuring the temperature is usually required. A thermometer used for measuring the temperature comes with many interfaces, analog and digital interface.

For digital interface there are many options. In this example, I use ds1621 digital thermometer manufactured by Maxim Integrated.

This temperature sensor comes with 8 pin integrated circuit. It is also available in DIP package, a good choice for bread board prototyping and hobbyist. The communication interface is inter integrated circuit. 

If we use degree Celsius it could sample the temperature between -55  to +125 degree Celsius with a 0.5 degree Celsius step. Using the Fahrenheit unit equivalence, the temperature sampling ranges from -67 to 257 degree Fahrenheit.

The supply voltage ranges from 2.7 to 5.5 V. In usual prototyping, it's normally supplied at 5 V DC.


Interfacing ds1621 digital thermometer to PIC16F628A
Pin diagram of ds1621

Programming interface

Currently of microcontrollers come with a rich of peripherals including the communication interfaces like inter integrated circuit (I2C). For some old age microcontrollers like PIC16F628A, the I2C is absent. 

With CCS PICC compiler, the I2C interface could be implemented using I2C module inside the MCU. Anyway, without the I2C module any MCU with sufficient program memory could emulate this interface using an I2C library that use bit banging method.

In this example, the MCU read the temperature data from ds1621 thermometer. Temperature data is displayed on a 16x2 lines character LCD. Timer 0 schedule the temperature reading and displaying for every one minute.


Interfacing ds1621 digital thermometer to PIC16F628A
Schematic diagram. CPU clock at 4 MHz. Thermometer connects to PIC16F628A via RA0
and RA1. PortB connects to LCD using 4-bit mode. Clock pins left unconnected due
to 4 MHz internal clock sources is used. 

The PICC source code:

#include <16F628A.h>
#fuses INTRC
#use delay(clock=4000000)
//i2c pins
#define DAL_SCL   PIN_A0
#define DAL_SDA   PIN_A1
//LCD pins                         
#define LCD_RS_PIN      PIN_B0                                    
#define LCD_RW_PIN      PIN_B1   
#define LCD_ENABLE_PIN  PIN_B2
#define LCD_DATA4       PIN_B4                                    
#define LCD_DATA5       PIN_B5                                    
#define LCD_DATA6       PIN_B6                                    
#define LCD_DATA7       PIN_B7         
#include <ds1621.c>
#include<lcd.c>
BYTE value;
BYTE cntInterrupts=0;
float celsius;
/*this function activates
every one second
*/
void displayResult(void){
      value = read_temp();
      /*convert to degree Celsius*/
      celsius = 5.0*(value-32)/9;
      lcd_gotoxy(1,2);
      printf(LCD_PUTC,"%.1f degree C\r\n",celsius);
}
void main() {
   /*timer 0 is prescaled to 1:256*/
   setup_timer_0( RTCC_DIV_256);
   /*turn on timer 0 interrupt*/
   enable_interrupts(INT_TIMER0);
   /*turn on global interrupt control*/
   enable_interrupts(GLOBAL);
   /*clear timer 0 interrupt flage*/
   clear_interrupt(INT_TIMER0);
   /*initialize the ds1621 function*/
   init_temp();
   /*initialize the LCD function*/
   lcd_init();
  
   lcd_gotoxy(1,1);
   printf(LCD_PUTC,"Temperature: ");
   
   while(1){
   /*if it's one second*/
      if(cntInterrupts>=15){
      displayResult();
         cntInterrupts=0;       
      }
      
   } 
}
#INT_TIMER0
void overflowISR(void){
   /*Each interrupt occurs every 65 mS*/
   cntInterrupts++;
   /*Clear flag*/
   clear_interrupt(INT_TIMER0);
}

Interfacing ds1621 digital thermometer to PIC16F628A

A test program read 27.7 degree Celsius from ds1621 thermometers.


Friday, May 15, 2020

PIC16F628A 50MHz Frequency Meters Using Timer1 External Counting

CCS PICC have a ready to use example, demonstrating the technique of using timer 1 external pulses counting to make a 50 MHz frequency meter.

The ex_freq.c explained the the process of making frequency meter using timer 1 of PIC16F877 with a one second delay. The output data is presented in serial terminal.

We can use timer 1 of PIC16F628A to count external digital input pulses. With this advantage, we can make a simple frequency meters, measuring the number of pulses per second.

In this example, I switch the CPU to PIC16F628A with the same build-in timer 1. A 16x2 character LCD uses to present the frequency and period.


PIC16F628A Frequency Meters With LCD
PIC16F628A supplied at +5V, clocks at 20 MHz.
Digital Clock pulse feds into pin RB6 Timer 1 Clock In.
SW1 hold the current frequency/period Value,
when shorted to ground

C Source code and simulation file could be download here:

---------------------------------------------------------------------
#include <16F628A.h>
#fuses HS,NOWDT
#use delay(clock=20000000)    
//one instruction=0.2us
#bit t1_overflow=0x0C.0

#define LCD_ENABLE_PIN  PIN_B2                                        
#define LCD_RS_PIN      PIN_B0                                        
#define LCD_RW_PIN      PIN_B1 

#define LCD_DATA4       PIN_B3                                       
#define LCD_DATA5       PIN_B4                                       
#define LCD_DATA6       PIN_B5                                        
#define LCD_DATA7       PIN_B7                                    


#include<LCD.C>

#define holdButton PIN_A0

void main() {
   int cycles8, cycles;
   long freq;
   long freqc_high;
   long freqc_low;
   set_tris_a(0x01);
   lcd_init();
   
   printf(LCD_PUTC,"Sampling!!!!!!");
   while (TRUE) {
      cycles8=0;
      cycles=0;
      freqc_high=0;
      t1_overflow=0;
      set_timer1(0);
      setup_timer_1(T1_EXTERNAL|T1_DIV_BY_1);
/* ___ wait one second ___  */
      while (cycles!=0xFF) { //true=3, false=4
       cycles8=0; //1 cycle
       //start inner loop
       while (cycles8!=0xFF) { //true=3, false=4
         if (t1_overflow)//true=2,false=3             //----|
            {t1_overflow=0;freqc_high++;}//6 cycles   //    |
         else                                         //    |-- 8 cycles
            {delay_cycles(5);}                        //----|
         delay_cycles(62); //x
         cycles8++; //1
 ///2 cycles to jump to top
 //math: end inner loop
 //math: total inner loop=((3+8+x+1+2)*255 + 4)*255
 //math: if x=62.87781 then inner loops takes 5mil instructions
 //math: if x=62 then inner loop takes 4942920, have to fill 57080 cycles
  }
 delay_cycles(216);      //y
 cycles++;          ///1 cycle
 ///2 cylces to jump to top
 //math: outer=(3+1+y+1+2)*255+4=57080
 //math: y=(57080-4)/255)-(3+1+0+0+1+2)
 //math: if y=216.827450980392156862745098039216 then outer loop cylces is 57080
 //math: if y=216 then outer loop cycles is off by 211 cycles.  z=211
}
      delay_cycles(211);   //z
/* ___ end waiting 1 second ___ */
      setup_timer_1(T1_DISABLED);   
      //turn of counter to prevent corruption while grabbing value
      if (t1_overflow)            
      //check one last time for overflow
          freqc_high++;
      freqc_low=get_timer1();      
      //get timer1 value as the least sign. 16bits of freq counter
      freq=make32(freqc_high,freqc_low);   
      //use new make32 function to join lsb and msb
      //printf("%LU Hz\r\n",freq);      
      //and print frequency
      lcd_gotoxy(1,1);
      printf(LCD_PUTC,"FREQ:");
      lcd_gotoxy(6,1);
      
      float period;
      if(freq==0){
         printf(LCD_PUTC,"Zero Signal");
         printf(LCD_PUTC,"\nT: -------------");
         
      }
      else if(freq<100000)  {
         printf(LCD_PUTC," %LU Hz      ",freq);
         period=1000.0/freq;
         printf(LCD_PUTC,"\nT: %.6f mS  ",period);
      }
      else if(freq<1000000){
         printf(LCD_PUTC," %3.3f kHz       ",(float)freq/1000.0);
         period=1000.0/freq;
         printf(LCD_PUTC,"\nT: %3.6f mS    ",period);
      }
      else{
         printf(LCD_PUTC," %3.3f MHz       ",(float)freq/1000000.0);
         period=1000000.0/freq;
         printf(LCD_PUTC,"\nT: %.6f uS   ",period);
      }
      
      while(input(holdButton)==0);
   }
}

---------------------------------------------------------------------

Simulation Result:

PIC16F628A Frequency Meters Simulation Result
Simulation Result,
signal feed from a virtual signal generator.
The picture show a sampling signal of 8.299 kHz.

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

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