Introduction: Arduino NANO Tests 2 MCP23S17 IO Xpanders
Wow, my first INSTRUCTABLE....
The Arduino's are great little modules. However, they can benefit from the MicroChip MCP23S17 IO expanders.
This instructable demonstrates the use of the SPI bus (not the I2C bus). One NANO talks to TWO MCP23S17's.
A similar project, using MCP23S17 parts, is by none other than, manu4371. Here is the link: https://www.instructables.com/id/State-machine-and-multitasking-on-arduino-with-SPI/
Another possible is Raspberry PI to MCP23S17 parts. Here is a link: https://www.instructables.com/id/Raspberry-Pi-Port-Expander/
(Also, thank you dreamcat4 for the MCP23S17 SPI driver here used...)
The idea here is a test circuit. It is simple. Each of the two MCP23S17 parts are connected to the NANO, and each MCP23S17 has its port pins wired to the exact same pins of the other device. (This is possible since a port pin can be either input or output.)
Step 1: Wire, Program the NANO, Run Test
Then, having number one MCP23S17 as output, and the other input,
a value is written on number one MCP23S17. (The initial value is hex 0x0001. So by shifting the "1" thru the pins, each pin is checked that it is set, and the number two MCP23S17 is receiving.
After completing the sixteen bits, the devices flip roles, with the other device as input, and the original output device now as input.
The user is notified thru the serial port of the NANO as the testing proceeds. If either a "MATCH" or an "ERROR" is happening, the value, and which device is input or output, is displayed. (You can test this works by simply opening a port connection.)
A great idea for improvement would be to add 16 LED's and 16 resistors and observe the "1" progress along the pins. Enjoy!