Shop OBEX P1 Docs P2 Docs Learn Events
connecting an lcd — Parallax Forums

connecting an lcd

LoridanLoridan Posts: 12
edited 2007-07-17 00:42 in Propeller 1
All,

I have a 4x40 character display that I would like to connect to my starter board. The logic supply VSS is rated -.3 to 7V and the drive supply is rated from -.3 to 13.5V. Is it ok to tie both these pins to the 5V supply, or do I need to place a current limiting resistor somewhere in this configuration to protect the prop?

Thanks in advance,
Dorian

Comments

  • PatMPatM Posts: 72
    edited 2007-07-12 02:05
    The ratings are min/max for not damaging the unit but don't necessarily reflect the voltages at which the unit will operate. Check the datasheet for the min and max operating voltage. I know the 4x20 LCDs I have won't work at 3.3v.

    The lcd drive will more than likely require a voltage divider to adjust the screen contrast. The units I have can go to something like 9 volts but good contrast is close to ground potential - anything over 1V makes the screen entirely black.

    edit: If you have a link to the datasheet, put it up. Much easier to give straight answers if the real data is available.


    Post Edited (PatM) : 7/12/2007 2:10:51 AM GMT
  • LoridanLoridan Posts: 12
    edited 2007-07-12 11:14
    Thank you for the response. I do plan on putting a 20k pot in the arrangement for the contrast as outlined in the datasheet. My main concern was that the lcd could pull too much current under certain circumstances and damage the power supply or even the prop chip on the board.
    Here is the spec sheet. Thanks,
    Dorian
  • JIRKJIRK Posts: 1
    edited 2007-07-12 12:42
    Datasheet shows, it's made for 5V. You need Pull-Up-Resistors for the data- and control-lines, connected to 3,3V. The backlight is to connect to 5V, too. Use Resistor 12R to 15R, 1206 (90mW to 135mW).

    Good luck!
    JIRK.
  • LoridanLoridan Posts: 12
    edited 2007-07-12 22:23
    Thank you very much for the help. I think now we are into the meat of my question. From other peoples example, and from what you are describing above it sounds like the output pins on the prop are incapable of supplying enough power for the inputs on the lcd, and therefor, you tie the pin to 3.3V with a pull up resistor and write a zero to the line to sink the voltage rather than source it, is that correct? I have done this type of configuration in the past using pic chips.

    If this is common knowledge and someone can please point me in the correct direction I would appreciate it. I had a PIC programming bible in the past and this sort of information was easily located, I cannot find anything of that nature for the prop...
  • HarleyHarley Posts: 997
    edited 2007-07-12 22:48
    Loridan,

    Have you read this thread HOW TO SAFELY INTERFACE A 5V SIGNAL TO THE PROPELLER? about half way down at the top of the Propeller forum in the blue section?

    That should provide most of the answers to your questions. Yes, there's lots to read and dig through.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Harley Shanko
    h.a.s. designn
  • LoridanLoridan Posts: 12
    edited 2007-07-12 23:41
    Harley,

    I did read that post, but it was centered on taking a 5V signal and bringing it into the prop safely. What I am wondering, is why I need to tie the input/control pins of this lcd to pull-up resistors rather than simply connecting them to the output pins of the prop chip. I understand that if the prop has a high state on the pin that the pull up resistor will faithfully add current to the control line. And when the output pin of the prop is low it what? Sinks the additional current from the pull-up resistor and hopefully drops the control line enough to be read as low?

    Again, I'm sorry if these are ignorant questions, and if there is a good source for this information please let me know.
  • AribaAriba Posts: 2,685
    edited 2007-07-13 00:53
    You don't need PullUp Resistors. The Datasheet says an LCD-Input needs minimal 2.2V for a High-Level. The Prop outputs near 3.3V for a High-Level - so no problem. But you need Serial-Resistors between the Prop and the D0..D7 pins of the LCD, because this Pins are 5V-Outputs when you read from the LCD (use 1k..10kOhm).
    Andy
  • LoridanLoridan Posts: 12
    edited 2007-07-13 00:59
    Ariba,

    That is how I read the data sheet as well. Thank you, for a moment there I was afraid that I had been away from electronics so long they changed the game. Thanks so much for your help.
  • Erik FriesenErik Friesen Posts: 1,071
    edited 2007-07-14 15:38
    I found with the ks0108 lcd drivers that it took a 470ohm resistor inline to properly drive the lcd.· Hooked up direct it would reset the screen somehow.
  • parts-man73parts-man73 Posts: 830
    edited 2007-07-15 04:27
    Ariba said...
    You don't need PullUp Resistors. The Datasheet says an LCD-Input needs minimal 2.2V for a High-Level. The Prop outputs near 3.3V for a High-Level - so no problem. But you need Serial-Resistors between the Prop and the D0..D7 pins of the LCD, because this Pins are 5V-Outputs when you read from the LCD (use 1k..10kOhm).

    Are there any objects currently that read from the LCD? I am using Dan Miller's object from the Propeller Object exchange. I made up a batch of circuit boards with no current limiting resistors. It works fine, but I don't believe this object does any reads from the LCD.

    Necessary? or better safe than sorry?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Brian Meade

    "They who dream by day are cognizant of many things which escape those who dream only by night" - Edgar Poe
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2007-07-15 07:05
    Just a quick comment regarding interfacing LCDs in general. I find it way easier to tie the R/W line low and never read from the display. This way you don't have any problems with interfacing to the Propeller. But how do you know when the lcd is ready you say? Easy, for all writes except the "clear display instruction" it takes 3 lcd clock cycles (37us max) which means you just need a simple delay loop between writes. Writes are very infrequent to these character LCDs by their very nature so simple delays do not impact on the operation of any CPU, especially if it's a Propeller.

    For the backlight I usually power it from an NPN or NCH so that I can turn it on or off or even pwm the brightness. This also means that the current limit resistor doesn't have to do all the work (dissipate heat) anymore as you have dropped the duty-cycle down from 100%. BTW, the backlight already has current limit resistors in place for operation from +5V but it doesn't hurt to allow for one externally. In some applications I have connected an NPN emitter follower up to the backlight through a small resistor and have been able to run this directly from +12V by simple duty-cycle control.

    The same goes for Vlcd contrast pin if you drive this from an I/O line via an RC combo you can take the contrast/viewing angle under software control. The voltage range needed usually won't be more than 1.3V (referenced to ground) at 70'C but if 0'C or less the voltage may need to go negative (not normally a worry).

    So, don't worry about any resistors for the data lines and it's totally safe and there's never a need to be sorry.


    *Peter*
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-07-15 09:12
    Peter,

    I like the thought of software controlled backlight a great deal.

    Can you share a schematic of these ideas? (My hardware need all the crutches I can get; NPN looks
    familiar but NCH went bye way too fast.)

    Fred
  • parts-man73parts-man73 Posts: 830
    edited 2007-07-15 19:13
    Fred Hawkins said...
    I like the thought of software controlled backlight a great deal.

    Can you share a schematic of these ideas? (My hardware need all the crutches I can get; NPN looks
    familiar but NCH went bye way too fast.)

    This is the circuit that I use.

    R1 is the current limiting resistor, I use a 4.7 ohm. For the transistor, I've always used a TIP41C.

    The input to the base of the transistor can be high or low to turn it on and off, or you can use PWM to dim the display.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Brian Meade

    "They who dream by day are cognizant of many things which escape those who dream only by night" - Edgar Poe
    411 x 502 - 21K
  • parts-man73parts-man73 Posts: 830
    edited 2007-07-15 23:53
    One other quick note. The peripheral board that I created for SpinStudio to control a parallel LCD uses outputs P9-P15 to control the LCD, as per Dan Miller's Object. Since each "Socket" on the SpinStudio Mainboard provides access to 8 I/O's, there is exactly 1 extra output that is used to control the backlight.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Brian Meade

    "They who dream by day are cognizant of many things which escape those who dream only by night" - Edgar Poe
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2007-07-16 02:06
    LCD BACKLIGHT
    The transistor for the backlight needn't be a monster as I have used BC337 (TO92) and BC317 (SOT-23). All that's important is that it can handle the current and it is saturated in that Vce is as low as possible thus limiting the power it needs to dissipate. Monsters such as the TIP41 can handle a lot more power but they also dissipate more power because of their lower gain. A 1K resistor into the base of a BC317 is sufficient to run the backlight (~200ma) and keep the transistor cool.

    NCH is just short-hand for N channel MOSFET which you can use in exactly the same way in this circuit although it operates quite differently. But the problem with MOSFETs is getting one with a low enough gate threshold (Vgt) to run off 3.3V.

    HOW MANY I/O DO YOU NEED?
    In regards to connecting LCDs just to show how little is required I once designed an ECU monitor that used a single 8-pin CPU which also drove a normal parallel LCD. How did I do it? Well, the CPU has 5 I/O and 1 input so I could connect 4 lines to the 4-bit data bus and 1 as the chip enable. That leaves the R/W and RS (or A0) but I don't have any outputs left! No problem, ground the R/W as that is practically redundant anyway and as RS only gets used occasionally I cheated and hooked up an RC to one of the data lines and into the RS. All I needed to do in software was precharge the RC to the state that I wanted for RS and then I would have 10's of microseconds to use the data lines before it would need refreshing again. Of course all the software had to do was precharge for 10 or so microseconds for each write access and then proceed as normal. The other input of the CPU was attached to the ECU and read in the pulse train and then displayed the results (I could have done this off a data line as well).

    This means if you wanted a serial LCD you could use an itty-bitty $1 micro or of course you could simply use 5 outputs from the Propeller. If I have I/O available I run the LCD in 8-bit mode but sometimes I'm squeezed and these are options.

    ABOUT SOFTWARE DRIVERS
    I notice a lot of software objects have multiple methods but I favor the streaming driver approach where it is treated as if it were an I/O device with a simple IN & OUT method. The OUT method handles the control codes etc and includes additional codes for backlight control etc. (The IN method is not really required for an LCD but my IN methods in general also accept a parameter that is treated as a command code (as opposed to data through OUT) so I use the command to access the driver rather than the device i.e. query a coms driver to see how much data it has in it's receive stream).

    *Peter*

    Correction: I mean BC817, not BC317
  • parts-man73parts-man73 Posts: 830
    edited 2007-07-16 03:38
    I agree that the TIP41C is definately overkill. I plan to make the next batch of these boards with a TO-92 type transistor.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Brian

    uController.com - home of SpinStudio
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-07-16 12:43
    Peter Jakacki said...
    ABOUT SOFTWARE DRIVERS
    I notice a lot of software objects have multiple methods but I favor the streaming driver approach where it is treated as if it were an I/O device with a simple IN & OUT method. The OUT method handles the control codes etc and includes additional codes for backlight control etc. (The IN method is not really required for an LCD but my IN methods in general also accept a parameter that is treated as a command code (as opposed to data through OUT) so I use the command to access the driver rather than the device i.e. query a coms driver to see how much data it has in it's receive stream).

    *Peter*

    Correction: I mean BC817, not BC317
    Nice discussion and I am glad that I asked.
    I do like the thought (but haven't done it yet to see if it ever pays off) of using the ram on the lcd to pass info from cog to cog.· So I won't rule out reading from an lcd.
    Here's an update version of Brian's schematic:
    530 x 502 - 50K
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2007-07-16 13:20
    Pass info from cog to cog via the LCD you say????? There are infinitely better and easier ways to do this Fred. Why wouldn't you use main memory?

    Accessing LCD data is very slow and I/O intensive and I would never do it even for display data as it is no problem at all on any micro to maintain a buffer in the micro's ram.

    Writing data to LCD RAM method
    set RS to 0 (command)
    set R/W to 0
    write RAM address to data lines
    wait (setup time)
    set CS
    wait wait wait
    release CS
    wait (hold time)
    set RS to 1 (data)
    write RAM data to data lines
    wait
    set CS
    wait wait wait
    release CS
    wait
    
    



    And that was only a single byte!!! skull.gif
    If the lcd only has 80 bytes of RAM all up for displaying characters then it doesn't leave a lot left over whereas the Prop's got 400 times that in main memory.

    Hope you've got an answer for me before I burn out my synapses trying to figure this one out although I'm guessing you would probably rule out lcd ram now roll.gif

    *Peter*
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-07-16 23:03
    Peter,

    Yeah, your're right. In my defense, I read datasheets and think, OK, maybe I can use that. But what I don't do is pay much (any) attention to timing details until too late, usually. Mostly because usec still don't mean much to me.

    Meanwhile, I bought some transistors and tried a test circuit (from www.kpsec.com/trancirc.htm). Which didn't work except when I put a finger on the base lead and my other hand grabbed a test pin stuck in the ground bar. Voila, the led lights... later after an appointment, I did a search on Mouser.com for the part number on the transistor. Alas, they are PNP's, all 15 of them. (They were the last pack of transistors at Radio Shack which sure has changed in the decades since I was there last. Learning about this stuff has suddenly developed an entirely new complication: where the hell to buy stuff retail in 2007)

    Swapped the hot and the ground on the test circuit and flipped the led, pushed the button and yup, it works even on the 3.3v power.

    Which suggests that the backlight would be on when the output from the propeller is low... not as nice as with the NPN in the preceding schematic.

    I did also wonder, do you use a whole cog just to run the backlight pwm or just set up a cntr? And if so, what does that code look like?

    Fred
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2007-07-17 00:42
    Hi Fred,

    Thanks for that.

    Using a PNP to +5V is ok for +5V circuits but the poor Prop will not be able to turn off the transistor as the minimum Vbe (ref to +5V) will be 5-3.3 = 1.7V which is way above the normal diode threshold of 0.6~0.7V. If the backlight does seem to turn off then you may find that the transistor is getting hot as it might be in it's linear region acting much more like a regulator than a switch. You can use a resistor divider but the Prop is effectively tied to +4.4V through a low value resistor, not something you should do.

    NPNs are cheap even if you buy them from Farnell (here in Oz) or Dick Smith etc. Where do you live?

    The pwm could in fact be in software if you dedicated a Prop to the LCD driver part (reads a buffer from main memory) but on the Prop this makes no sense as each cog has it's own counters. The frequency for the PWM is not really important and can in fact be very low, around 1KHz. Even though you could go lower and not sense any flicker it is important to limit the 'on' time if you were operating direct from a higher supply than +5V. I think there has been various examples of PWMing around you could glean from.

    Good luck.

    *Peter*
Sign In or Register to comment.