MCP23017: Port control - not Pin control
Moderators: grovkillen, Stuntteam, TD-er
MCP23017: Port control - not Pin control
Hi All
Is it possable to send one command to change all 16 I/O pins at once.
At the moment i send 16 commands MCPGPIO,1,1.....MCPGPIO16,1 via MQTT. I have 32ESP's and updating all the status is NUTS...
Any way of sending one command to change the output of all 16 I/O pins?
Z69
Is it possable to send one command to change all 16 I/O pins at once.
At the moment i send 16 commands MCPGPIO,1,1.....MCPGPIO16,1 via MQTT. I have 32ESP's and updating all the status is NUTS...
Any way of sending one command to change the output of all 16 I/O pins?
Z69
Re: MCP23017: Port control - not Pin control
Well, the plugin doesn't have a command to switch on all 16 gpio's at once, but you can add an event in the rules to turn 'm all on using 1 command:
That allows to set all gpio's to either 0 or 1 using the command event,mcpgpioall=0 or event,mcpgpioall=1
Code: Select all
on mcpgpioall do
mcpgpio,1,%eventvalue%
mcpgpio,2,%eventvalue%
mcpgpio,3,%eventvalue%
// and some more...
mcpgpio,16,%eventvalue%
endon
/Ton (PayPal.me)
Re: MCP23017: Port control - not Pin control
Hi Ath
Yes, i looked at that, but i have 31 combenations that the ports need to be in, not just On/Off.
Depecning on a input value of 0 to 30, there is a "MAP" value that the ports need to be in.
That is why i was looking at sending a 16bit "Port" value as one comand instead of 16 commands to set each port when the input value change.
Yes, i looked at that, but i have 31 combenations that the ports need to be in, not just On/Off.
Depecning on a input value of 0 to 30, there is a "MAP" value that the ports need to be in.
That is why i was looking at sending a 16bit "Port" value as one comand instead of 16 commands to set each port when the input value change.
Re: MCP23017: Port control - not Pin control
Using rules, you should be able to map the 0-30 value to the required gpio states, could be though making that smart, but be aware you can pass up to 4 values to the event (%eventvalue1% to %eventvalue4%, %eventvalue% is an alias for %eventvalue1%)Zodiac69 wrote: ↑29 Sep 2020, 21:00 i have 31 combenations that the ports need to be in, not just On/Off.
Depecning on a input value of 0 to 30, there is a "MAP" value that the ports need to be in.
That is why i was looking at sending a 16bit "Port" value as one comand instead of 16 commands to set each port when the input value change.
/Ton (PayPal.me)
Re: MCP23017: Port control - not Pin control?
Hi Ath
Rules.... not enough space as i have to set all 16 pin states for each of the 31 "MAP" values.
Was thinking if it is possable to change P009 to include aditional command to set the "Port" instead of each pin - posted this on the GitHub as well.
Send MCPPort instead of MCPGPIO.
MCPPort, 0xFFFF will set all 16 I/O pins to output high(1)
MCPPort, 0x0000 will set all 16 I/O pins to output low(0)
MCPPort, 0xAA55 will set the 16 I/O pins to output in this patern - 1010 1010 0101 0101
MCPPortA, 0xAA will only affect the "A" port
MCPPortB, 0xAA will only affect the "B" port
Rules.... not enough space as i have to set all 16 pin states for each of the 31 "MAP" values.
Was thinking if it is possable to change P009 to include aditional command to set the "Port" instead of each pin - posted this on the GitHub as well.
Send MCPPort instead of MCPGPIO.
MCPPort, 0xFFFF will set all 16 I/O pins to output high(1)
MCPPort, 0x0000 will set all 16 I/O pins to output low(0)
MCPPort, 0xAA55 will set the 16 I/O pins to output in this patern - 1010 1010 0101 0101
MCPPortA, 0xAA will only affect the "A" port
MCPPortB, 0xAA will only affect the "B" port
Re: MCP23017: Port control - not Pin control
I like the idea (also saw your suggestion on github). That github improvement still needs some time tough, it seems.
/Ton (PayPal.me)
Re: MCP23017: Port control - not Pin control
Hi Ath
Any pointers on how to do the "Port" part?
i tried to see if i can understand how to do it in P009, but i am not that good, need a lot of schooling on how to do that.
Just so i can control the port with one command instead of 16 to set / reset each pin
Any pointers on how to do the "Port" part?
i tried to see if i can understand how to do it in P009, but i am not that good, need a lot of schooling on how to do that.
Just so i can control the port with one command instead of 16 to set / reset each pin
Re: MCP23017: Port control - not Pin control
You can create a short general purpose event rule that avoids hard coding 31 MAP values. Here is an example:Rules.... not enough space as i have to set all 16 pin states for each of the 31 "MAP" values.
Code: Select all
on MCPport16 do
logentry,"The 16-bit port pattern is %eventvalue1%"
MCPGPIO,16,{substring:0:1:%eventvalue1%}
MCPGPIO,15,{substring:1:2:%eventvalue1%}
MCPGPIO,14,{substring:2:3:%eventvalue1%}
MCPGPIO,13,{substring:3:4:%eventvalue1%}
MCPGPIO,12,{substring:4:5:%eventvalue1%}
MCPGPIO,11,{substring:5:6:%eventvalue1%}
MCPGPIO,10,{substring:6:7:%eventvalue1%}
MCPGPIO,9,{substring:7:8:%eventvalue1%}
MCPGPIO,8,{substring:8:9:%eventvalue1%}
MCPGPIO,7,{substring:9:10:%eventvalue1%}
MCPGPIO,6,{substring:10:11:%eventvalue1%}
MCPGPIO,5,{substring:11:12:%eventvalue1%}
MCPGPIO,4,{substring:12:13:%eventvalue1%}
MCPGPIO,3,{substring:13:14:%eventvalue1%}
MCPGPIO,2,{substring:14:15:%eventvalue1%}
MCPGPIO,1,{substring:15:16:%eventvalue1%}
endon
Code: Select all
event,MCPport16=1010101010101011
I don't use the MCP23017 so I cannot test this. So you might have to tweak the code to get it to work correctly. Use Serial Log if debugging is necessary.
- Thomas
Re: MCP23017: Port control - not Pin control
Hi ThomasB
Thank you, i finally managed to implement this and it works.
Thank you again for assistance.
Thank you, i finally managed to implement this and it works.
Thank you again for assistance.
Re: MCP23017: Port control - not Pin control
You are welcome. It is good to know you resolved the problem.
- Thomas
- Thomas
Who is online
Users browsing this forum: Bing [Bot] and 32 guests