Legal Removal Request This form is for reporting content posted on the AB Electronics UK forums that you believe violates your personal legal rights or applicable local laws for your country. Post: Hi Sean The interrupts on the IO Pi are designed so that the IA and IB pins will go high when an interrupt occurs. To read the interrupt pins you can either use a loop to check the status like you would with a port read or you can connect the interrupt pins to the Raspberry Pi GPIO port via a resistor divider and then set the GPIO pin to trigger an interrupt routine when the GPIO pin changes state. Based on what you have described above the easiest solution would probably be to use something similar to our [url=https://github.com/abelectronicsuk/ABElectronics_Python_Libraries/blob/master/IOPi/demos/demo_iointerruptsthreading.py]demo_iointerruptsthreading.py[/url] demo in the python library. This demo runs a background thread which checks the interrupt status every 0.5 seconds and calls callback_function() if the interrupt is triggered. If you need a faster response time you can reduce the sleep time to a shorter period. To configure the interrupts for your application you can modify the demo with the following code: # Set the interrupt polarity to be active high and mirroring enabled, so # pins 1 to 10 will trigger both INT A and INT B [b]iobus.set_interrupt_polarity(1)[/b] [b]iobus.mirror_interrupts(1)[/b] # Set the interrupts default value to 0, this means the interrupt will fire when the pins go high [b]iobus.set_interrupt_defaults(0, 0x00)[/b] [b]iobus.set_interrupt_defaults(1, 0x00)[/b] # Set the interrupt type for ports A and B so an interrupt is # fired when a pin goes high [b]iobus.set_interrupt_type(0, 0xFF)[/b] [b]iobus.set_interrupt_type(1, 0xFF)[/b] # Enable interrupts for pins 1 to 10 [b]iobus.set_interrupt_on_port(0, 0xFF)[/b] [b]iobus.set_interrupt_on_port(1, 0x03)[/b] Using the above code the interrupt will be triggered when any of pins 1 to 10 on the bus go high. To find out which pin triggered the interrupt you can use the read_interrupt_capture(port) function which stores the state of the port when the interrupt occurs. The code in the demo_iointerruptsthreading.py script has to read the interrupt status at regular intervals to see if the interrupt has occurred. When using the interrupts in this way you don't need to connect anything to the IA and IB pins on the IO Pi Plus as everything is handled internally within the IO controller chip. If you want to make it work without having to read the interrupt status you could connect the interrupt pins to a Raspberry Pi GPIO pin via a voltage divider and then use a GPIO interrupt with a callback function so the function is called when the interrupt pin changes state. As the code above sets the IA and IB pins to be mirrored you only have to connect one of them to the Raspberry Pi GPIO for it to work. Adafruit has a tutorial on [url=https://learn.adafruit.com/node-embedded-development/events]how to use GPIO interrupts[/url]. As the IO Pi Plus interrupt outputs are 5V and the Raspberry Pi GPIO is 3.3V you will need to use a voltage divider to drop the 5V to 3.3V. We have a voltage divider calculator on our website [url=https://www.abelectronics.co.uk/tools/resistor-voltage-divider]Resistor Voltage Divider[/url]. A 10K resistor on R1 and 18K for R2 should drop the IO Pi Plus output to around 3.2V which will work. Select the country where you are claiming legal rights. Albania Algeria American Samoa Andorra Angola Anguilla Antarctica Antigua and Barbuda Argentina Aruba Australia Austria Bahamas Bahrain Bangladesh Barbados Belarus Belgium Belize Benin Bermuda Bhutan Bolivia Bosnia And Herzegovina Botswana Bouvet Island Brazil British Indian Ocean Territory British Virgin Islands Brunei Bulgaria Burkina Faso Burundi Cambodia Cameroon Canada Canary Islands Cape Verde Cayman Islands Central African Republic Chad Channel Islands Chile Christmas Island Cocos (Keeling) Islands Colombia Comoros Congo Cook Islands Costa Rica Croatia Cuba Cyprus Czech Republic Denmark Djibouti Dominica Dominican Republic East Timor Ecuador Egypt El Salvador Equatorial Guinea Estonia Ethiopia Falkland Islands (Malvinas) Faroe Islands Federated States of Micronesia Fiji Finland France French Guiana French Polynesia French Southern Territories Gabon Gambia Georgia Germany Ghana Gibraltar Greece Greenland Grenada Guadeloupe Guam Guatemala Guyana Haiti Heard Island and McDonald Islands Honduras Hong Kong Hungary Iceland India Indonesia Ireland Israel Italy Jamaica Japan Jordan Kazakhstan Kenya Kiribati Kuwait Kyrgyzstan Laos Latvia Lesotho Liechtenstein Lithuania Luxembourg Macau Macedonia Madagascar Malawi Malaysia Maldives Mali Malta Marshall Islands Martinique Mauritania Mauritius Mayotte Mexico Micronesia, Federated States Of Moldova, Republic Of Monaco Mongolia Montenegro Montserrat Morocco Mozambique Myanmar Namibia Nauru Nepal Netherlands Netherlands Antilles New Caledonia New Zealand Nicaragua Niue Norfolk Island Northern Mariana Islands Norway Oman Palau Panama Papua New Guinea Paraguay Peru Philippines Pitcairn Poland Portugal Puerto Rico Qatar Reunion Romania Russia Rwanda Samoa San Marino Sao Tome and Principe Saudi Arabia Serbia Seychelles Singapore Slovakia Slovenia Solomon Islands South Africa South Georgia and the South Sandwich Islands South Korea Spain Sri Lanka St. Helena St. Kitts and Nevis St. Lucia St. Pierre and Miquelon St. Vincent and the Grenadines Suriname Svalbard and Jan Mayen Islands Swaziland Sweden Switzerland Syria Taiwan Tajikistan Tanzania Thailand Togo Tokelau Tonga Trinidad and Tobago Tunisia Turkey Turkmenistan Turks and Caicos Islands Tuvalu U.S. Virgin Islands Uganda Ukraine United Arab Emirates United Kingdom United States United States Minor Outlying Islands Uruguay Uzbekistan Vanuatu Vatican City Venezuela Vietnam Wallis and Futuna Islands Western Sahara Yemen Yugoslavia Zambia What legal issue or problem do you wish to report? Please select Privacy / Erasure under GDPR Defamation Intellectual Property Hate Speech Other Please enter the following information so we can process your report. Contact Name: Contact Email: Details of complaint: Submit Complaint