728x90

728x90

Showing posts with label PIC16F818/819. Show all posts
Showing posts with label PIC16F818/819. 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


Saturday, August 8, 2020

Creating A Negative Voltage Regulator Using PIC16F818 PWM

Creating A Negative Voltage Regulator Using PIC16F818 PWM

 An Overview Of Negative Voltage Creating 

A negative voltage level is useful in some situations, a negative voltage reference for ADC module, a negative supply voltage for an op-amp. 

Creating A Negative Voltage Regulator Using PIC16F818 PWM
A simulation program sample

It's easily built using two high speed diodes, two polarized capacitor with an oscillator. An oscillator could be created with NE555 timer, or using an op-amp with some extra passive components.

Creating A Negative Voltage Regulator Using PIC16F818 PWM
A block of negative voltage generator. At the high cycle of OSC1, 
it charges the capacitor C1, and bypass D1 diode to the ground
creating a potential at both positive and negative pin of C1. 


Another option to create a negative voltage is using a DC-DC converter, as a case of using MC34063A. 

Using these two method as per above require an extra components placement on board. In any application where a microcontroller is needed, we can use a PWM signal created by the on-board microcontroller. Most 8-bit microcontroller, currently shipped with a PWM peripheral inside. If it isn't so, PWM signal could be created using software, by toggling an output pin with a specific period. 

PIC16F818 PWM Programming And Interfacing With CCS PICC

PIC16F818 is an 8-bit microcontroller. It's a tiny 18-pin available in DIP package. PWM signal is created by CCP1 module inside this device.

With the ease of complexity of programming, CCS PICC could configure the PWM output using a few line of code. Unlike other compiler, that a calculation to find PWM frequency and duty cycle is needed.

In CCS PICC, I use the #use pwm(options) directive to configure the module, frequency and duty cycle. But it's required to set the direction of CCP1 pin to an output direction. It's done within a few lines C code.

In this program, I use CCP1 of PIC16F818 to create PWM signal at the frequency of 1 kHz, and 50% duty cycle. This signal fed into the negative voltage generator circuit, creating a negative output voltage around -5 V, the same magnitude to the input voltage.

Creating A Negative Voltage Regulator Using PIC16F818 PWM
Schematic Diagram, excludes the supply voltage circuit for the MCU. CCP1 creates a PWM 
output at RB2. The MCU clock is internal 8 MHz RC oscillator inside.

C source code is just a dozen of lines.

#include<16F818.h>
#fuses INTRC_IO,NOWDT
#use delay(clock=8M)

/*Use CCP1 Module with the frequency of
1 kHz and 50% duty cycle*/
#use pwm(CCP1,FREQUENCY=1000,DUTY=50)

void main(void){
   output_B(0x00);
   set_tris_b(0x00);
   while(1){
   
   }
}

A screen shot of the running program shown below.

Creating A Negative Voltage Regulator Using PIC16F818 PWM
A simulation screen shot. Output voltage probe connects to C2(-). Output voltage 
reaches around -5 V when C2 is fully charged.

Thursday, July 23, 2020

PIC16F818 interfaces to TC72 SPI Digital Temperature Sensor using CCS PICC

TC72 SPI Temperature Sensor At Brief

TC72 is a temperature-to-digital converter with serial peripheral interface (SPI). It could read the temperature from -55 to +125 degree Celsius. The temperature data is 10-bit format in which the upper 8-bit is the signed decimal value. The remaining two lower bits is the fraction value. The fraction is 0.25 degree Celsius step.


Sample program of TC72 temperature reading sensor negative Proteus CCS PICC PIC PIC16F display LCD microcontroller Microchip digital thermometer
A program screen shot reading the temperature of -16.25 degree Celsius.

The device comes with 8-pin SMD package.


TC72 SMD Package
Pins diagram of this device lists below.

TC72 Pins Diagram

The supply voltage is between 2.65 V to 5.5 V DC. All pins description are list below.

  1. NC - No Connection
  2. CE - Chip Enable (active high)
  3. SCK - Serial Clock Input
  4. GND - Ground
  5. SDO - Serial Data Out
  6. SDI - Serial Data In
  7. NC - No Connection
  8. VDD - Positive Supply 

For data communication, there are two read and write operations- SPI single byte and SPI multiple byte. But here, I implement only the SPI single byte implementation.


TC72 SPI Read/Write Operation
Ax Denotes the address of register. Dx is the data written or reading from the corresponding address.

Reading and writing need one 8-bit address and one 8-bit data. There are four addresses registers- Control, LSB Temperature, MSB Temperature and Manufacturer ID Register. Control register is read/write while others are read-only.

TC72 Address

Control register is for initialize the operation of this device. There are three modes- one-shot, continuous conversion and shut down. At power on reset or brown out reset, it is in shut down mode. Control register setting lists below.

  1. One-shot = 0 and Shut-Down = 0 - Continuous temperature conversion
  2. One-shot = 0 and Shut-Down = 1 - Shut Down
  3. One-shot = 1 and Shut-Down = 0 - Continuous temperature conversion
  4. One-shot = 1 and Shut-Down = 1 - One Shot

LSB temperature is the two-bit fraction number. It is 0.25 degree Celsius per bit, and 0.75 degree Celsius maximum value. We can ignore this fraction LSB temperature number with 0.75 degree Celsius error.

MSB temperature is the signed decimal temperature data. Manufacturer ID identifies this device.

Programming with CCS PICC

PIC16F818 comes with and SPI communication module. The program memory sizes up to 2 kB, sufficient for this programming example.

In this example, the SPI port commands to read the temperature from TC72 in continuous mode. An 16x2 character LCD display the result with full formatting. 

The MCU clocks at 4 MHz, yielding a 1 micro second instruction speed. SPI clock is divided by 64 to make a steady serial data reading. 


Schematic for this program
Schematic diagram

CCS PICC program lists below.


#include<16F818.h>
#use delay(clock=4M)
#fuses NOWDT,INTRC_IO

#define LCD_ENABLE_PIN  PIN_A2                                        
#define LCD_RS_PIN      PIN_A0 
#define LCD_RW_PIN      PIN_A1    
#define LCD_DATA4       PIN_A4    
#define LCD_DATA5       PIN_A3    
#define LCD_DATA6       PIN_A6  
#define LCD_DATA7       PIN_A7

/*use a built-in LCD driver*/
#include<lcd.c>

void main(){
   int sspL,sspH,fraction;
   /*223 is custom code for degree*/
   char c1=223,signing;
   int fractionN[3]={75,50,25};
   /*SPI master mode, clock low to high divided by 64*/
   setup_spi(SPI_MASTER | SPI_L_TO_H |SPI_CLK_DIV_64);

   output_b(0x00);
   set_tris_b(0x02);
   setup_adc_ports(no_analogs);
   lcd_init();
   lcd_gotoxy(1,1);
   
   printf(LCD_PUTC,"Temperature");
   /*Configure the TC72, Set the control
   register to continuous temperature reading*/
   output_high(pin_b0);
   /*0x80 is the control register address*/
   spi_write(0x80);
   /*0x04 means continuous temperature conversion*/
   spi_write(0x04);
   output_low(pin_b0);
   /*Wait for device to be ready*/
   delay_ms(250);
   
   while(1){
      
      /*Reading the LSB fraction number*/
      output_high(pin_b0);
      /*0x01 is the LSB temperature fraction number*/
      spi_write(0x01);
      /*output one more clock frame*/
      spi_write(0x00);
      output_low(pin_b0);    
      if( spi_data_is_in() ) sspL=spi_read();   
      
      /*Reading the MSB decimal number*/
      output_high(pin_b0);
      /*0x02 is MSB temperature address*/
      spi_write(0x02);
      /*output one more clock frame*/
      spi_write(0x00);    
      output_low(pin_b0);  
      if( spi_data_is_in() ) sspH=spi_read();
      
      lcd_gotoxy(1,2);
      
      /*Processing the fraction number*/
      sspL>>=6;
      fraction=sspL*25;
      
      /*Check wether temperature is negative*/
      if(sspH&0x80){
         sspH=~sspH;
         signing='-';
         fraction=fractionN[sspL];
      }
      else {
         signing=' ';
      }
      
      printf(LCD_PUTC,"%c%d.%d %cC   ",signing,sspH,fraction,c1);    
      delay_ms(1000);
   }
}

The overall program resource usage needs 86% of flash memory and 24% of program memory.

CCS PICC completed compilation


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

 

 Watch it on YouTube


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