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: Hello Alex I have spent the day trying to improve the performance when sampling from the ADC Pi and I have managed to make some performance gains by using threading in Python. I first updated the [url=https://github.com/abelectronicsuk/ABElectronics_Python_Libraries/blob/master/ADCPi/demos/demo_speedtest.py]demo_speedtest.py[/url] file to read from all 8 channels and record the overall sample rate to give me a baseline to work from. The results were: Bit Rate: 12 - 214.82 samples per second Bit Rate: 14 - 64.29 samples per second Bit Rate: 16 - 16.32 samples per second Bit Rate: 18 - 4.10 samples per second Next, I created a new file [url=https://github.com/abelectronicsuk/ABElectronics_Python_Libraries/blob/master/ADCPi/demos/demo_speedtestthreaded.py]demo_speedtestthreaded.py[/url] which splits the ADC reads from each chip into a separate thread. This allowed the program to read from both chips at the same time. The results were almost a doubling in performance. Bit Rate: 12 - 434.87 samples per second Bit Rate: 14 - 123.65 samples per second Bit Rate: 16 - 31.94 samples per second Bit Rate: 18 - 8.05 samples per second I made a couple of changes to the main [url=https://github.com/abelectronicsuk/ABElectronics_Python_Libraries/blob/master/ADCPi/ADCPi.py]ADCPi.py[/url] library to improve its threading performance, so you may want to update it to the latest version. I also changed the speed of the I2C bus to be 1MHz which is the maximum speed supported by the ADC chip. If you have not done this on your Raspberry Pi you can find out how to do it in our [url=/kb/article/1/i2c-part-2-enabling-i2c-on-the-raspberry-pi]I2C tutorial[/url]. In theory, if you use two ADC Pi boards and create a new thread for each chip that should give you a performance improvement but the gains will probably not be as big as you are still limited by the speed of the I2C bus. I tried creating a separate thread for each channel but that just caused timeout errors where it tried to switch channels before getting the results from the first one so you will be limited to one thread per ADC chip. These tests were all done on a Raspberry Pi 3+ so you may see some small improvements using a Raspberry Pi 4. The other way to improve the sample rate would be to use a compiled language like C or C++ instead of Python. Hopefully, the new threaded demo will help you improve the performance of your program. 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