Buck-Boost Converter with lcd and keypad using PIC16F877A

Thread Starter

sefoj12

Joined Oct 22, 2017
2
our project is to generate the buck- boost converter using pwm in pic16f877a range from 0-48v and our main source is 24v..the use of keypad and lcd is to input voltage and display in lcd and generate it to pwm and put it in the converter please anyone help me
 

dendad

Joined Feb 20, 2016
4,476
Have you done any work on it as yet?
Are you using a development board or rolling your own. And What is your programming environment?

First I'd get the LCD going then you have a built in debug display.
Then read the keys and display when pushed.
Next get the PWM going to drive an LED.
This is a pretty good project to learn on. Just work in steps and see how you go.
 

Thread Starter

sefoj12

Joined Oct 22, 2017
2
as of now we were working on the lcd and keypad part but our problem we dont know how to input at least 2 digit number on lcd..here is our code for the keypad and lcd part..can anyone help me


C:
unsigned short kp, cnt, oldstate[48], i;
char txt[1];


// Keypad module connections
char  keypadPort at PORTC;
// End Keypad module connections

// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;

void initMain(){  //main initialization of SFR registers
  INTCON = 0xFF;                        //turn on interrupts
  ADRESH = 0x00;
  ADRESL = 0x00;
  ADCON1 = 0x0F;                        //all inputs are digital
  ADCON0 = 0x00;
  TRISC = 0xFF;                        //PORTD is input
  TRISB = 0x00;
  PORTB = 0x00;
}


void main() {
   Keypad_Init();
   Lcd_Init();
   Lcd_Cmd(_LCD_CLEAR);                     // Clear display
   Lcd_Cmd(_LCD_CURSOR_OFF);                // Cursor off
   Lcd_Out(1, 1, "Voltage:");

   for(i=0; i<47; i++)
    oldstate[I] = 0;                   //reset to 0 keypress counter

  do {                                 //infinite loop
    kp = 0;

    while (!kp){                       //Wait for key to be pressed and released
      kp = Keypad_Key_Press();         //There is a Click function in new library
      Delay_ms(10);                    //wait a bit
    }

    oldstate[kp]--;                   //increment counter for this key

   // Prepare value for output, transform key to it's ASCII value
    switch (kp) {
      case  1: kp = 49; break; // 1        // Uncomment this block for keypad4x4
      case  2: kp = 50; break; // 2
      case  3: kp = 51; break; // 3
      case  4: kp = 65; break; // A
      case  5: kp = 52; break; // 4
      case  6: kp = 53; break; // 5
      case  7: kp = 54; break; // 6
      case  8: kp = 66; break; // B
      case  9: kp = 55; break; // 7
      case 10: kp = 56; break; // 8
      case 11: kp = 57; break; // 9
      case 12: kp = 67; break; // C
      case 13: kp = 42; break; // *
      case 14: kp = 48; break; // 0
      case 15: kp = 35; break; // #
      case 16: kp = 68; break; // D

    }
    Lcd_Chr(1, 10, oldstate);
    Lcd_Chr(1, 11, kp);
    WordToStr(cnt, txt);                   // Transform counter value to string
    }while(1);

}
Moderators note: Please use code tags for pieces of code
 
Last edited by a moderator:
Top