Library 3-wire serial lcd using 74hc595 for CodevisionAvr

Go To Last Post
34 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi everybody,

 

I need Library 3-wire serial lcd using 74hc595 for CodevisionAvr I searched on Google, but not found 

 

Help me please 

 

Thank

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

Why don't you ask on the Codevision forum? They would be the best, however as you not providing any hardware information maybe no one can help.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

I have published a Codevision library for the popular I2C adapters.   (on this Forum)

 

I really can't see the point of using a 74HC595.   It needs more pins.   No one makes the adapters.   It would be expensive.

 

If you can show me that you actually possess an adapter for the 16x2,   I will write and publish the Codevision library.

Please post a link to the adapter on Ebay or similar.

 

All that I can find is http://www.ebay.co.uk/itm/Serial-UART-I2C-SPI-Adapter-for-1602-1604-2002-2004-4002-LCD-in-Arduino-AVR-PIC-/371649946300?hash=item56881022bc:g:B7UAAOSwImRYbCu1

And it is a lot more expensive than the I2C Adapters.

 

David.

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

david.prentice wrote:

I have published a Codevision library for the popular I2C adapters.   (on this Forum)

 

I really can't see the point of using a 74HC595.   It needs more pins.   No one makes the adapters.   It would be expensive.

 

If you can show me that you actually possess an adapter for the 16x2,   I will write and publish the Codevision library.

Please post a link to the adapter on Ebay or similar.

 

All that I can find is http://www.ebay.co.uk/itm/Serial-UART-I2C-SPI-Adapter-for-1602-1604-2002-2004-4002-LCD-in-Arduino-AVR-PIC-/371649946300?hash=item56881022bc:g:B7UAAOSwImRYbCu1

And it is a lot more expensive than the I2C Adapters.

 

David.

 

Hi thanks for the answer 

 

I using a typical LCD 4*20 i need more 2 i/o so i want drive LCD with 74HC595 This low-cost way for me  

 

If you help me I will be grateful

Last Edited: Sun. Feb 12, 2017 - 02:36 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

I have used this excellent adaptation of Peter Fleury's LCD library for I2C by Davide Gironi:

 

http://davidegironi.blogspot.com...

 

I had asked him about developing a multiple LCD version of his library which I believe he did....I will have to look for it.

 

david.prentice wrote:
I really can't see the point of using a 74HC595. It needs more pins. No one makes the adapters. It would be expensive

Agreed.

 

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: 1

@azadfalah,
Please post a photo or link to a real 74HC595 adapter.
I do not mind spending 30 minutes of my life writing "lcd_spi.h" for Codevision if helps more than one person.
.
If you provide a good reason, I would do it just for you. e.g. if you already have other SPI devices on a single SPI bus.
.
David.

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

You can find exactly what you want to do on this WEB PAGE Sorry, but your internet search skills are lacking. I typed "74hc595 c code example" to find the code in less than 3 minutes.

 

I took another look and you problem has been solved two years ago on this forum. https://www.avrfreaks.net/forum/s...

Last Edited: Sun. Feb 12, 2017 - 12:47 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Someguy22 wrote:
I took another look and you problem has been solved two years ago on this forum.

AVRfreaks reached critical mass some years ago -- every possible AVR issue has been raised, discussed, and consensus reached. ;)

 

OK, I suppose I have to add something on-topic.  In a couple apps we have gone the "serial backpack" route and added a small AVR at the display.  Then UART or UART+transceiver added for the distance.  Not as inexpensive as the shift-register approach but handles the "remote" problem.  In addition, that remote AVR can scan user buttons/keys associated with the display and handle associated I/O  (LEDs; buzzer; ...)

 

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

david.prentice wrote:
@azadfalah, Please post a photo or link to a real 74HC595 adapter. I do not mind spending 30 minutes of my life writing "lcd_spi.h" for Codevision if helps more than one person. . If you provide a good reason, I would do it just for you. e.g. if you already have other SPI devices on a single SPI bus. . David.
 

 

Thanks for the answer

 

The image of what I want

 

 

i want this Library for CodevisionAvr

 

Please guide me

Last Edited: Sun. Feb 12, 2017 - 08:26 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Are you serious?

 

Most people would wire:

Q0 RS

Q1 RW

Q2 EN

Q3

Q4 DB4

Q5 DB5

Q6 DB6

Q7 DB7

 

And use the ATmega8 SPI pins: SS, MOSI, SCK

 

I did ask for either a real-life hardware adapter or a "compelling reason". 

Is this just a Proteus exercise to use random pins? 

 

David.

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

azadfalah,

 

You want, you want, you want a specific library, for a specific circuit, for a specific compiler without doing the slightest bit of work on your own. It's clearly a school project most likely run on a pirated simulator. I posted two links to a partial solution. The code is all over the web. Sorry, I won't offer more help. You are on your own.

 

someguy22

Last Edited: Mon. Feb 13, 2017 - 03:16 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

BASCOM-AVR?.

Sigh.......

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

david.prentice wrote:

Are you serious?

 

Most people would wire:

Q0 RS

Q1 RW

Q2 EN

Q3

Q4 DB4

Q5 DB5

Q6 DB6

Q7 DB7

 

And use the ATmega8 SPI pins: SS, MOSI, SCK

 

I did ask for either a real-life hardware adapter or a "compelling reason". 

Is this just a Proteus exercise to use random pins? 

 

David.

 

David.

 

Well, I at first I wanted to  use 3 pin different from spi but now I realized more quickly spi 

 

 

How can I drive the LCD with ُSPI ?

 

Thanks,

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

Does it have to be SPI? Could you not use I2C?

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

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

Please give an honest answer.

 

Do you have a genuine product with a wrong pcb layout?

i.e. you just want to make a quick fix to existing hardware.

It happens.   It is a perfectly good reason.

 

Or do you just have a Proteus Simulation project?

 

When someone asks an interesting question or even a sob story,   they are likely to get a good response.

If you try to be secretive,   you will just get ignored.

 

Even if it is a school project,  people will happily answer specific questions.   Don't expect them to do your schoolwork for you.

 

David.

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

azadfalah wrote:
How can I drive the LCD with ُSPI ?

Obviously (I hope?)  the SPI is completely irrelevant to the LCD itself: the LCD itself neither knows nor cares anything about SPI - it is totally oblivious to SPI.

 

All the LCD sees is the signals at its pins - so your task is to replicate from the shift register exactly the same signals that the LCD would see if it were directly connected to your microcontroller.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:

Please give an honest answer.

 

Do you have a genuine product with a wrong pcb layout?

i.e. you just want to make a quick fix to existing hardware.

It happens.   It is a perfectly good reason.

 

Or do you just have a Proteus Simulation project?

 

When someone asks an interesting question or even a sob story,   they are likely to get a good response.

If you try to be secretive,   you will just get ignored.

 

Even if it is a school project,  people will happily answer specific questions.   Don't expect them to do your schoolwork for you.

 

David.

 

This is the Real project And production in large numbers

 

I use the i2c to communicate with RTC  and use Usart for other works

In my project i using Atmega64 but we should use Atmega32 and when i want use Atmega32 even though I used the IC latch for Increase I/O i need two PIN more ,

so i want Drive LCD with less PIN for free my two PIN ...

 

Low-cost way for me is Drive the LCD with SPI this way Free Four PIN and great

 

I am using the codevisionAVR ,

 

Sajjad,

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

azadfalah wrote:

I use the i2c to communicate with RTC...

 

So you could also use I2C to talk to your LCD.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

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

Brian Fairchild wrote:

azadfalah wrote:

I use the i2c to communicate with RTC...

 

So you could also use I2C to talk to your LCD.

 

Why do not you think the economy 74HC595 Cheap and abundant 

PCF8575 could not find in my country

Last Edited: Mon. Feb 13, 2017 - 11:33 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

The popular I2C adapters use PCF8574 or PCF8574A (8-bit expander).

The PCF8575 is a 16-bit expander.

 

Seriously,   sit down with a nice cup of tea.   Think about how to wire a 74HC595 e.g. as suggested in #10.

 

If you want to wire things differently,  please explain your reasons.

 

Incidentally,  the whole I2C adapter costs about $0.99 on Ebay.   Since you already have an active I2C bus,  an extra device does not need ANY extra pins.

 

David.

 

 

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

azadfalah wrote:
PCF8575 could not find in my country

 

Then if you do not want to buy the adapters on Ebay at a very reasonable cost compared to building these 'quantities' you need, take a look for the MCP23017.  THere is an Arduino library for it too from Adafruit.

 

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

A couple of left field suggestions:

 

1) use a 40 pin rather than a 28 pin AVR - you will get more than enough extra IO pins that way! I bet any cost up is no more than the cost of the 595 anyway.

 

2) What is actually on the whole of PORTC and PORTD of that mega8? You may find that some form of multiplexing (multiple buttons on a single ADC input for example) frees the additional IO lines you need for a direct connect. Your picture already shows there's just 6 active wires to the LCD and 3 to the 595 so it would seem you are only actually looking for 3 additional pins.

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

clawson wrote:
1) use a 40 pin rather than a 28 pin AVR - you will get more than enough extra IO pins that way! I bet any cost up is no more than the cost of the 595 anyway.

 

Yabbutt what does this mean:

azadfalah wrote:
In my project i using Atmega64 but we should use Atmega32 and when i want use Atmega32 even though I used the IC latch for Increase I/O i need two PIN more ,

 

 

So we have three different AVRs called out.  Pick a chip, any chip.

 

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: 1

Oh I see the (mega8) picture was just "generic" culled from Google Images was it?

 

If the problem is really finding 2 pins on a mega32 then surely to goodness there's got to be something there that can be multiplexed to free just 2 more pins?

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

We have no idea what the OP actually wants or needs.

 

Oh,  the software took 5 minutes to write.   By the time I have dug out a breadboard and 595 and wired it up,   I would have wasted 25 minutes of my life.

 

It is a no-brainer to add an I2C LCD to an existing bus.   Zero extra pins.

Adding a 595 to an existing SPI bus.   One extra pin.

 

If there were no existing buses,   I2C costs two pins.   SPI costs three pins.

Driving the LCD directly with its existing 4-bit interface only costs six pins in the first place!

 

As I understand,  the OP is migrating from a 64-pin mega64 to a 44-pin mega32.

Most apps would be happy with the GPIO from either chip.

 

David.

Last Edited: Mon. Feb 13, 2017 - 01:52 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I made a mistake I find  PCF8574 But twice the price of 595

 

I using the Atmega32  Because we should use dip package

 

david.prentice wrote:

 

If you want to wire things differently,  please explain your reasons.

 

David.

 

 

no, i dont want  wire things differently If you have the library  please help me

 

 

Thanks to friends

 

 

Last Edited: Mon. Feb 13, 2017 - 03:33 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

david.prentice wrote:
We have no idea what the OP actually wants or needs.

 

Just think, it took only 25 posts to get there! The OP can't even post the actual problem. The solution to this problem is all over the web. The boding; Ill.

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

azadfalah wrote:
i dont want wire things differently
Not even if it saves the cost of the 595 from the design? I suppose it depends whether you are making just one of this circuit or 10,000 units? If the latter then saving the cost of $0.50 chip from the design could be significant.

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

Someguy22 wrote:

david.prentice wrote:
We have no idea what the OP actually wants or needs.

 

Just think, it took only 25 posts to get there! The OP can't even post the actual problem. The solution to this problem is all over the web. The boding; Ill.

 

i want drive LCD with spi and don't Have any library for codevisionAVR 

 

It was obvious problem?

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

clawson wrote:

azadfalah wrote:
i dont want wire things differently
Not even if it saves the cost of the 595 from the design? I suppose it depends whether you are making just one of this circuit or 10,000 units? If the latter then saving the cost of $0.50 chip from the design could be significant.

 

Here I buy the more expensive Yes, nearly 10,000 units  And cost savings are significant

 

I think instead of posting
  I worked the library was now over.

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

azadfalah wrote:

i want drive LCD with spi and don't Have any library for codevisionAVR 

 

To be accurate you aren't looking for a library; when talking about compilers the word has a specific meaning. What you want is sample or example code.

 

As you are using an AVR, not matter what type, you can look at any code written for the Arduino. If I search on "lcd 595 spi" I very quickly find this page which does exactly what you want...

 

http://playground.arduino.cc/Mai...

 

It will take you about 10 minutes to make that work on your chosen chip.

 

 

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

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

azadfalah wrote:
Here I buy the more expensive Yes, nearly 10,000 units And cost savings are significant
Then why won't you explore the possibility of reducing the other mega32 pin usage so as to free enough pins for the LCD? As I read it you seem to be saying you are only 2 pins short. You may even find that your LCD pins could be doing "double duty". The LCD controller only really responds to data presented on D4..D7 when the E line is activated so, say you have some buttons in your design - perhaps a matrix? You might be able to use the same output lines that go to the LCD as the driven outputs to your key matrix too if the design is such that it can be either addressing the LCD or the buttons at any time but not both at the same time. Just don't drive the E line when you are outputting to the buttons.

 

And that's just one example - it'd be unusual in a 40 pin chip design not to be able to find at least a couple of pins that can do "double duty".

 

Perhaps you don't have a key matrix but just 4 buttons on individual inputs? If you could shuffle things round so that all 4 would connect to one ADC pin you can often use a switched resistor network to present different voltages depending on which button is pressed. However it's true that a possible complication is if you might expect to see more than one button pressed at once. However even that's do able. Conceptually have one button switch 0.5Vcc, one switch 0.25Vcc, one 0.125Vcc and so on. Now if you read 0.75Vcc you can be pretty sure it's buttons 1 and 2 that are pressed.

 

There are many ways to skin this cat!

 

If it could save $5000 from the production cost (10,000 74595's at $0.50 each) then it's got to be worth spending at least an hour studying how you might cut it from the design?

 

Or are you entrenched in the belief that the only way to gain the 2 pins you need is with a port expander?

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

@clawson

 

I checked all the issues  I realized that I have to Drive  LCD via SPI Now, by analyzing code arduino I will make a library

 

Thanks for your ideas

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

33 Posts only to be told:

azadfalah wrote:
I realized that I have to Drive LCD via SPI Now, by analyzing code arduino I will make a library

 

Where back in Post #7:

Someguy22 wrote:
You can find exactly what you want to do on this WEB PAGE Sorry, but your internet search skills are lacking. I typed "74hc595 c code example" to find the code in less than 3 minutes. I took another look and you problem has been solved two years ago on this forum. https://www.avrfreaks.net/forum/s...

 

 

angry

 

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