74HC595 Support for more GPIO's
Posted: Sun Jul 10, 2016 7:17 pm
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.
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.
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.
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.