Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : LCD schematic - pls explain open collecto
Page 1 of 2 | |||||
Author | Message | ||||
James_From_Canb Senior Member Joined: 19/06/2011 Location: AustraliaPosts: 265 |
I can see that connecting the control pins on the LCD directly to the Maximite output pins may not work because they are only 3.3V and the LCD board is designed for 5V. I understand that I could use a transistor to switch 5V to the LCD control pins. Fine so far. I just can't figure out how the "Open Collector Digital Output to 5V" works on the LCD schematic. If I configure pin 11 as Open Collector and set the pin value to high, doesn't that mean I'm allowing 5V to be grounded through the pin 11? So how does setting Pin 11 high make 5V flow from the power rail across the 10K resistor to pin 4 on the LCD circuit board? Or does grounding pin 4 on the LCD circuit work the same as applying power to it? That's not intuitive to a newbie like me. My mind is aglow with whirling, transient nodes of thought careening through a cosmic vapor of invention. Hedley Lamarr, Blazing Saddles (1974) |
||||
rhamer Senior Member Joined: 06/06/2011 Location: AustraliaPosts: 174 |
James, I have to go to work now, but if someone else doesnt answer before me, I'll answer it when I get there. Given you have also bought 2 of my expanders, you need to understand how the open collector option works with them as well. Cheers Rohan Rohan Hamer HAMFIELD Software & Hardware Solutions Makers of the Maximite Expander. http://www.hamfield.com.au |
||||
jebz Regular Member Joined: 13/06/2011 Location: AustraliaPosts: 79 |
Open collector is a nic feature as it allows you to translate from the controllers low positive supply level to a higher positive supply. You use a resistor from the peripheral positive supply to the controller output pin. When the controller has it's output as open collector and is in a high state it's like an open circuit on that pin so it's pulled to the higher voltage level through the resistor (say 5v). When the controller output goes low it shorts the end of the resistor to ground giving 0v. |
||||
rhamer Senior Member Joined: 06/06/2011 Location: AustraliaPosts: 174 |
The first place to look would be here http://en.wikipedia.org/wiki/Open_collector It has a good overview. The term "open collector" refers to the way an NPN transistor is wired. It is configured to work as a switch to ground and literally has nothing connected to the collector, hence the term open collector. This means that when the transistor is not being driven (more on that later) the collector (which is the output) is neither high (+V) or low (gnd). this is sometimes called high impedance state or tri-state. The basic wiring of a open collector is the drive (or control) is to the base via a current limiting resistor, the emitter is connected directly to ground and the collector is left open. Now with this kind of wiring, the output (collector) can only ever be switched low. This occurs when the base is switched high, the transistor current flows from the emitter to the base and at the same time “effectively” connects the collector to the emitter (ground) thus making the collector at (or very near) ground also. So how to you actually switch a load? Normally the load is wired between the collector and +V, so when the transistor is turned on the collector is pulled low and the load activates. This kind of output is useful if you want to connect several devices together on the same bus or single wire because the open collector can only ever be switched low and not high Another advantage of this scheme is the +V to drive the load can be different to the +v that drives the base of the transistor. So in the case of the Maximite, you can use +3.3v to turn on a +12V relay. Also the relay coil current only passes between the emitter and collector of the transistor, so you can drive higher current loads than what the Maximite could directly handle. It is also important to understand that you are effectively inverting the output state as well. When you drive the base high it pulls the collector low. Trap for young players: An open collector output will not show any sort of switching on a voltmeter without a load connected. If you want to see it just work, then place a pull up resistor between the collector and +V then you will see the collector alternate between almost ground and almost +V (don’t worry about the almost it will be close enough) So after all that we can see that an open collector output is capable of driving the collector low but not high, and relies on either the load or a pull-up resistor to pull the load high. Now with respect to my expander boards, the digital output circuit is essentially an open collector output with a pull-up resistor. This gives you the best of both worlds as you can remove the pull-up for true open collector or leave it in for digital high low switching. However note you need to loop the +v to each output of an appropriate voltage for the load you are driving (i.e +12V for a 12 V relay) Hopefully that makes some sense Cheers Rohan Rohan Hamer HAMFIELD Software & Hardware Solutions Makers of the Maximite Expander. http://www.hamfield.com.au |
||||
Keith @ Senior Member Joined: 19/06/2011 Location: AustraliaPosts: 167 |
Rohan Thanks for your short article ... It has saved me some time in research. I would like to confirm that with SETPIN(11),9 the PIN(11)=1 command turns the base of the open collector on with no load or connection between the external +V and the collector. Thus giving a digital low on chip pin 11 because it is connected internally in the PIC32 to ground. And that when a load is connected between the external +V and the open collector a current will flow using PIN(11)=1. This load can be anything within specifications such as a relay, LED, mosfet etc. When using SETPIN(11),8 the PIN(11)=1 command will not go via the internal PIC32 open collector and will present itself as a digital high on pin 11 of the chip. Thus giving the inverting digital high/low logic when using PIN(11)=1 or =0 when using digital output or open collector. Keith The more we know, the more we know we don't know ! |
||||
Keith @ Senior Member Joined: 19/06/2011 Location: AustraliaPosts: 167 |
Ooopps! sorry I read another article and I realise I should have said IDC pin 11 not chip pin 11 Keith The more we know, the more we know we don't know ! |
||||
stuarts Senior Member Joined: 15/06/2011 Location: AustraliaPosts: 199 |
Keith, when you do the setpin 11,9 to put the output in open collector mode, the pin(11)=1 will actually release the collector so that the pullup resistor can pull the line up to a 1 state. If you want to turn on a load (led, resistor, relay), you need to do a pin(11)=0. The sense of the command is at the output pin, not the base (actually gate in this case as it is a FET that is driving the pin. In summary, if you put a pullup resistor on the pin to 3.3v or 5v, you will get a 1 when you do a pin(11)=1 or a 0 if you do a pin(11)=0. Stuart Time is nature's way of keeping everything from happening all at once. |
||||
James_From_Canb Senior Member Joined: 19/06/2011 Location: AustraliaPosts: 265 |
Thank you all for your excellent replies. I truly appreciate it. Which leads to my next uninformed question. I apologise. Is the value of the current limiting resistor significant? Here's why I ask: I have a 10k resistor connected as per the diagram in LCD.PDF. It connects to the Maximite pin 13 and the Maximite's 5V output. I also have a 180 ohm resistor connected to an LED, then the Maximite's Ground. That should be enough load to cover Rohan's "Trap for young players", and show me it works. pin 13 -------+------180 ohm R------LED A(+) LED K(-)---- Maximite Ground ..................| ..................| ................100K R ..................| Maximite 5V-+ (edited: excuse the dots - spaces in front of the down pipe symbols were ignored) If I set pin(13) = 1 nothing happens. Oddly, if I remove the 180 Ohm resistor I get a faint glow from the LED, and it stops glowing if I set pin(13) = 0. This makes me wonder if the 10K current limiting resistor might be limiting the current too much. Question 2: Can I damage anything by experimenting and replacing the current limiting resistor with a much lower value one? Thanks again James My mind is aglow with whirling, transient nodes of thought careening through a cosmic vapor of invention. Hedley Lamarr, Blazing Saddles (1974) |
||||
Talbit Senior Member Joined: 07/06/2011 Location: AustraliaPosts: 210 |
I'm not sure how far you are with this but Geoff's schematic for the LCD display is wrong. Pin 13, 14, 15 ,16 should go to D4, D5, D6, D7. I posted this some time back and Geoff said he'd fix it but he hasn't so far. I've made up the circuit using the Jaycat QP-5516 using the Maximite 5V and it works fine. Talbit Talbit |
||||
James_From_Canb Senior Member Joined: 19/06/2011 Location: AustraliaPosts: 265 |
OK. Thanks for the heads up. That solved it. Sort of. There's a comment in the code with the correct pin connections, but I didn't cross-check it with the info on the schematic. I blissfully ignored it because I wasn't amending the code. I'm using a DSE Z4172 16x2 unit and I've now corrected the pin connections. When I run LCD.BAS, the screen displays one line of gibberish. And yes, I unzipped a fresh copy to make sure the gibberish wasn't caused by me changing the code. Over the last couple of days I've been trying to figure out why it doesn't work. I rewrote a bit of the code to use the initialisation sequence from the spec sheet that came with the unit. I've just tried running that code, and it displays perfectly. It seems the DSE Z4172 doesn't work with LCD.BAS, probably because of a difference in the way the unit is initialised. I'll try to figure out what the diffence is, and post the result. James My mind is aglow with whirling, transient nodes of thought careening through a cosmic vapor of invention. Hedley Lamarr, Blazing Saddles (1974) |
||||
Talbit Senior Member Joined: 07/06/2011 Location: AustraliaPosts: 210 |
Woops. It looks like Geoff corrected the code instead of the circuit. So the new code now matches the old circuit. Double check it anyway. Be very careful with pin numbers of these LCDs. The +V and ground can be the opposite way around. I'm in Canberra too. Do you want to chat on the land line. email me trevjan@bigpond.com and I'll give you my number. Talbit Talbit |
||||
Talbit Senior Member Joined: 07/06/2011 Location: AustraliaPosts: 210 |
Also, I needed to put a small delay (1 ms)in the original code just before you send the Hello World to the LCD. Not sure exactly where but it cured the jibberish. Talbit Talbit |
||||
Talbit Senior Member Joined: 07/06/2011 Location: AustraliaPosts: 210 |
Woops Woops!!! I don't know what's going on now re the code correction. I'm not sure if he changed anything. Yet me think about it over a cuppa. Freezing out in my shed. My son pinched my heater. Talbit Talbit |
||||
James_From_Canb Senior Member Joined: 19/06/2011 Location: AustraliaPosts: 265 |
Well, adding a short pause and connecting the pins to the LCD the way you described has made the original code work. Big tick! Thanks James My mind is aglow with whirling, transient nodes of thought careening through a cosmic vapor of invention. Hedley Lamarr, Blazing Saddles (1974) |
||||
Talbit Senior Member Joined: 07/06/2011 Location: AustraliaPosts: 210 |
Good news! Now, how can I refresh these post without logging in and out? Talbit Talbit |
||||
stuarts Senior Member Joined: 15/06/2011 Location: AustraliaPosts: 199 |
James, the reason why the LED doesn't glow or barely glows is that you have to remember that the open collector output can only sink current. It does this by pulling the line to GND. When it is at ground potential, the LED will be off as both ends are connected to ground. If you output a 1 then the output curcuits of the Maximite aren't driving the LED. The only thing that allows any current flow through the LED is the 100k resistor to the 5v rail. That value is way too large to allow significant current to flow. Assuming about a 2v drop across the LED, that leaves about 3v across the 100k and the 180R resistor. I=E/R comes up with about 30uA I'd get rid of the 100k resistor and then connect a 470R resistor and the LED between 5v and the pin. That will provide about 6mA which should be plenty to light the LED. Stuart Time is nature's way of keeping everything from happening all at once. |
||||
James_From_Canb Senior Member Joined: 19/06/2011 Location: AustraliaPosts: 265 |
I really must proof read my postings better before I click on "post reply". The body of my question said 10k, but my diagram has 100k. It's a 10k resistor, as specified on the LCD.PDF schematic. But even at 10k your formula shows it was too high to drive an LED. That's what I suspected might be the problem, but I wasn't sure what I could 'cook' if I put in too low a value resistor to check. I've connected it up as you suggested, and it works 100%. So a 10k resistor allows enough current to control an LCD screen, and therefore probably most other electronic gear, but not if it needs significant current, like driving an LED. Tick. Understood. Thanks again. James My mind is aglow with whirling, transient nodes of thought careening through a cosmic vapor of invention. Hedley Lamarr, Blazing Saddles (1974) |
||||
stuarts Senior Member Joined: 15/06/2011 Location: AustraliaPosts: 199 |
I'm using 22k resistors to 5v for my I2C and its working quite well, although looking at the waveforms I might go a little lower. Typically anywhere from about 2k up will provide a strong enough pullup to get a good risetime. It comes down to the amount of capacitance on the line that slows the risetime. To a large extent, this will depend on how long your wires from the maximite to the device you are driving are. Stuart Time is nature's way of keeping everything from happening all at once. |
||||
stuarts Senior Member Joined: 15/06/2011 Location: AustraliaPosts: 199 |
James, depending on what you are doing, it might make more sense to just use the straight digital output rather than open collector. Do you really need open collector for your application? Stuart Time is nature's way of keeping everything from happening all at once. |
||||
James_From_Canb Senior Member Joined: 19/06/2011 Location: AustraliaPosts: 265 |
Possibly not, but I was trying to set up the LCD connections as per the schematic. I intend to try lots of variations - and that's a lot easier if I'm starting from a known good setup. The good thing is that I now have a better understanding of what the Open Collector setting does. Many thanks for everyone's help. My mind is aglow with whirling, transient nodes of thought careening through a cosmic vapor of invention. Hedley Lamarr, Blazing Saddles (1974) |
||||
Page 1 of 2 |
Print this page |