Tell me what you want, What you really, really want.

Moderator: Mmiscool

User avatar
By forlotto
#50536 Previous and recently I am running into the issue of need more GPIO's ...

CICCIOCB did a demo on this shift register as an expander and talked about possibly integrating it into basic with some simple commands to control the ON/OFF functionality of the IO.

The 74HC595 is commanded by bitbang but I plan to implement a dedicated function for the 74hc595 expander.
Using the UDP utility it's very simple also to command.
Simply type 1 to toggle relay1, 2 for relay2, 4 for relay3, 8 for relay 4 , ..... (binary bits)
- See more at: viewtopic.php?f=40&t=9841&start=20#sthash.sJuxkl5E.dpuf


Below is the code he used for IR Based expansion. A rather interesting bit of code that I do not fully understand how it works I would love to say io(po x1 1) to turn on gpio 1 of the shift register maybe this is not even the correct terminology but operational principal should apply.

Code: Select all
memclear
cls
print ramfree()
pi 1 a
ir.recv.setup(1)
irbranch [ircode]

udpbegin 5001
udpbranch [receive.UDP]

ss = 0
dat = 0
gosub [bitbang]

wait
end

''''''''''''''''''''''''''''''''''''
' WRITE to the 74HC595 shift register
' using the bitbang with 2 pins
' this function uses the variables
' dat = data - INPUT -
' use GPIO2 for the clock/store
' and GPIO0 for the data
'''''''''''''''''''''''''''''''''''
[bitbang]
ww = dat
po 2 0  'clock
for w = 0 to 7
  b = ww and 128
  if b = 0 then
     po 0 1
  else
     po 0 0
  end if
  ww = ww << 1
  po 2 1  'clock
  if w < 7 then po 2 0  'clock
next w
'store
return

[ircode]
'serialprintln "code received"
r = ir.recv.get()
'print r
if r <> "ffffffff" then
   if r = "8c7320df" then
     ss = ss xor 1
   end if
   if r = "8c73a05f" then
     ss = ss xor 2
   end if
   if r = "8c73609f" then
     ss = ss xor 4
   end if
   if r = "8c73e01f" then
     ss = ss xor 8
   end if
   if r = "8c7330cf" then
     ss = ss xor 16
   end if
   if r = "8c73b04f" then
     ss = ss xor 32
   end if
   if r = "8c73708f" then
     ss = ss xor 64
   end if
   if r = "8c73f00f" then
     ss = ss xor 128
   end if
end if
dat = ss
gosub [bitbang]
return


[receive.UDP]
ud = udpread()
ud = val(ud)
ss = ss xor ud
dat = ss
gosub [bitbang]
return



Lets say that none of this is possible or even something you would like to consider from a hardware or software perspective.

Can you at the very least provide support for some type of GPIO expansion and give an example of how to use it preferably something that will not break the bank and PWM would be an added bonus but not really needed currently by my own small mind. There are 6 PWM pins already available and ways to control lights such as neopixels etc...


I know this is asking a lot and I have asked similar questions before I will gladly provide you with appropriate hardware you would need if needed to carry out your tests to mitigate any expenses that you would incur on this within reason I am not going to buy you tools such as a scope etc. Tools I assume you already have plenty of just with talking however a 7HC595 chip I would gladly see to it you get a couple if you were at all interested in doing so.

I assume that I could simply use the chip hooked to the same GPIO's and replace the IR routine with buttons doing the same thing or msg branch.

But my knowledge of what is needed beyond the chip and nodemcu is kind of poor I am sure looking at a datasheet would greatly improve that or the operational principals of the shift register.

Support would be great but I would settle for understanding and direction even without the silver spoon so to speak.
Last edited by forlotto on Wed Jul 20, 2016 10:10 pm, edited 1 time in total.
User avatar
By trackerj
#50546 Why not use a dedicated Port I/O Expander like the PCF8574 for a full 8 Bit I/O portor even the PCF8575 for a full 16bit one!

Even a 4x4 matrix keyboard is very easy to implement and still let you extra I/O pins free.

And because PCF8574/5 are I2C compatible, you can have even more that that ones the same I2C bus, using just 2 ESP8266 GPIO pins.
User avatar
By forlotto
#50548 Errrr why not I ordered 25 of these shift registers lol after I seen what was possible rather simple answer but I am not biased to using something else.


Take care and thanks for the suggestion trackerj.
User avatar
By trackerj
#50550 They are plenty of reasons why not HC595. I will give you now only one extra: if you want to use also a interrupt event detection mechanism for your GPIO extension board it's way more simple and elegant with a dedicated GPIO port expander like PCF8574/5.