+ Post New Thread
Results 1 to 15 of 15
  1. #1
    Member level 2
    Points: 321, Level: 3

    Join Date
    Feb 2019
    Posts
    42
    Helped
    0 / 0
    Points
    321
    Level
    3

    Driving an LCD using ShiftRegister

    Hi, I am trying to control an LCD using a shift register. I am using the very successful arduino LiquidCrystal library which is tried and tested but am trying to modify the only function which differs. Instead of writing bytes directly to pins (like in the original function below) I am trying to output using a shift register (also as below). Its good to point out that I do not have d0 to d7 pins but instead a shift register connected to the LCD where d0 = bit 1, d1 = bit 2, .... d7 = bit 8

    As for rs, en and rw they are connected directly to the microcontroller so this is straight forward. LCD datasheet here

    so technically, if I want to write the value binary 00001011 to d0-d7, using the shift register I should be able to shift out the value decimal 11 however this is not working. Can anyone assist please?

    The original code as per github (the very last function scroll all the way down)
    Code:
    void LiquidCrystal::write8bits(uint8_t value) {
    	for (int i = 0; i < 8; i++) {
    		digitalWrite(_data_pins[i], (value >> i) & 0x01);
    	}
    
    	pulseEnable();
    }
    and my modified code
    Code:
    void LiquidCrystal::write8bits(uint8_t value) {
    	digitalWrite(_latch, LOW);
    	shiftOut(_data, _clock, LSBFIRST, value);
    	digitalWrite(_latch, HIGH);
    
    	pulseEnable();
    }

    Thanks

  2. #2
    Advanced Member level 5
    Points: 12,689, Level: 27
    Achievements:
    7 years registered

    Join Date
    Apr 2010
    Posts
    1,927
    Helped
    413 / 413
    Points
    12,689
    Level
    27

    Re: Driving an LCD using ShiftRegister

    is the 'fourbitmode ' is set as true or false?



    •   AltAdvertisement

        
       

  3. #3
    Member level 2
    Points: 321, Level: 3

    Join Date
    Feb 2019
    Posts
    42
    Helped
    0 / 0
    Points
    321
    Level
    3

    Re: Driving an LCD using ShiftRegister

    it is false yes just like the original source. it should technically be running as 8bit mode
    however the screen refuses to show anything



  4. #4
    Advanced Member level 5
    Points: 12,689, Level: 27
    Achievements:
    7 years registered

    Join Date
    Apr 2010
    Posts
    1,927
    Helped
    413 / 413
    Points
    12,689
    Level
    27

    Re: Driving an LCD using ShiftRegister

    For the LCd make sure that it is connected properly.
    are you able to see black boxes in one line upon reset?



  5. #5
    Super Moderator
    Points: 29,792, Level: 42
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    8,893
    Helped
    1125 / 1125
    Points
    29,792
    Level
    42
    Blog Entries
    9

    Re: Driving an LCD using ShiftRegister

    using the shift register I should be able to shift out the value decimal 11 however this is not working
    It is not clear whether this is not working in simulation environment (once above schematic seems like drawn on ISIS Proteus) or on assembled circuit. If you have the means to debug, why not just to see what apeears on the shift register?
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



  6. #6
    Member level 2
    Points: 321, Level: 3

    Join Date
    Feb 2019
    Posts
    42
    Helped
    0 / 0
    Points
    321
    Level
    3

    Re: Driving an LCD using ShiftRegister

    Hi actually its a fully assembled circuit and im debugging with no success

    - - - Updated - - -

    Quote Originally Posted by srizbf View Post
    For the LCd make sure that it is connected properly.
    are you able to see black boxes in one line upon reset?
    no just the backlight lights up



    •   AltAdvertisement

        
       

  7. #7
    Super Moderator
    Points: 261,317, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    45,654
    Helped
    13881 / 13881
    Points
    261,317
    Level
    100

    Re: Driving an LCD using ShiftRegister

    Why did you choose LSBFIRST? It doesn't seem right.



    •   AltAdvertisement

        
       

  8. #8
    Member level 2
    Points: 321, Level: 3

    Join Date
    Feb 2019
    Posts
    42
    Helped
    0 / 0
    Points
    321
    Level
    3

    Re: Driving an LCD using ShiftRegister

    To be fair I tried both MSB and LSB but to be fair im not sure



  9. #9
    Super Moderator
    Points: 29,792, Level: 42
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    8,893
    Helped
    1125 / 1125
    Points
    29,792
    Level
    42
    Blog Entries
    9

    Re: Driving an LCD using ShiftRegister

    im debugging with no success
    How are you debugging, step by step with break points? Anyway, define how did you came to the conclusion that it is not working, just by not seeing expected characters on LCD, or checking each command sent to the shift register during simulation?
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



  10. #10
    Member level 2
    Points: 321, Level: 3

    Join Date
    Feb 2019
    Posts
    42
    Helped
    0 / 0
    Points
    321
    Level
    3

    Re: Driving an LCD using ShiftRegister

    I am using VisualMicro which allows me to debug however that's as far as I can go without some ideas. I send simple text and no characters show up.

    - - - Updated - - -

    Here's a suspicion. Could the LCD be damaged if on VEE I supplied 5v? According to the datasheet, VEE should be from 0.3v up to 1.2v. But it says nothing about limits. As in the schematic I connected a trimpot to vary the voltage on VEE and I am certain that it was 5V at one point in time as I was turning it. It is currently set to exactly 1v.



  11. #11
    Super Moderator
    Points: 78,516, Level: 68
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    15,930
    Helped
    3610 / 3610
    Points
    78,516
    Level
    68

    Re: Driving an LCD using ShiftRegister

    Hi,

    VEE: post (a link to ) the datasheet.

    Klaus

    Added: I just recognized it's on pos#1.
    So, No, it should not get damaged with VEE = 5V.

    I agree, that the datasheet is not like a datasheet should be.
    I'm missing:
    * absolute maximum ratings
    * recommended operating conditions
    * timing diagrams
    ... and so on

    I personally like (and use) the Electronic Assembly parts, but the datasheets are really poor.

    Klaus
    Please donīt contact me via PM, because there is no time to respond to them. No friend requests. Thank you.



    •   AltAdvertisement

        
       

  12. #12
    Super Moderator
    Points: 261,317, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    45,654
    Helped
    13881 / 13881
    Points
    261,317
    Level
    100

    Re: Driving an LCD using ShiftRegister

    I agree, that the datasheet is not like a datasheet should be.
    The display module datasheet should be read together with controller ST7066 documentation which has all the missing information.

    I suggest to proceed with the suggestions given by andre_teprom. LCD controller interface is fully static, you can single step through the code and check the shift register operation as well as the correct output of each command byte.

    I guess 95% of failing LCD interface codes are due to misunderstanding the protocol requirements, e.g. command timing, soft versus hardware reset.



  13. #13
    Member level 2
    Points: 321, Level: 3

    Join Date
    Feb 2019
    Posts
    42
    Helped
    0 / 0
    Points
    321
    Level
    3

    Re: Driving an LCD using ShiftRegister

    Hi, Yes while I do agree that it is easy to misunderstand, I am using an existing library as in my first post and only changing the last 2 functions which instead of outputting bits directly to different pins, I am outputting bits to the shift register. I shall try to figure out a way to find out what the shift register is outputting.



  14. #14
    Advanced Member level 5
    Points: 12,689, Level: 27
    Achievements:
    7 years registered

    Join Date
    Apr 2010
    Posts
    1,927
    Helped
    413 / 413
    Points
    12,689
    Level
    27

    Re: Driving an LCD using ShiftRegister

    just backlights may mean the lcd is not initialised properly or it is not functioning.

    connect the LCD alone to pwr supply ,backlight and contrast setting pot without any i/p data and .control connections.

    Switch on LCD and adjust the pot to see the character boxes.

    If you are able to see it then you must check the serial2parallel block and up the line.

    If not replace LCD and see.


    1 members found this post helpful.

  15. #15
    Member level 2
    Points: 321, Level: 3

    Join Date
    Feb 2019
    Posts
    42
    Helped
    0 / 0
    Points
    321
    Level
    3

    Re: Driving an LCD using ShiftRegister

    Ok so clearly the LCD may be bust because I see nothing at all! :(

    - - - Updated - - -

    Quote Originally Posted by srizbf View Post
    just backlights may mean the lcd is not initialised properly or it is not functioning.

    connect the LCD alone to pwr supply ,backlight and contrast setting pot without any i/p data and .control connections.

    Switch on LCD and adjust the pot to see the character boxes.

    If you are able to see it then you must check the serial2parallel block and up the line.

    If not replace LCD and see.
    You were correct Sir! The LCD was bust! Thanks for the tip. It works like a charm



--[[ ]]--