Forum Replies Created
-
AuthorPosts
-
8 November 2023 at 15:34 in reply to: MicroPython I2C PCF8591 round value problem Raspberry Pi Pico #28096
Hello Renzo!
I tried running the modified library (and also tried it on another set of Raspberry Pi picow and PCF8591). PCF8591 still couldn’t correctly read the value which generated by itself, but the value it read are not fixed now.
Here is the result:Written: 0, Read: 128 Written: 1, Read: 184 Written: 2, Read: 184 Written: 3, Read: 184 Written: 4, Read: 0 Written: 5, Read: 0 Written: 6, Read: 0 Written: 7, Read: 0 Written: 8, Read: 128 Written: 9, Read: 184 Written: 10, Read: 0 Written: 11, Read: 184 Written: 12, Read: 0 Written: 13, Read: 0 Written: 14, Read: 184 Written: 15, Read: 0 Written: 16, Read: 0 Written: 17, Read: 0 Written: 18, Read: 0 Written: 19, Read: 184 Written: 20, Read: 0 Written: 21, Read: 128 Written: 22, Read: 184 Written: 23, Read: 0 Written: 24, Read: 0 Written: 25, Read: 0 Written: 26, Read: 184 Written: 27, Read: 184 Written: 28, Read: 0 Written: 29, Read: 184 Written: 30, Read: 184 Written: 31, Read: 0 Written: 32, Read: 184 Written: 33, Read: 0 Written: 34, Read: 0 Written: 35, Read: 0 Written: 36, Read: 0 Written: 37, Read: 0 Written: 38, Read: 0 Written: 39, Read: 184 Written: 40, Read: 184 Written: 41, Read: 0 Written: 42, Read: 128 Written: 43, Read: 0 Written: 44, Read: 184 Written: 45, Read: 0 Written: 46, Read: 0 Written: 47, Read: 0 Written: 48, Read: 184 Written: 49, Read: 0 Written: 50, Read: 0 Written: 51, Read: 0 Written: 52, Read: 0 Written: 53, Read: 0 Written: 54, Read: 0 Written: 55, Read: 0 Written: 56, Read: 184 Written: 57, Read: 0 Written: 58, Read: 184 Written: 59, Read: 0 Written: 60, Read: 0 Written: 61, Read: 0 Written: 62, Read: 184 Written: 63, Read: 184 Written: 64, Read: 184 Written: 65, Read: 128 Written: 66, Read: 184 Written: 67, Read: 0 Written: 68, Read: 184 Written: 69, Read: 0 Written: 70, Read: 184 Written: 71, Read: 128 Written: 72, Read: 184 Written: 73, Read: 128 Written: 74, Read: 0 Written: 75, Read: 0 Written: 76, Read: 0 Written: 77, Read: 184 Written: 78, Read: 184 Written: 79, Read: 0 Written: 80, Read: 0 Written: 81, Read: 0 Written: 82, Read: 0 Written: 83, Read: 0 Written: 84, Read: 0 Written: 85, Read: 0 Written: 86, Read: 0 Written: 87, Read: 184 Written: 88, Read: 0 Written: 89, Read: 184 Written: 90, Read: 0 Written: 91, Read: 0 Written: 92, Read: 0 Written: 93, Read: 0 Written: 94, Read: 0 Written: 95, Read: 0 Written: 96, Read: 184 Written: 97, Read: 184 Written: 98, Read: 184 Written: 99, Read: 0 Written: 100, Read: 128 Written: 101, Read: 184 Written: 102, Read: 0 Written: 103, Read: 0 Written: 104, Read: 184 Written: 105, Read: 128 Written: 106, Read: 0 Written: 107, Read: 184 Written: 108, Read: 0 Written: 109, Read: 0 Written: 110, Read: 0 Written: 111, Read: 128 Written: 112, Read: 0 Written: 113, Read: 184 Written: 114, Read: 184 Written: 115, Read: 0 Written: 116, Read: 128 Written: 117, Read: 184 Written: 118, Read: 128 Written: 119, Read: 0 Written: 120, Read: 184 Written: 121, Read: 184 Written: 122, Read: 184 Written: 123, Read: 0 Written: 124, Read: 0 Written: 125, Read: 184 Written: 126, Read: 128 Written: 127, Read: 184 Written: 128, Read: 0 Written: 129, Read: 0 Written: 130, Read: 184 Written: 131, Read: 0 Written: 132, Read: 0 Written: 133, Read: 0 Written: 134, Read: 0 Written: 135, Read: 0 Written: 136, Read: 184 Written: 137, Read: 0 Written: 138, Read: 0 Written: 139, Read: 0 Written: 140, Read: 0 Written: 141, Read: 184 Written: 142, Read: 128 Written: 143, Read: 0 Written: 144, Read: 184 Written: 145, Read: 184 Written: 146, Read: 184 Written: 147, Read: 0 Written: 148, Read: 0 Written: 149, Read: 0 Written: 150, Read: 0 Written: 151, Read: 184 Written: 152, Read: 0 Written: 153, Read: 184 Written: 154, Read: 0 Written: 155, Read: 184 Written: 156, Read: 0 Written: 157, Read: 0 Written: 158, Read: 0 Written: 159, Read: 0 Written: 160, Read: 184 Written: 161, Read: 0 Written: 162, Read: 0 Written: 163, Read: 184 Written: 164, Read: 0 Written: 165, Read: 0 Written: 166, Read: 0 Written: 167, Read: 0 Written: 168, Read: 0 Written: 169, Read: 184 Written: 170, Read: 128 Written: 171, Read: 0 Written: 172, Read: 0 Written: 173, Read: 128 Written: 174, Read: 184 Written: 175, Read: 184 Written: 176, Read: 184 Written: 177, Read: 0 Written: 178, Read: 0 Written: 179, Read: 184 Written: 180, Read: 0 Written: 181, Read: 184 Written: 182, Read: 184 Written: 183, Read: 0 Written: 184, Read: 0 Written: 185, Read: 128 Written: 186, Read: 0 Written: 187, Read: 128 Written: 188, Read: 0 Written: 189, Read: 128 <strong>Written: 190, Read: 189</strong> Written: 191, Read: 128 <strong>Written: 192, Read: 192</strong> Written: 193, Read: 128 Written: 194, Read: 128 Written: 195, Read: 0 Written: 196, Read: 128 <strong>Written: 197, Read: 196</strong> Written: 198, Read: 128 Written: 199, Read: 0 <strong>Written: 200, Read: 198</strong> Written: 201, Read: 128 Written: 202, Read: 0 Written: 203, Read: 128 Written: 204, Read: 0 Written: 205, Read: 128 Written: 206, Read: 0 Written: 207, Read: 128 Written: 208, Read: 0 Written: 209, Read: 128 Written: 210, Read: 0 Written: 211, Read: 0 Written: 212, Read: 128 Written: 213, Read: 0 Written: 214, Read: 128 Written: 215, Read: 0 <strong>Written: 216, Read: 213 Written: 217, Read: 214</strong> Written: 218, Read: 128 <strong>Written: 219, Read: 216 Written: 220, Read: 217</strong> Written: 221, Read: 0 <strong>Written: 222, Read: 219</strong> Written: 223, Read: 128 Written: 224, Read: 0 <strong>Written: 225, Read: 221</strong> Written: 226, Read: 0 Written: 227, Read: 128 <strong>Written: 228, Read: 224</strong> Written: 229, Read: 128 <strong>Written: 230, Read: 226</strong> Written: 231, Read: 128 Written: 232, Read: 128 <strong>Written: 233, Read: 228 Written: 234, Read: 229 Written: 235, Read: 230</strong> Written: 236, Read: 0 Written: 237, Read: 128 <strong>Written: 238, Read: 232</strong> Written: 239, Read: 128 <strong>Written: 240, Read: 233 Written: 241, Read: 233</strong> Written: 242, Read: 128 Written: 243, Read: 0 Written: 244, Read: 0 Written: 245, Read: 0 Written: 246, Read: 0 Written: 247, Read: 0 Written: 248, Read: 0 Written: 249, Read: 0 <strong>Written: 250, Read: 234</strong> Written: 251, Read: 0 Written: 252, Read: 0 Written: 253, Read: 128 <strong>Written: 254, Read: 234</strong> Written: 255, Read: 234
When the value read by analog_read is greater than 184 (sometimes change a little), PCF8591 will read correctly from time to time (I marked it; and the AIN port can only read a maximum of 233 or 234), but most of the time it is still 0 or 128 . When the number read by the AIN port is less than 184, it will only read 0, 128 or 184 (I think 184 should be when PCF8591 tries to read ‘correctly’). The waveform of the AOUT port can still be read normally by the oscilloscope.
6 November 2023 at 20:51 in reply to: MicroPython I2C PCF8591 round value problem Raspberry Pi Pico #28043Ahh, I did not directly test with the example in github. I used this library in my project and find some problem. And wrote a small program to test:
from machine import I2C, Pin from PCF8591 import PCF8591 i2c = I2C(0, scl=Pin(9), sda=Pin(8)) pcf8591 = PCF8591(0x48, i2c) if not pcf8591.begin(): print("PCF8591 not found") else: with open('test.txt', 'w') as file: for value in range(256): pcf8591.analog_write(value) utime.sleep_ms(10) read_value = pcf8591.analog_read(pcf8591.AIN0) file.write(f"{value}, {read_value}\n") print(f"Written: {value}, Read: {read_value}") utime.sleep_ms(10) print("TEST FINISHED")
And part of result:
Written: 49, Read: 128 Written: 50, Read: 128 Written: 51, Read: 128 Written: 52, Read: 128 Written: 53, Read: 128 Written: 54, Read: 128 Written: 55, Read: 128 Written: 56, Read: 128 Written: 57, Read: 128 Written: 58, Read: 128 Written: 59, Read: 128 Written: 60, Read: 128 Written: 61, Read: 128 Written: 62, Read: 128 Written: 63, Read: 128 Written: 64, Read: 128
During the test, I connected the AOUT and AIN0 ports and no error in wiring. And when the read and write functions are tested separately(both analog and voltage), the oscilloscope can also see the changes in the AOUT port. However, the AIN port cannot correctly read the waveform generated by another function generator.
I also tried whether it was a problem with the Raspberry Pi pico, but when I connected the AOUT port of the PCF8591 to the pico’s internal AD converter, it could read the changes in the waveform normally.
If there is no problem with the program, maybe there is some conflict in the hardware? Between PCF8591 and Raspberry Pi picow ?5 November 2023 at 00:35 in reply to: MicroPython I2C PCF8591 round value problem Raspberry Pi Pico #28004The AOUT port is good, analog/voltage write can output correct value, but there are some problem with the analog/voltage reading of all AIN port.
5 November 2023 at 00:26 in reply to: MicroPython I2C PCF8591 round value problem Raspberry Pi Pico #28003Hello!
I encountered the same problem, although I used the updated version 0.02, it seems that the situation has not changed: my pcf8591 still only reads three values 64, 128, 192. The microcontroller is a Raspberry Pi pico w, Using micropython and ThonyyIDE, is there any solution? Thank you so much -
AuthorPosts