Blog Three: Adding Additional Ports
- William Pretty
- Jul 12, 2024
- 3 min read
Updated: Jul 19, 2024
The following blog contains some ideas and suggestions for improving your alarm system.
The MCP23017 I/O Expander:
The expander board is based on the MCP23017 port expander integrated circuit. The device comes with sixteen ports which can be configured as either inputs or outputs.
The I/O Expander Board:
The proposed expander board will have eight inputs and eight outputs. The inputs are identical to the ones on the main board and come with the same antitamper features. The eight outputs of the IC are connected to solid state, optically isolated relays. Each relay is capable of sinking twenty four volts at two amps, or forty-eight watts. This should be more than enough to drive mechanical relays, solenoids or relays.

Figure 9-1. Port Expander IC
Figure 9-1 shows the connections to the MCP23017 port expander IC. Connectors J1 and J2 connect to the I2C bus which provides power and data to the expansion board. Connector J2 is provided as a loop through connector so that other expander boards can be connected to the system. Voltage regulator U2 is a low drop out 3.3 volt regulator which supplies power to U1 and the rest of the system. Connectors J3 and J4 provide 12 volt power to the board. The board is normally connected to a mains power supply which provides power for the board. The user can connect a 12 volt battery to J4 to supply power to the board in the event of a power failure. Three position dip switch SW1 and resistor network RN1 are used to set the address of the expander board. Closing a switch results in a logic 0 on the address line. In this system hex address x27 is used by the LCD display. For that reason, we have addresses hex x20 to hex x26 left over for our expander boards.

Figure 9-2. Solid State Relays
Figure 9-2 shows the eight solid state relays which are connected to Port A of the MCP23017. These are solid state relays so the correct polarity must be observed when connecting a DC load to these devices. Each output has its own ground connection (OUT0-) so that the ribbon cable ground connection does not have to carry several amps.
The Alarm Inputs:

Figure 9-3. Alarm Inputs
Figure 9-3 shows a typical alarm sensor connection to the expander board. The alarm inputs on the expander board use exactly the same circuit as on the main board. The end of line resistor and the relay are located on the sensor device. Resistors R1 and R2 form a voltage divider which supplies approximately 2 volts to the negative input of the comparator U1. Resistors R3, R4 and the end of line resistor form a second voltage divider. In the normal condition the relay contacts are closed, and the voltage divider supplies 3.4 volts to the positive input of the comparator. During an alarm condition, the relay contact opens and resistor R3 pulls positive input to zero volts. When the positive input is higher than the reference to output is high. When the positive input is lower that the reference to output is low.
Troubleshooting the System:
The alarm system software does not have to be running in order to perform these tests. Each zone input on both the main board and the expander boards has a red LED attached to its output. When an alarm condition occurs the output of the comparator goes low, and the LED turns on. A 5K6 resistor should be connected between the COM and the IN terminals of any zone inputs that are not in use. This simulates the end of line resistor and the LED associated with the zone should be off. If a normally closed push button switch is connected in series with the resistor, the switch can be used to simulate an alarm condition. A normally open push button switch can be connected across the same terminals of the fire zone inputs. Pressing the switch will make the comparator output go low and turn on the LED associated with the zone.
The address of the expander is set using the 3 position dip switch. Turning a switch on pulls the address bit low. With all of the switches closed the address of the first expander card will be Hex 20. This is because the most significant byte of the address is hard coded into the IC as a hex ‘2x’ and cannot be changed by the user. Also, the address of the LCD is hard coded to Hex 27 and cannot be changed. These addresses can be checked using the i2cdetect -y 1 Linux command. Some LCDs have a different hex address which may cause a conflict. Note that because of the default address of the LCD, only addresses Hex 20 through Hex 26 can be used by the expander cards.

Figure 9-4 i2cdetect Command
Comments