Need help in vb<>pic16F877a<> LCD

Discussion in 'Embedded Systems and Microcontrollers' started by sgkho, Feb 19, 2012.

  1. sgkho

    Thread Starter New Member

    Feb 2, 2012
    11
    0
    We have tried plenty of way but cant solve the problem hope can get expert help in solving the problem cos it almost near the submission date.

    The logic is as below :
    there are two ways that user is able to control the home security mode either by pressing Character A,B,C,D in keypad or vb send char A,B,C,D to activate certain security mode but the problem is neither vb sending char A nor keypad A clicked works. Which the LCD should be display the "A " mode (away mode). Our program are able to display the status of the sensors in vb interface but user not able to control the mode . :confused:

    I have attach the main program n my usart.c code . Hope to get reply soon, thx.
     
  2. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    zip is corrupted. Try posting a short segment of the code where problem is directly using code tags.

    Do not post if you do not understand what I just said.
     
  3. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,866
    988
    There are 3 main things that cause problems with LCD assuming the code is mainly correct.

    1. The contrast pin is not wired correctly. Use a 10K pot and adjust.

    2. It is wired wrong. Step through your code and verify with a scope or logic probe that pins are changing on the LCD as you expect.

    3. The delays after various commands is incorrect. You might find some code that works fine on another MCU but that does not mean it will work on yours if they are different clock speeds.
     
  4. sgkho

    Thread Starter New Member

    Feb 2, 2012
    11
    0
    the coding quite alot so i reupload it . The prob is how to put my gui_control() to the lcd function so that in either case both works and can control the sensors n display the status at LCD


    for pins assignment or circuit i dont think it will have problem since i previously able to use keypad control but when added in vb control command then only keypad control and vb control nt working.
     
  5. sgkho

    Thread Starter New Member

    Feb 2, 2012
    11
    0
    pls , i really need help , If dont work my GUI part just partially complete.
    I have tried out with timer interrupt to let the main program jump out of the while loop when there is no data transfer in usart n a flag to assign if gui is selected the keypad option will be disable. But it still facing same problem. Hope can get help. Really appreciate it,thanks...:(
     
  6. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,866
    988
    You said you "think" the connections are correct. Thinking is not knowing. Have you confirmed with a scope, logic probe, logic analyzer etc. the inputs on the LCD are changing how you expect them to change?

    Most people do not want to open a zip file. You never know what it contains. Even if someone wants to open it, they are not going to read through hundreds of lines of code to troubleshoot your problem.

    If you are have problems with the LCD then create a small program to simply display Hello on the LCD.

    You need to make some attempt to help yourself if you expect others to help you.
     
  7. sgkho

    Thread Starter New Member

    Feb 2, 2012
    11
    0
    sry for my improper language and the way seeking for help. LCD part i'm is my partner doing . Previously without adding the gui control part,the keypad functioned well that able to allow user to select the security mode and display the status on LCD . So dont the LCD functioned correctly not the problem of pins and LCD program ?

    The problem arise when it come to integrate both gui and keypad together. Both GUI control and Keypad control does not work which the keypad suppose functioning as previously but when user key input mode,the LCD still in the main display words that require user to select the security mode.

    The problem is due to the system unable to jump out of the gui_control in while(1) main program as in usart, it will continue looping until there is a char/data receive then only it will jump out of the gui_control function so we added in usart interrupt which the interrupt suppose to be functioning but it not. So just do it part by part, is that correct the way i use to interrupt my usart ?

    This is the interrupt declaration and program:
    Code ( (Unknown Language)):
    1. int counter = 0;
    2.  
    3. static void interrupt isr(void)
    4. {
    5.        
    6.    
    7.     if(TMR0IE && TMR0IF)
    8.         {        
    9.           TMR0IF=0;  //clear flag
    10.  
    11.             if (counter > 60)
    12.             {
    13.                 CREN=0;
    14.                 counter = 0;
    15.                 TMR0IE = 0;    
    16.             }
    17.             counter++;  //increment over flow counter
    18.         }
    19.  
    20.    
    21. }
    Gui part
    Code ( (Unknown Language)):
    1. void gui_control(void)
    2. {
    3.  
    4.     TMR0IE = 1;  //Enable TIMER0 Interrrupt
    5.     counter = 0;
    6.     switch(USARTReadByte())
    7.     {
    8.     case 'A': if (away==1);
    9.               break;
    10.     case 'B': if (home=1);
    11.               break;
    12.     case 'C': temperature();
    13.               delayS(3);
    14.                 digital_reset=1;
    15.               break;
    16.     case'D':  if (pir=1);
    17.               break;
    18.     default:
    19.               break;
    20.     }
    21.    
    22.     TMR0IE = 0;
    23. }
    24.     }
    25. }
    Main program (interrupt configuration)
    Code ( (Unknown Language)):
    1.     // TMR 0 configuation
    2.     T0CS = 0;       //Prescaler gets clock from FCPU (5MHz)                
    3.     PSA = 0;       //Timer clock source is from prescale                
    4.     PS2 = 1;       //prescale 1:256
    5.     PS1 = 1;       //set to "111"
    6.     PS0 = 1;       //prescaler rate bits
    7.     RCIE = 0;      //USART receive interrupt disable bit
    8.     GIE = 1;       //Enable INTs globally
    9.     PEIE = 1;      //Enable Peripheral Interrupt
    10.     TMR0IE = 0;    //Enable TIMER0 Interrupt
     
    Last edited: Feb 22, 2012
  8. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,866
    988
    You are setting TMR0IE to zero. Every Pic I have ever seen it needs to be a 1.

    Check your data sheet.

    There is no need for

    if(TMR0IE && TMR0IF) in your ISR

    if(TMR0IF) will do

    you need to clear TMR0IF in your ISR

    TMR0IF = 0;

    That is just the beginning. I strongly suggest you read up on interrupts. Also you should create a small program just for Timer 0 interrupt to learn how it works.
     
  9. panic mode

    Senior Member

    Oct 10, 2011
    1,318
    304
    why are you saving RAR files with ZIP extension?
    this is the reason your attachments appear corrupt...
     
  10. sgkho

    Thread Starter New Member

    Feb 2, 2012
    11
    0
    oic , thanks for pointing up the problem. I will study up some tutorial for interrupts.

    oic , thanks for the info cos i'm using rar so dont knw it will be occur error if change to zip
     
Loading...