PIC with LCD in Oshonsoft basic

Discussion in 'Programmer's Corner' started by camerart, Apr 17, 2014.

  1. camerart

    Thread Starter Active Member

    Feb 25, 2013
    517
    30
    Hi,

    I am trying to get a PIC to connect to an LCD module. I'm using Oshonsoft basic.

    I have attached a photo, showing my program, also one of the circuit. This works in the simulator, but not in circuit.

    I have a LED in the LOOP, and if I start with the LCD parts commented out, the LED flashes. If I work down the code commenting back in each element. When the 'Lcdinit' is commented in, then the LED doesn't flash.

    Are there any more ideas please.

    Cheers, Camerart.
     
  2. ericgibbs

    AAC Fanatic!

    Jan 29, 2010
    2,503
    380
    hi E,
    PORTA.4 pin#3 is Open Drain, add a 4k7 or 2k2 pull up to +5V.
    The Enable pin will never be pulled high without the pull up resistor

    Also remove that link on D0,1,2,3 and 0V link on the LCD.

    Eric
     
    Last edited: Apr 17, 2014
    camerart likes this.
  3. camerart

    Thread Starter Active Member

    Feb 25, 2013
    517
    30
    Hi Eric, 'Good to hear from you'

    I added the resistor and now the LED flashes in the Simulator and the circuit. I tried a logic probe on the 7 LCD pins, and they all seemed to be working as they should. Voltage at pin#3 when running 1.54V

    I don't understand the timing, but my ill informed guess is that the screen doesn't have time to write?

    Link on D0,1,2,3 and 0V removed

    I'm hoping that the LCD is not broken!

    Regards, 'Camerart'
     
  4. ericgibbs

    AAC Fanatic!

    Jan 29, 2010
    2,503
    380
    hi E,
    I would add a 10k contrast pot, one end to +5V the other end to 0V and the wiper to VO of the LCD.
    Adjust until you can just see the all the character pixel blocks on the LCD


    Also add a 10uF and 100nF cap from +5V to 0V on your project board, decoupling.
    Eric
     
  5. camerart

    Thread Starter Active Member

    Feb 25, 2013
    517
    30
    Hi Eric,

    I can now see a few lines of pixels on the second row, but no writing.

    C.
     
  6. ericgibbs

    AAC Fanatic!

    Jan 29, 2010
    2,503
    380
    hi E,
    Please post your complete Oshonsoft code and I will check it out.
    E
     
  7. camerart

    Thread Starter Active Member

    Feb 25, 2013
    517
    30
    Hi E,

    Code ( (Unknown Language)):
    1.  
    2. '16f684A xtl
    3.  
    4. Define CONF_WORD = 0x3f41  'XTL
    5. Define CLOCK_FREQUENCY = 4  'Changed from 12
    6. AllDigital
    7.  
    8. 'Define SIMULATION_WAITMS_VALUE = 1  'SIMULATION ONLY
    9.  
    10. Define LCD_BITS = 4
    11. Define LCD_DREG = PORTB
    12. Define LCD_DBIT = 4
    13. Define LCD_RSREG = PORTA
    14. Define LCD_RSBIT = 2
    15. Define LCD_RWREG = PORTA
    16. Define LCD_RWBIT = 3
    17. Define LCD_EREG = PORTA
    18. Define LCD_EBIT = 4
    19. Define LCD_READ_BUSY_FLAG = 0
    20. Lcdinit
    21.  
    22. loop:
    23.     Lcdcmdout LcdClear
    24.     Lcdout "WORKING!?"
    25.     Lcdcmdout LcdLine2Home
    26.     Lcdout "TEST"
    27.     Toggle RA1
    28.         WaitMs 1000
    29. Goto loop
    30.  

    Cheers, Camerart.
     
    Last edited by a moderator: Apr 18, 2014
  8. ericgibbs

    AAC Fanatic!

    Jan 29, 2010
    2,503
    380
    Hi E,
    It runs fine in simulation.
    I see on your code list at the top it says,,, 16F684A......... its a 16F648A, I guess thats a typo.?

    I will relook at your photo of the project board, see if there are anymore problems.

    E

    EDIT:
    Top wiring on the PCB board checks out OK against the diagram and program.

    Can you post a photo of the underside of the PCB, check for copper whiskers.??
     
    Last edited: Apr 17, 2014
  9. camerart

    Thread Starter Active Member

    Feb 25, 2013
    517
    30
    Hi E,

    I changed from 16F819 to 16F648A as I won't need any analogue, so it not a typo.

    I'll double check the board tomorrow for whiskers.

    Cheers, C
     
  10. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    Where's the code for your LCD initialisation routine?
     
  11. camerart

    Thread Starter Active Member

    Feb 25, 2013
    517
    30
    Is it not in #7
     
  12. jjw

    Member

    Dec 24, 2013
    173
    31
    It is inbuilt function in Oshonsoft Basic.
     
  13. camerart

    Thread Starter Active Member

    Feb 25, 2013
    517
    30
    I don't know where it is, I'll look.

    But read the next posting.
     
  14. camerart

    Thread Starter Active Member

    Feb 25, 2013
    517
    30
    Hi Eric,

    Today I did a continuity test between each pin and all the rest. I found PIN1 connected to +V.

    The power connection at the bottom of the board, has a link across the board, making two +v lines of copper. I've cut the offending one, and now the board works:mad:

    Thanks for all the help, Camerart.
     
    ErnieM likes this.
  15. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    Yes it was;
    Lcdinit

    Sorry that was my fault, I missed it. :) Probably because it looked like part of your #defines.

    Do the Basic inbuilt LCD functions check the busy flag? If not, there needs to be the correct sized delays in the code for certain commands and some compilers will not use the correct delays unless you have specced the xtal speed properly (I noticed you changed it from 12 to 4?).
     
  16. jjw

    Member

    Dec 24, 2013
    173
    31
    The program can either use the busy flag or the delays which can be set freely or use the default values.
     
  17. camerart

    Thread Starter Active Member

    Feb 25, 2013
    517
    30
    I don't know about LCD functions.

    I changed the XTL to 4MHz because I have them. I'll change later.

    Did you see the 19 April posting? The LCD is working! Now it's working, I will 'play' with it and look at timings etc.
     
  18. camerart

    Thread Starter Active Member

    Feb 25, 2013
    517
    30
    Is it set in the best way now?
     
  19. ericgibbs

    AAC Fanatic!

    Jan 29, 2010
    2,503
    380
    hi E,
    Use the LCD Busy flag if you have the pin to spare, using delays will always mean that LCD subroutines will run slower.

    Also in a 16F PIC you have only a 8 deep Stack, Oshonsoft LCD delays hog the Stack, so any other Gosubs your program uses could generate Stack overflow errors.

    E
     
  20. camerart

    Thread Starter Active Member

    Feb 25, 2013
    517
    30
    Hi E,

    As I have the r/w pin connected, reading the 'HELP' as if it should be set to 1? I'll leave it like that for now. I have 1 pin spare!

    As I'm at stage one, before I go to far down the track, do you think I have to make the giant leap to a larger PIC or step up to 18 series? I was hoping to stay as I am. If need be, I can connect two PICs together.

    Using 16 PICs, to work on the program. I will be working with lists of data, where the program compares data with data. I will need some kind of way of seeing the results. Is the LCD module in Oshonsoft best for this?

    Regards C.
     
Loading...