Closed GoogleCodeExporter closed 8 years ago
Hi, that was a nice solution, thanks! (sorry for the late reply).
In fact I just tried it. I just threw in a one-transistor inverter as suggested
(BC548B, 10k to Vcc, 1k to base from clock input), and it worked like a charm!
:)
And btw I did make this lib with the 74xx164 in mind at the time.
Original comment by raron...@gmail.com
on 31 Jan 2012 at 12:49
There is a simpler/better solution.
You can eliminate the transistor and resistors by connecting RCLK to SRCLK.
However, when you do this, as noted, the output stage is always 1 clock/shift
behind.
To compensate for this you can simply re-wire everything off set by one bit
lower.
So you wire it up like this:
QB - RS
QC - D4
QD - D5
QE - D6
QF - D7
QG - E
While the output bit wiring is different than the ls164 the actual bits used
within the 8 bit by byte transferred are the same so there is no impact on the
software.
The real bit 0 is stuck inside the shift register and the previous byte bit 0
is bit 7 on the latch output.
This doesn't matter because once the wires are shifted down one bit, neither
the stuck bit 0 or
bit 7 of the output latch are needed.
(The current byte bit 7 will be on bit 6 of the output latch)
It is a bit confusing to look at but re-wiring it on bit shifted
will eliminate the need for the transistor and make the 595 work basically the
same as the 164.
This is what I'm using on my 74HC595 based setup.
--- bill
Original comment by bperry...@gmail.com
on 6 Feb 2012 at 7:33
Re Bill's comment - you say that can eliminate the transistor and resistors but
can you also eliminate the diode?
Original comment by comer.edward
on 6 Feb 2012 at 10:37
Sorry if I was a bit confusing.
Start with the 2 wire latched shift register schematic with the 595.
The resistors that go away are R2 and R3 along with the transistor.
R1 and the diode stay as before.
RCK connects to SCK.
The outputs on the 595 are connected offset by one bit as above.
--- bill
Original comment by bperry...@gmail.com
on 6 Feb 2012 at 11:58
Hehe..
Cute solution to rewire one bit lower and eliminate the inverter :)
Good job man
Original comment by Love.Nystrom
on 7 Feb 2012 at 3:36
Bill: Heh, that was a nice one also! Thanks for posting!
Original comment by raron...@gmail.com
on 7 Feb 2012 at 7:08
I have been successful using a 74HC595 with the 3-wire method but I have been
unable to get either of the 74HC595 2-wire methods working, version 1 or 2. I
have triple and quadruple checked my breadboard circuits against the schematics
at arduinoshiftreglcd and they are correct. I even went back and rebuilt the
3-wire version just to make sure that it was still working, and it was. I know
that some of you have gotten the 2-wire versions working BUT do the schematics
at arduinoshiftreglcd match what you have working??
This is driving me nuts. I really want to use the 2-wire circuit for a a
ATtiny85 project where I NEED the pins for other tasks.
Original comment by comer.edward
on 10 Feb 2012 at 10:16
corner.edward:
I've found the type of diode used can make a big difference (as well as the
resistance of the resistor, and probably lots of other things too, like type of
LCD, type of IC, etc. Noisy power?). Did you use a 1N4148 or equivalent? IE no
rectifier diodes or similar (I made that mistake). Have you decoupled the power
near the HC595 with say 100nF cap (from Vcc to GND)?
And yes I made both methods work recently when testing on my 20x2 line LCD, and
74HC595.
If you're really stressed for output pins, I've just put together a 1-wire (as
well as 2 and 3-wire) library compatible with this, link on front page (in the
process of putting up the page, so not done just yet). 1-wire method is pretty
slow though, 2- and 3-wire is the fastest. But the new library is a bit bigger,
so if space is a concern, it might be just as well to stick to this.
Original comment by raron...@gmail.com
on 10 Feb 2012 at 10:51
The only signal diodes that I have on hand are 1N4001. I'll admit that when I
metered these diodes what I saw concerned me. Infinite resistance with reverse
biad (as expected) but almost 1k ohms forward bias resistance. This seemed
wrong to me 1K ohms forward biased?
Original comment by comer.edward
on 11 Feb 2012 at 12:02
corner.edward:
You don't measure "forward resistance" of a diode with an ohm-meter /
multimeter, if I understood you correctly (the result would vary with the
voltage used by the ohm meter to measure it - they are non-linear). But the
diode seems to work from what you write.
Still - try another type of diode if you can find. Or, alternatively, if you
have a 74LS type IC (like 74LS164 or 74LS595), you could try that with your
diode.
Or what about using a small-signal transistor base-emitter as a diode? (Leaving
collector unconnected - I haven't tried that one though).
Well those are my only suggestions at the moment..
Original comment by raron...@gmail.com
on 11 Feb 2012 at 1:17
I used the emitter/base of a 2N3904 NPN transistor as the diode and TWO_WIRE
worked. I have ordered some 1N4148 diodes but I am concerned at how sensitive
this pseudo AND Gate is and wonder if will be a reliable solution with the
"pick of the litter" of parts, even if they are 1N4148. I am really surprised
that a plain vanilla 1N4001 will not work.
Original comment by comer.edward
on 11 Feb 2012 at 4:38
corner.edward:
Glad to hear it worked!
Regarding diodes that don't, I'm surprised by that as well. I used yet another
one in the beginning and it would only work with 74LS-type IC's. Hence my
suggestion about that. I'm not really sure why that is, the specs don't seem so
different at these small currents at 5 mA or so. They seem to have about the
same Vf of 0.7V.
Only "big" difference I see, at a glance just now, is the reverse biased
capacitance, around 15pF for 1N4001 versus 0.85 pF for 1N4148 at 4-5 volts. The
2N3904 is listed as having just below 3 pF emitter-base reverse biased
capacitanse at around 5V, and the diode I used before (BYV95), had 10 pF,
according to specs.
I'm not sure if this is the cause though. The capacitance seem so insignificant
- then again input impedance of the LCD Enable might be very high? (This
suggests a couple of experiments...).
And of course you could also use a real AND gate...
Original comment by raron...@gmail.com
on 11 Feb 2012 at 8:09
Raron - regarding the capacitance, I think that you are on to something. At
website http://www.rentron.com/Myke1.htm the author uses a 1N914 diode, which
has a junction capacitance of 4pf. So, 1N914 is another diode that should work.
Also, thake a look at http://www.romanblack.com/shift1.htm where the author
shows a 1-wire shift register LCD control using pulse width and capacitors.
Original comment by comer.edward
on 11 Feb 2012 at 5:08
More on the 1-wire protocol: see
http://www.3guys1laser.com/arduino-one-wire-shift-register-prototype
Original comment by comer.edward
on 11 Feb 2012 at 5:32
comer.edward:
(Oops, I misspelled your name all along, didn't notice that until now).
I have a datasheet that says "For 1N4148 see 1N914", but it didn't state the
junction capacitance. I have other datasheets for 1N4148 that does. I guess
they are not really that equivalent after all then, 4pF vs 0.85pF. But as you
say, it should still work, that's good to know.
As for 1-wire, I did base mine on the Shift1 system that you link to (I wrote
that both in code and on the page, but the new page is a pretty messy wall of
text and right now).
I haven't seen the last link yet though, will have a look later. Thanks!
Original comment by raron...@gmail.com
on 11 Feb 2012 at 8:56
Still using my NPN transistor as a diode while I wait for my order to arrive
but I have now got this 2-wire circuit working in an ATtiny85 chip! The binary
is 2,008 bytes which gives me 6k left for the rest of my code. Raron - thank
you for your help and thanks to the others who contributed designs and posts -
I am a happy camper.
Original comment by comer.edward
on 12 Feb 2012 at 12:22
comer.edward:
You're welcome!
FYI, I did some further experimenting. My old 1-line LCD actually worked with
BYV95 and 74HC595, whereas my newer 20x2 LCD's don't work with that diode.
See the attached schematics for reference (Except I used 74HC595 and Bill's
method above).
Using the 20x2 LCD's with BYV95. If I change the resistor R2 to 220 ohm, then
load LCD Enable with R4 = 1k, and also load the shift register output with R3 =
220 ohms, it worked. I could not change any resistor much though, before the
LCD got garbled again. Nor could I add another 5 pF over the diode :p
With the original diode (1N4148) and resistor R2 = 1k, I could add 5pF across
the diode and it still worked. But not 10 pF. However loading the LCD Enable
with R4 = 3.9k fixed that again (no R3 this time). 10k did not work. Neither
did the values in the attached schematics.
1k worked also, which is a bit strange as the voltage divider R2-R4 divides the
signal in half, but maybe my LCD regards V/2 as a logical "1".
Further testing: 1N4148, 20pF added capacitance, and R2 = R4 = 220 ohms still
works with the 20x2 LCD. But not 30 pF.
Of course your mileage might vary, depending on a lot of factors. But it seems
like diode junction capacitance above 5 to 10 pF don't work too well. Unless
input impedance to LCD Enable is in the order of 100 Mohms (which it might
be?), I find it quite puzzling. Especially when loading LCD Enable with 1k,
which is nothing in comparison. The clock speed is also pretty slow (<100 kHz),
but I haven't considered pulse rise time, maybe that's another factor also.
Just speculating a bit before going to sleep :)
Original comment by raron...@gmail.com
on 12 Feb 2012 at 1:35
Attachments:
For reference I have ST 74HC595B1 parts.
When I did my 2wire HC595 implementation,
I actually used a 4.7k resistor for R1 rather than a 1k resistor
and a 1n4148 diode.
I'm wondering if the loading makes a difference?
i.e. would using 4.7k resistor and a bypass cap up by the HC595 solve the issue?
I ran into a strange problem when working on a 1 wire implementation using a
HC595
on a 16x2 LCD.
What I noticed is that the E line glitched every now an then during the latch
rising edge.
I don't have a scope so it is very difficult to tell what was really happening.
What noticed with my cheapie logic analyzer (set to 24mhz sampling rate)
is that every now and then I'd see a L->H-L 42ns pulse on the E signal
when it should be staying solid low because the current E output and
new shifted in E output were both low.
(probably not really 42ns but that is what it can detect at that 24mhz rate)
I'm guessing that this glitch/spike creates a fake E pulse to the LCD which
corrupted the nibble synchronization which corrupts the display.
Altering the timing of the latch "pulse" never fixed things.
I also noticed that it was different when using a Teensy board vs a Diavolino
board.
Diavolino wouldn't even work at first.
The glitch only seemed to happen on the E line and not any of the other
signals coming out of the HC595. It followed the E line no matter which
pin on the HC595 I used.
If I moved E to a separate AVR pin rather than use an output pin of the HC595
and still used the HC595 for all the other control pins,
everything would work.
In reading about the HC595 it seems that they are subject to output glitches
on outputs during transitions without proper bypass caps.
Adding a .1uf cap up by the HC595 helped but didn't solve the problem.
I'm wondering if it is a combination of glitching and ringing on the E signal?
I played with many pullup/pulldown and RC combinations on the E line
and slowing down and speeding up the timing between clock pulses and
nothing fixed it.
What finally fixed my one wire implementation was to add an additional
.1uf bypass cap up by the HC595 and to put a 4.7k resistor on the E line
in series between the LCD and the HC595 E output pin.
(1k failed, 1.5k, 4.7k 10k, and 33k all worked)
This ran for several hours but remove either component and it
immediately fails again.
If something similar happens in the 2wire mode during a shift operation on the
E output of the HC595 SR then you will end up a similar type glitch.
r3 and r4 in that schematic just doesn't feel right to me.
I'd really like to understand what the real problem is.
This kind of stuff is impossible to debug and fully resolve using trial and
error or
even a logic analyzer as the Logic analyzer won't see the same things the HC595
and
the LCD sees.
In the one wire setup, I could tell the Logic analyzer would detect a rising "1"
on the latch signal up to 30us before the HC595 would see the "1".
I also noticed that just hooking up the analyzer probes changed things slightly
as well.
Does anyone have a high speed scope to really see what is happening?
(Maybe its time to break down and buy one...)
--- bill
Original comment by bperry...@gmail.com
on 12 Feb 2012 at 7:22
Bill:
Interesting. Btw I do have a scope, but only 20 MHz, but it's an old analog
one, no storage scope... And I haven't tried scoping it yet though. Also, I
haven't experienced the shiftregister E spikes you have. Well to my knowledge
that is, and I have been running the LCD's for hours at a time without any
strange behaviour.
Perhaps something was wrong or off with your LCD's E-line? Have you tried a
different LCD? If you suspect ringing, is the signal line long? (picking up
noise maybe?).
Regarding R3 and R4 in that schematics, those were just experimentally
determined when using the BYV95 diode and my LCD. I was perhaps a bit vagues,
but I did not use R3 when testing with the 1N4148. I did use R4 sometimes, as
stated. Also, normally, I don't use those resistorsl, that was just for testing.
You said:
"What finally fixed my one wire implementation was to add an additional
.1uf bypass cap up by the HC595 and to put a 4.7k resistor on the E line
in series between the LCD and the HC595 E output pin."
Did you mean a power decoupling capacitor? And was the 4.7k resistor in
parallell over the diode?
Original comment by raron...@gmail.com
on 13 Feb 2012 at 4:02
Sorry about the confusion.
I experienced the glitches when I was running the HC595 in a 1 wire mode.
There is no diode when using 1 wire, just two RC networks.
Yes the .1uf cap that was part of the "fix" for the 1 wire glitches
was a decoupling cap.
What is odd is that the same LCD and same HC595 chip works fine in 2wire mode.
In that setup I used a 4.7k resistor for R1 instead of the 1k shown
in the "Bills version" schematic.
That had worked for hours with no issues.
I just ran quick test and replaced the 4.7k resistor I used in
the 2 wire setup with a 1k resistor.
It fails instantly. So the "bills version" schematic does not work
for me with a 1k resistor but it does work with a 4.7k resistor.
I didn't have any probes on the wires so I don't know if it is similar
to the issue I saw in the 1 wire setup.
I'm using a breadboard setup with wires that are about 3-5 inches long.
(see attached photo)
On this lcd it appears that RS,and the data lines have internal pullups on them
but E is neither pulled up or down.
I have other LCDs but they weren't ready to hook up.
I'll try a few others and see if they have the same issue on E.
I think it's going to take a high speed scope to see what is going on.
--- bill
Original comment by bperry...@gmail.com
on 13 Feb 2012 at 6:32
Attachments:
A bit of a follow up here.
I had a conversation with one of my hardware friends.
Still no scope view but the problem has been narrowed down
to ground bounce from ground loops.
The ground path between the LCD and the SR was too long
due to my sloppy breadboard wiring.
Moving the ground wire from the LCD to be very close to the ground connection
point of the shift register along with putting a .1uf cap directly across the
power and ground pins of the shift register cleared up the problem.
Now my 1 wire mode works with no series resistor on the E line
and the 2 wire mode now works with a 1k resistor using the "bill's version"
schematic.
I'm guessing originally got "lucky" on the two wire mode, in that it appears
that the
higher resistor value was increasing the rise time masking the glitch.
With better power & ground wiring, keeping wire paths short,
and a bit of decoupling it all works like it should now.
The moral of the story here.
As everybody already knows,
keep your wires, especially the power and ground wire paths short
and use decoupling as close to the SR as possible.
--- bill
Original comment by bperry...@gmail.com
on 13 Feb 2012 at 10:52
Bill:
Great info, thanks!
Also pretty incredible that it solved your problem, I'm pretty amazed by that
(given that your breadboard isn't that big, nor are (were) the wires very long).
So, now "Bill's version" works for you too, that's good :p
Original comment by raron...@gmail.com
on 14 Feb 2012 at 4:41
Funny huh?
After a little more playing with it. It is the decoupling that is key.
The wires really didn't matter. I originally shortened them first which
improved things but didn't solve it.
When I put the wires back and left in the decoupling cap, it still works.
You can see the .1uf cap in the photo.
Original comment by bperry...@gmail.com
on 14 Feb 2012 at 5:07
Attachments:
My order of 1N4148 diodes just arrived. I removed the NPN transistor and
substituted a 1N4148 diode in my 2-wire setup - it works perfectly!
Original comment by comer.edward
on 14 Feb 2012 at 7:04
Bill: Ok, good to know! Makes more sense with the decoupling cap than wire
length in this case I think.
comer.edward: That's great!
Original comment by raron...@gmail.com
on 15 Feb 2012 at 5:51
My project has moved along from testing with a Nano328 to the final target, an
ATtiny85 running at 8MHz. The 2-Wire LCD setup with the Nano328 runs pretty
much flawlessly, almost always booting up in displaying the LCD correctly. I am
having less success with the ATtiny85. Nothing changed in the LCD setup - I
simply removed the nano from the breadboard and replaced it with the ATtiny85.
I even swapped the nano back for a while to verify that I hadn't nocked
something loose in the LCD wiring.
Anyway, I am not getting reliable results with the ATtiny85. Occasionally, the
ATtiny85 will drive the LCD correctly but mostly it boots up garbage on the
LCD. I have not placed a .1mf cap across the shifter's power because I don't
currently have one. If you'll look at my attached breadboard, my leads are
longer than those of bperry and I wonder if my problem is the same as his -
possibly aggravated by some timing differences of the ATtiny versus the Nano.
The attached photos show my breadboard during one of the few times that the LCD
functioned correctly.
Original comment by comer.edward
on 21 Feb 2012 at 8:00
Attachments:
I can't say for sure of course, even with the pictures, but I'd say adding a
decoupling capacitor would most likely improve things. The exact value of .1 uF
is not really that important, but a "ballpark" value around that. But make sure
that it's not an electrolytic capacitor, as those are not so good for
decoupling high frequency noise. Preferably ceramic capacitors. And have it as
close to the shiftregister as possible.
Still, you could combine that with a somewhat bigger electrolytic one, on the
breadboard, to see if that helps. I'm not familiar with the way you power the
breadboard, but it seems there is at least one electrolytic cap next to the
green LED? So you have at least one in the system.
Other than that, it's not easy to say why changing the Nano328 with the Attiny
should have anything to say. Which version of the library do you use? The
latest should be very timing safe (But I have never used anything but a 16 MHz
Arduino).
Oh, and "jlk"? :P
Original comment by raron...@gmail.com
on 22 Feb 2012 at 12:27
jlk - hey, what can I say - in a hurry - or maybe because jlk is the last part
of my ham radio call - wa4jlk and I'm used to typing it.
The power on the breadboard is nifty little power supply from China that is
specifically designed to plug onto a MB102 style breadboard. It is made by
Ywrobot and cost only $4.88 on eBay - search for "3v/5v Power Supply Module
adapter For MB102 Breadboard". The schematic is at
http://www.emartee.com/Attachment.php?name=41960.pdf It has .1uf bypass caps by
the regulator and a 47uf electrolytic between 5V and GND. Of course, it isn't
near the shift register.
I've got some .1uf discs on order. Maybe I'll stop by Radio Shack tomorrow and
see if they have any. I live in the middle of nowhere and have to order
everything electronic that isn't used by John Q Public.
Original comment by comer.edward
on 22 Feb 2012 at 1:15
Missed the question re the library. I am using LiquidCrystal_SR marked
internally "Created by Francisco Malpartida on 20/08/11" and with the most
recent history date of "2011.10.29 fmalpartida - adaption of the library to
the LCD class hierarchy.".
Original comment by comer.edward
on 22 Feb 2012 at 4:12
I just downloaded the current NewLiquidCrystal library from Malpartida's git.
I'll test tomorrow. However, diff didn't show many changes.
Original comment by comer.edward
on 22 Feb 2012 at 4:22
Today I obtained a .1uf disc cap and placed across the 74595's power pins -
PROBLEM SOLVED!!! The circuit is now stable with the ATtiny85. The 2-wire
circuit truly needs a bypass cap - the schematic should be updated to reflect
this. As to why the problem was worse with the ATtiny85 versus the nano328 -
the nano has some on-board capacitors and that may be what made it work better.
Thanks to bperry for this discovery.
Original comment by comer.edward
on 22 Feb 2012 at 3:49
Alright, good to know it worked out for you.
I added a note about decoupling capacitrs for now (though it's somewhat of a
common sense thing... but you are right, I should have made that more clear).
And that solved the mystery of "jlk":p
Original comment by raron...@gmail.com
on 23 Feb 2012 at 1:54
Thanks to all 2-wire contributors. I have implemented a PCB with my
implementation of a VT100 emulator that is the subject of an article that I am
writing to be published in Linux Journal. You can see the board in action on
YouTube at:
http://youtu.be/9r2GVga5cYs
The weather data being displayed is simulated by a shell script, being driven
over a serial ACSII connection with VT100 protocol.
Original comment by comer.edward
on 29 Mar 2012 at 1:50
Help me, error rotate 90, test display 1234
https://drive.google.com/folderview?id=0BySB0AjU2WNVMGFobWZETEdBUkU&usp=sharing
Original comment by dominhtr...@gmail.com
on 2 Mar 2015 at 7:56
Original issue reported on code.google.com by
Love.Nystrom
on 11 Jan 2012 at 5:18