Current News

Moderator: Mmiscool

User avatar
By Mmiscool
#46086 The new build has been published.

The docs have been updated.
User avatar
By cicciocb
#46088 I made a little video showing a 74HC595 and a MCP23S17 connected to en ESP-12E.

https://youtu.be/k3gACQGSPVs

The code is the following :
Code: Select allmemclear
cls

spi.setup(1000000, 0)

gosub [init.expander]

for i = 0 to 255
' write port A
add = 18
dat = (not i)
gosub [write_exp]
gosub [write_595]
'read port B
add = 19
gosub [read_exp]
serialprintln dat
next i

end

''''''''''''''''''''''''''''''''''''
' INIT THE MCP27S17 EXPANDER
''''''''''''''''''''''''''''''''''''
[init.expander]
'disable HAEN (Hardware Address Enable)
add = 12 ' IOCON
dat = 0 ' disable HAEN
gosub [write_exp]
'set the expander with port A output
add = 0 'IODIRA
dat = 0 ' all outputs
gosub [write_exp]
'set the expander with port B input
add = 1 'IODIRB
dat = 255 ' all inputs
gosub [write_exp]
'set the expander with pull-up on port B inputs
add = 13 'GPPUB
dat = 255 ' all inputs pullup active
gosub [write_exp]
return

''''''''''''''''''''''''''''''''''''
' WRITE to the MCP23S17 EXPANDER
' this function uses the variables
' add = address - INPUT -
' dat = data - INPUT -
'''''''''''''''''''''''''''''''''''
[write_exp]
'chip select
po 5 0
spi.byte(64) 'writemode (0x40)
spi.byte(add)
spi.byte(dat)
po 5 1
return

''''''''''''''''''''''''''''''''''''
' READ from the MCP23S17 EXPANDER
' this function uses the variables
' add = address - INPUT -
' dat = data - OUTPUT -
'''''''''''''''''''''''''''''''''''
[read_exp]
'chip select
po 5 0
spi.byte(65) 'readmode (0x41)
spi.byte(add)
dat = spi.byte(dat)
po 5 1
return

''''''''''''''''''''''''''''''''''''
' WRITE to the 74HC595 shift register
' this function uses the variables
' dat = data - INPUT -
'''''''''''''''''''''''''''''''''''
[write_595]
'chip select
spi.byte(dat)
po 2 0
po 2 1
return


The wiring is
mcp23s17_74hc595.PNG
You do not have the required permissions to view the files attached to this post.
User avatar
By Electroguard
#46091 Oi Matey - I just looked at your IO expander vid which is great, but ended up more interested in your browser! ... how are you getting things highlighted in the Edit window - and how can ! ???

It's actually quite relevent to this new release, cos I'm getting 'goto branch not found' errors which I can't find any apparent reason for, and which were ok in prior versions - but I have no way of visually tracking or comparing defined branches for errors.

A couple of other things I've noticed in the the new release is that such errors cause Saves etc to no longer work - they go off to do their thing (on a big script), but then eventually cause a reboot (which has never happened before), and when things are accessable again the edit page no longer shows default.bas but just some garbage instead.
( I think this probably started happening after disabling autorun in settings)

I haven't had long enough to be sure about anything, but I thought it worth mentioning quickly in case it's something that needs to be kept an eye on.
User avatar
By forlotto
#46115 Electroguard you mean misspellings being highlighted?

@Cicciocb

Rather interesting so it is not quite as simple as I presumed you actually need two chips and it is all serial coms IDK for sure would need to evaluate more the code and the video. I figured something may have been built into basic for expansion so you could just reference the ports in the same manner and have a GPIO expansion much like I was able to do with the two extra ports.

I am sure this will help oodles of people though if they chose to take that route however I would like to opt for the simplistic route less hardware moar gpios and less complexity as you can see from my powerstrip example in my latest video there is not a heck of a lot of room to cram all this stuff in I am pushing the limit with what I have in there already.

I do not even use any PCB's or breadboards in any devices just wiring harnesses and PCB modules mainly to connect each device which helps save a bit of space and in the power strip example it helped largely although if there were a relay board that carried the 120v to leg 1 on each relay just by putting 120v on leg 1 of the first relay this would be huge in space and time savings.

Anyhow thanks a ton for the help your example with the LED build up is way cool but to be honest I don't quite grasp everything at a functional level upon first look I need to study a bit more about basic and the serial portions of it etc in order to make heads or tails of the port expansion.

It would be nice if you could just hook the thing up and do the following.

Set GPIO1 of GPIO Expansion to 1.
po x1 1

Set GPIO2 of GPIO Expansion to 0.
po x2 0

Set pwo of GPIO 1 to full on.
pwo x1 512

This was kind of what I was hoping for I suppose but the important take away from all of this is it is possible.

As far as dimming or interrupts I am not sure if your example really covered this question.

Forgive me for lacking the know how but its slightly greek to me at this point.