Interface LCD with PIC18f452

Discussion in 'General Electronics Chat' started by Afnan_123_, Feb 19, 2013.

  1. Afnan_123_

    Thread Starter New Member

    Feb 7, 2013
    22
    0
    Hello
    I am working in project to measure the temperature of the room
    when i did it in proteus program it's working,
    but can anyone check the connection of the pins ?
    because i think we should use capacitor and resistor?
    if we should use it, where i can connect them in the circuit?
    Code ( (Unknown Language)):
    1. // Lcd pinout settings
    2. sbit LCD_RS at RB4_bit;
    3. sbit LCD_EN at RB5_bit;
    4. sbit LCD_D7 at RB3_bit;
    5. sbit LCD_D6 at RB2_bit;
    6. sbit LCD_D5 at RB1_bit;
    7. sbit LCD_D4 at RB0_bit;
    8.  
    9. // Pin direction
    10. sbit LCD_RS_Direction at TRISB4_bit;
    11. sbit LCD_EN_Direction at TRISB5_bit;
    12. sbit LCD_D7_Direction at TRISB3_bit;
    13. sbit LCD_D6_Direction at TRISB2_bit;
    14. sbit LCD_D5_Direction at TRISB1_bit;
    15. sbit LCD_D4_Direction at TRISB0_bit;
    16.  
    17. int x=0;
    18. float temp=0;
    19. char txt[12];
    20. void main() {
    21. lcd_init (); ADC_init ();   //analogue and digital converter
    22. lcd_cmd(_lcd_cursor_off);
    23. trisa.b0=1;
    24. porta.b0=0;
    25. trisd.b1=0;
    26. portd.b1=0;
    27. while (1) {
    28. x=ADC_read (0);  // 0 refers to the port number
    29. temp=x*0.489;
    30. floattostr (temp,txt);
    31. lcd_out (1,1,txt);
    32. if (temp<24) { portd.b0=0; }
    33. else { portd.b1=1;}
    34. } }
     
  2. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    How about posting your schematic too, it will reduce the guesswork...
     
  3. Afnan_123_

    Thread Starter New Member

    Feb 7, 2013
    22
    0
    i didn't work in hardware yet
    because i want to sure about the connection
     
  4. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    :confused:
    You setup hardware according to the schematic, not the other way around...

    You have some sort of oscillator connected to your PIC, right?
     
  5. Afnan_123_

    Thread Starter New Member

    Feb 7, 2013
    22
    0
    i didn't get u??
    what do u mean by sort of oscillator connected to PIC
     
  6. Afnan_123_

    Thread Starter New Member

    Feb 7, 2013
    22
    0
    just i did the connection in proteous and the code , i didn't do anything else

    but my confuse is no capacitor and resistor is connected
    should i use it in hardware?
     
  7. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    The PIC18f452 doesn't have an internal oscillator.
    You need to hook up something to create a clock source for your digital logic. Refer to pages 19-21 of the datasheet.

    Without one, your microcontroller won't do anything.
     
  8. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    If you are referring to making a RC oscillator in your PIC, as shown in Figure 2-3 on page 20, then yes.
     
  9. Afnan_123_

    Thread Starter New Member

    Feb 7, 2013
    22
    0
    but the pins 13 and 14 is OSC1 and OSC2
     
  10. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    Yes, that is the purpose of those pins.
     
  11. Afnan_123_

    Thread Starter New Member

    Feb 7, 2013
    22
    0
    but u r said The PIC18f452 doesn't have an internal oscillator.
    and pins 13 and 14 is OSC1 and OSC2
     
  12. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    Yes, yes I did. Again, read pages 19-21 of the datasheet. These pins are for connecting oscillators...


    If your circuit works in a simulation, why are you trying to add more parts?:confused:
     
  13. Afnan_123_

    Thread Starter New Member

    Feb 7, 2013
    22
    0
    because i am afraid it will not work in hardware:(
     
  14. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    It won't. That's what we are talking about.

    Beyond that, no one can comment because you haven't provided a description of the hardware connections you intend to make: a schematic...
     
  15. Afnan_123_

    Thread Starter New Member

    Feb 7, 2013
    22
    0
    when i start the hardware i will provide the connection
     
  16. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,392
    1,606
    What we've got here is failure to communicate.

    Afnan, the pins you use seem fine. You will need something external to the PIC to get it to oscillate as it has no internal oscillator: an RC is fine for many things. Do read the data sheet where tshuck mentioned to understand this critical item.

    Do make a schematic first, then follow it to build the hardware.

    Plan you work, then work your plan.
     
    tshuck likes this.
  17. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    How do you know what will be connected where to write the code??

    You need a schematic first, you probably drew one in Proteus to verify whatever you are doing is doing what you want it to, right?

    Print that schematic, take a screen shot of it and post it as an attachment.

    The OSC pins are for connecting the external oscillator components (RC or crystal), not for providing an oscillator to another microcontroller.
     
Loading...