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.

No comments:

Post a Comment

Search This Blog

Labels

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