HC595 to LCD 8-bit mode interface

Go To Last Post
59 posts / 0 new

Pages

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No, poked in the eye this time with replacement a plastic bit..just like the million dollar man but cheaper.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

js wrote:
You must be bored like me. wink

No jobs that pay decent on the desk so I have some time sadly.

 

I actually started thinking about how we did it at the alarm company back in the 80's and wanted to see if I could remember the signal lines and the protocol.  I am 90% sure we used 4 lines as I can remember the waveforms on the scope screens like it was yesterday......now where are my glasses? cool

 

Question I ask myself is should I bother?  The 10 pieces I bought were less than $4.00 so I am not out anything other than a cup of overpriced coffee.  It might be an accomplishment to write a driver as a self teach to finally learn how to use CodeVision for a project as I paid for the license, but only use it for configurations.

 

Why bother when I have a bunch of I2C LCD backpacks I had made using the PCF8754 which work great with Davide Gironi's adaptation of Peter Fleury's code and you only need TWO lines?  Not four like the '595 needs.

 

I shall debate this while on line getting a $2.00 cup of tea...wink

 

Meh...

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You buy your $2 cup of tea online? Does it arrive hot?

 

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

valusoft wrote:

You buy your $2 cup of tea online? Does it arrive hot?

 

As long as I don't order it FedEx!

 

Not going to hijack the OP's thread.

 

JIm

 

EDIT:  Just figured out the tongue in cheek you were insinuating Ross!  Good one

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

Last Edited: Thu. Mar 9, 2017 - 01:42 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
This seems a rather pointless exercise: 1. 3 pins for RS, RW, EN and 3 pins for HC595_SH_CP_POS, HC595_ST_CP_POS, HC595_DS_POS 2. a regular 4-bit LCD library only uses 6 pins (if you are write-only)
jgmdesign wrote:
Sat down to write this out and Realised that using the '595 is a huge waste of time!
clawson wrote:
Apart from the point David made ("why bother?")
Sooner or later the message will get through. Exactly what point is there in putting a 595 into this?

 

But if one is going to attempt it then I would take a lot of notice of:

Kartman wrote:
The assumption is that there is only one problem - there are probably many.

Which is why I said:

clawson wrote:
Just start by wiring an HD44780 direct to the AVR. Again I'm not sure why anyone would choose to use 8bit when 4bit is just fine but most existing libraries will support both 4 or 8 so wire it with either. Meanwhile in a separate project work on the 595 stuff. Just ensure that you can light any combination of LEDs (say) on the output pins. Finally put the two "proven" pieces of work together.
The way to find the faults in a complex system is to break it down into easily manageable/testable parts and ensure each small part is working OK. When you have proven each small part THEN put them together to build the larger/complex system.

If you hang the HD44780 directly off the 595 in step 1 and the whole thing "does not work" you have no idea whether it is in the HD44780 part of the 595 part or, worse yet. BOTH where the problems are located.

 

So develop each in turn separately and only put the "building blocks" together when each part is proven.

 

As I've said you can start by getting an LCD connected directly to the AVR to work. The "output" of that module is simply code that "wiggles" 4/8 data bits and 2/3 control signals. Later you can move the generation of those signals from direct port pin usage e.g. PORTB |= (1 << LCD_RW) to Shift_595_setoutput_bit(LCD_RW) or whatever.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have not been following this thread recently.

 

From the code in #17 the idea could work but it is complicated.

Looking at your photo in #40,  it seems that this is a home-made project.

 

You have only got to use 6 GPIO pins to drive the LCD.   Codevision has already got < alcd.h> library and a GUI to configure it.

 

Incidentally,   I wrote a Codevision library when your colleague first suggested a HC595.   And I made a plug-in Adapter for the LCD.

My library uses 3 pins and the SPI bus.   The I2C version uses 2 pins and the I2C bus.   The bit-banged I2C version uses any pins.

 

I can not see any advantage in HC595 via SPI over PCF8574 via I2C.   3 pins against 2 pins.

Your method is quite possible but uses an awful lot of pins.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
My library uses 3 pins and the SPI bus.

Theres an Arduino example that also does this.  From what I saw it would appear that for each nibble you need to send three transactions with the E line control connected to the 595.  Send nibble with E line low to set up the data outputs, send the same nibble but with the E bit high, send the same nibble a third time with E bit low.  Lot of traffic.

 

Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes,  it is exactly the same as the PCF8574.   You simply wiggle the bits on the Port Expander.   It is 5 states per transaction.

Remember that I have a 4-bit data bus.

uint8_t IFACE_WRITESEQ(uint8_t slave, uint8_t *seq, uint8_t n)
{
    uint8_t i, ret = 0;
    for (i = 0; i < n; i++) {  // 5 states @ 1MHz = 40us
        HC595_CSLO;
        spi(seq[i]);
        HC595_CSHI;
    }
    delay_us(40);
    return ret;
}

bit-bash I2C:

uint8_t IFACE_WRITESEQ(uint8_t slave, uint8_t *seq, uint8_t n)
{
    uint8_t ret = 1;
    if (i2c_start() && i2c_write(slave << 1)) {
        uint8_t i;
        for (i = 0; i < n; i++)
            i2c_write(seq[i]);
        ret = 0;
    }
    i2c_stop();
    return ret;
}

and TWI:

#define IFACE_WRITESEQ(slave, buf, n)  twi_master_trans(slave, buf, n, 0, 0)

You can see that the TWI version is a lot simpler.

And the sequence is not difficult either:

    seq[0] = mode;                      // EN=0, RW=0, RS=mode
    seq[1] = (c & 0xF0) | mode | 4;     // EN=1, RW=0, RS=mode
    seq[2] = seq[1] & ~4;               // EN=0, RW=0, RS=mode
    seq[3] = (c << 4) | mode | 4;       // EN=1, RW=0, RS=mode
    seq[4] = seq[3] & ~4;               // EN=0, RW=0, RS=mode

Of course,  the OP's method of an 8-bit data bus on the Expander with the 3 separate control lines is simple to program but eats an awful lot of GPIO pins.

 

David.

Last Edited: Thu. Mar 9, 2017 - 03:53 PM

Pages