1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

PIC with 48x84 LCD screen

Discussion in 'Oshonsoft' started by camerart, Mar 12, 2017.

  1. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,318
    Likes:
    11
    Location:
    Dorset UK.
    Hi E,
    Played with a few changes in the LOOP, but got odd results. i,e 0x00 produces lines all the way down the screen.

    I'm now following this program, by Chris Holden as a guide.
    C.
     

    Attached Files:

  2. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,185
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi C,
    I am sorry to keep dripping like at tap...:(, but I do really want to help.
    The Holden program is written to suit a bigger PIC than the 18LF2520, it will require extensive changes to make it work.
    It is not using SPI commands, but Bit commands.

    May I ask why, after fixing the PIC, SPI to 5110 are you changing to a totally different method.?

    E
     
  3. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,318
    Likes:
    11
    Location:
    Dorset UK.
    Hi E,
    I'm not changing from SPI, only using it as a guide, as I understand that the 5110 needs libraries for the text.
    CORRECTION: In #101 I said 0x00 produces lines. I should have said 0x00 pixels all off, 0xff pixels all on and 0x01 lines all down the screen.
    C.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,185
    Likes:
    644
    Location:
    Ex Yorks' Hants UK

    hi C,
    This bit of code sets the LCD write direction [left to right across the screen]
    BTW: the text code ASCII table in the Holden file is the same as the Video, but Holden starts at 'A' not like the Video, which is: Space followed by the maths symbols, then the ASCII chars.

    I should have said 0x00 pixels all off, 0xff pixels all on and 0x01 lines all down the screen

    Which is correct.

    E
    lcdxy:
    SPICSOn
    SPISend 0x80
    WaitUs 100
    SPISend 0x40
    SPICSOff
    WaitMs 1
    Return
     
  6. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,318
    Likes:
    11
    Location:
    Dorset UK.
    Hi E,
    You're much quicker than I am, I will have to play and read a bit longer for me to figure out what's going on.
    C.
     
  7. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,318
    Likes:
    11
    Location:
    Dorset UK.
    Hi
    I tried playing this morning, but the module stopped working so I went back to #96 and this didn't work till I added:
    SPICSOn
    SPISend 0x55
    SPICSOff
    WaitUs 1
    SPICSOn
    SPISend 0xaa
    SPICSOff
    C.
     
  8. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,185
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi C,
    Not a problem, I am working out a LCD Font that we can use with Oshonsoft Basic.
    It looks OK in simulation, let me know when you would like to try writing text to the lcd.
    E

    EDIT
    : this should work OK.
    SPICSOn
    SPISend 0x55
    SPISend 0xaa
    SPICSOff

    EDIT2:
    Your posted 5110 has just arrived in good condition. :woot:
     
    Last edited: Oct 12, 2017
  9. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,318
    Likes:
    11
    Location:
    Dorset UK.
    Morning E,
    I'm happy to try any time, at the moment, I'm trying to understand how it works.
    Hopefully, next I will add a barometer module also SPI, as an altimeter, so hopefully the 5110 will give the results.
    C.
     
  10. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,185
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi C,
    Got the 5110 lcd working OK with a 18F4520, displaying ASCII characters.
    At the moment I have only have the 'A thru G' ASCII fonts in the font table, it just a chore adding the remainder of the alphanumeric set.
    I need to tweak the Contrast setting later.
    E
     
  11. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,318
    Likes:
    11
    Location:
    Dorset UK.
    Hi E,
    If you post the program, I can add the remaining digits etc
    C.
     
  12. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,185
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi,
    I will post the program later, managed to improve the Contrast.
    Got a decent picture of the displaying LCD, but for some reason I cannot transfer files to my PC, very annoying.
    It displays '0123ABCDEFG' top left line.
    E

    EDIT:
    Is was the USB cable adaptor
    5110Font1.jpg
     
    Last edited: Oct 12, 2017
  13. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,185
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi C,
    This is the latest version of the program , I have added some comments to help you follow the code.
    I would suggest you try adding to and modifying this diagnostic program and use the modified program for the work we will do together.
    Once you are satisfied, try it within your main project program
    E
     

    Attached Files:

  14. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,318
    Likes:
    11
    Location:
    Dorset UK.
    Hi E,
    It looks really neat. I'll have a better look tomorrow.
    Thanks,
    C.
     
  15. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,318
    Likes:
    11
    Location:
    Dorset UK.
    Hi E,
    Here's the amended program:
    I hope I've done it correctly.
    C
     

    Attached Files:

  16. camerart

    camerart Active Member

    Joined:
    Jun 12, 2008
    Messages:
    1,318
    Likes:
    11
    Location:
    Dorset UK.
    EDIT:Not sure the SPICSOff is the problem, as I am still getting intermittent working??
     
  17. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,185
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi C,
    I have been writing to the lcd with that basic program most of the day with no problems at all.
    Adding lcd line selection, line start position etc, all working fine.
    Next step is to use an analog port and display ADC data.

    You seem to have a intermittent fault on your hardware.
    E
    Give it a try, displays 0 to 9 and DP on all 6 lines of the lcd.
     

    Attached Files:

  18. jjw

    jjw Member

    Joined:
    Apr 16, 2012
    Messages:
    261
    Likes:
    15
    Location:
    Helsinki, Finland
    ONLINE
    One thing I noticed: strings start at position 1, not 0.
     
  19. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,185
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    hi jjw,
    So did I, will try to figure out why tomorrow.
    E
    Do you also see those two left side pixels at 0x80 and 0x40.??
    I figure the DC level needs checking [later]

    main:
    'data write to LCD block, specify required positions of X and Y

    Gosub lcdxy 'set lcd write at top left of screen

    wr2lcd:
    'write some data pattern
     
    Last edited: Oct 13, 2017
  20. jjw

    jjw Member

    Joined:
    Apr 16, 2012
    Messages:
    261
    Likes:
    15
    Location:
    Helsinki, Finland
    ONLINE
    lcdxy should be executed in command mode.
    Now it displays the dots 0x80, 0x40
    Add lcd_data_command=0 to lcdxy
     
    Last edited: Oct 13, 2017
  21. ericgibbs

    ericgibbs Well-Known Member Most Helpful Member

    Joined:
    Jan 4, 2007
    Messages:
    21,185
    Likes:
    644
    Location:
    Ex Yorks' Hants UK
    Thanks, but I have already done that,ref post #118.;)
    E

    jjw
    camerart
    EDIT:
    NOTE: Oshonsoft MidStr will read the double quote at the start of the string, if the pointer starts at 0 [zero].
    The LEN will return the length of the string not counting the quotes.

    This was the reason I was getting a space at the start of my displayed lcd string.

    Example:
    menu1 = "0123456789ABCD"


    'gets each ASCII char in turn and writes it to lcd
    msg2lcd:
    Gosub lcdxy
    lcd_data_command = 1 'data
    y = Len(msg1)
    For x = 1 To y ' using a for 0 to y, will get the double quotes and the full string.
    ascval = MidStr(msg1, x, 1)
    Gosub chr2lcd
    Next x
    Return
     
    Last edited: Oct 14, 2017

Share This Page