123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|687|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> On Topic -> Hacking the 74HC595 shift register.

Sun, 31 Mar 2019, 06:20
steve_ancell

Hacking the 74HC595 shift register.


The 74HC595 is quite a handy chip for expanding the amount of outputs from a microcontroller, and can also be used to drive 7-segment number displays. This chip takes an 8-Bit binary stream and then outputs in parallel to the eight output pins. The 74HC165 does the opposite, converts parallel to serial.

When I first tried using the 74HC165 I blew-up two in a row, those chips are quite fragile when it comes to experimentation. The 74HC595, however, is more forgiving, it is also cheaper and more abundant on eBay, I recently aquired 100 of then for less than a fiver, and this is why I came up with what I'm about to try explaining.

I have found a way to use the 74HC595 as an input chip, converting parallel to serial on a serial to parallel chip. I found similar ideas to this on Youtube but they all seem to use push buttons, but I wanted input pins so had to come up with my own hack. Some so-called geeks will say it's impossible to convert outputs to inputs, I'm here to tell you that you can, and don't let any of the know-it-alls tell you different.

The way this works is quite simple, well sort of. The idea is to turn-on one pin, on the 74HC595, at a time while turning of the previous pin, a bit like a LED chaser without the LEDs. The code on the Arduino then detects the presence or absense of a return voltage on a common bus while looping though the 8 pins. If the current pin in the loop is on, and there's a positive voltage at the return wire, that is stored in an array as '1', if not then it's stored as zero. A diode is required on each ouput to avoid pin clash, and a transistor on each one makes or breaks the return voltage.

The reason I have done this is because a lot of us electronics geeks seem to have loads of general-purpose diodes and transistors knocking about here and there, and as I stated above, the 74HC595 is heaps cheaper than the 74HC165, and can take a lot more punshment so is harder to blow up.

In the mean time I will leave some pics here, and source code, for anyone to bugger about with. I will at some point be doing a full video tutorial on this.

Thanks for reading, I hope I ain't ground down your brains to much, be sure to learn the basics of shift registers before trying this out though.

Please excuse my crappy schematic drawing, I'm evidently no artist.







Sun, 31 Mar 2019, 07:14
steve_ancell
Just in case this all went over the top of your head, in Layman's term it turns outputs into inputs. If you break up each of the transistor-diode into seperate modules, and then imagine each one of the pins on the chip switching the power on and off to each of those modules, and then that power passes through the transistor when a smaller current is applied to its base pin. When the current goes through the diode bus it then goes to the yellow wire that connected to the 10K resistor, and travels out of the wire into pin 5 on the microcontroller and makes that pin go HIGH. When that current is absent, that resistor then pulls pin 5 LOW.

I know I'm crap at explaining stuff, but it will click into place when you read through the source code.
Sun, 31 Mar 2019, 13:23
steve_ancell
I'm going to ask something, and I want you to be honest. Was I successful in explaining the above or did it go right over your heads?
Sun, 31 Mar 2019, 14:07
cyangames
I'd have to have a long look through it tomorrow night I think

-=-=-
Web / Game Dev, occasionally finishes off coding games also!
Mon, 01 Apr 2019, 12:25
Krakatomato
Not sure why you've had so many issues with the 165. I've had loads of those and the 595 for their respective applications and, aside from some dodgy cheap-arsed batches from China, they've all been perfectly fine. Mind your voltages and current draw and you're generally golden.

As for using a 595 as a '165' - nah. I'd rather stick to what they're supposed to do, regardless of what you can make them do.
Mon, 01 Apr 2019, 14:42
steve_ancell
I have experimented with the 165 and I only need to fart next to it for it to blow up, plus this circuit I did was a fun bit of hacking. It just shows what can be done if one has shedloads of 595s, transistors and diodes and has run out of 165s.

I just need to be more careful where I shove my wires I suppose, and get my eyes tested, then maybe I won't blow up any 165s.
Mon, 01 Apr 2019, 14:46
steve_ancell
Krackatomato Not sure why you've had so many issues with the 165

I didn't really have that many issues, I only blew up two of them, I just discovered that the 595 can take more abuse than a 165 that's all. I will use 165s as my inputs when I finally build my own IO expansion board.
Mon, 01 Apr 2019, 16:02
steve_ancell
What the Peking-Duck!... I'll have a hundred of them at that price, and how generous of the postage price. > Reveal 🔎
Mon, 01 Apr 2019, 16:06
Jayenkai
Beware of what you order.. that says there's 2 of them in the pack. You don't want to be overrun by millions of chips because you accidentally bought 2,000,000 instead of just 1,000,000.

-=-=-
''Load, Next List!''
Mon, 01 Apr 2019, 18:01
steve_ancell
I was being sarcastic Jay, there's no way I would pay £12,893.60 for that.
Oh!, plus the £3.50 shipping of course.
Mon, 01 Apr 2019, 18:04
steve_ancell
I've just ordered 20 74HC165 chips, and 20 ULN2803 transistor arrays. Should keep me happy for a while.

That project at the start of this topic was mainly to show that it can be done, was a fun project too.
Wed, 03 Apr 2019, 18:40
steve_ancell
And now, I do, a completely unrehearsed video. I sound nervous as fuck in this one, watta nause!


View on YouTube
Wed, 03 Apr 2019, 18:52
Jayenkai
Crazy chaos!!
Wed, 03 Apr 2019, 20:06
steve_ancell
I noticed I went off track once or twice after I uploaded it, but it is was it is, I think I got my point across hopefully.