PCF8591 AD-Wandler Analog-Digital

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Franzel007
Normal user
Posts: 4
Joined: 01 Aug 2021, 16:18

PCF8591 AD-Wandler Analog-Digital

#1 Post by Franzel007 » 01 Aug 2021, 16:25

A nice hello,
I connected three A / D converters PCF8591 to an ESP32 via I2C. The addresses are also displayed in the I2C scanner as specified 0x48, 0x49 and 0x4A.
Which port belongs to which address, since I can't select the address? I suspect port 0-3 and port 8-11 but unfortunately I won't be able to use the third one.

Can you help me please?

Greeting Franzel

TD-er
Core team member
Posts: 5373
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: PCF8591 AD-Wandler Analog-Digital

#2 Post by TD-er » 01 Aug 2021, 18:28

Ah yeah that one is still on my mental "todo" list as the addressing is just rediculous from a user point of view.

Code: Select all

      uint8_t unit       = (CONFIG_PORT - 1) / 4;
      uint8_t port       = CONFIG_PORT - (unit * 4);
      uint8_t address = 0x48 + unit;
CONFIG_PORT is the "port" you set in the task configuration.

So the lower 2 bits are the port of the chip and the upper bits are added to the base address.

0...3 -> 0x48
4...7 -> 0x49
8...11 -> 0x4A
etc.

Franzel007
Normal user
Posts: 4
Joined: 01 Aug 2021, 16:18

Re: PCF8591 AD-Wandler Analog-Digital

#3 Post by Franzel007 » 03 Aug 2021, 10:20

Thanks a lot.
That´s nice

Regards
Franzel

User avatar
Ath
Normal user
Posts: 1090
Joined: 10 Jun 2018, 12:06
Location: NL

Re: PCF8591 AD-Wandler Analog-Digital

#4 Post by Ath » 03 Aug 2021, 15:26

I've created a pull-request ([urlhttps://github.com/letscontrolit/ESPEasy/pull/3734]#3734[/url]) to improve the UI on this selection:

Address selection:
P007_I2CAddressOptions.png
P007_I2CAddressOptions.png (32.63 KiB) Viewed 1217 times
Port selection:
P007_PortOptions.png
P007_PortOptions.png (17.93 KiB) Viewed 1217 times
/Ton

User avatar
Ath
Normal user
Posts: 1090
Joined: 10 Jun 2018, 12:06
Location: NL

Re: PCF8591 AD-Wandler Analog-Digital

#5 Post by Ath » 03 Aug 2021, 16:50

Franzel007 wrote: 03 Aug 2021, 10:20 Thanks a lot.
That´s nice
Hi Franzel,

Does that addressing actually match? From my testing I'd expect the Port -> unit calculation to be like:

1...4 -> 0x48
5...8 -> 0x49
9...12 -> 0x4A

Can you please confirm if using Port 1 is actually reading A0, and Port 2 A1, etc? (I expect that Port 0 and Port 1 are both reading the A0 input on the first PCF8591)
/Ton

Franzel007
Normal user
Posts: 4
Joined: 01 Aug 2021, 16:18

Re: PCF8591 AD-Wandler Analog-Digital

#6 Post by Franzel007 » 08 Aug 2021, 17:21

Hihi,

where can I download the new version. I don not find it.
If I can download the new file I will test it this week.

Regards
Franzel

User avatar
Ath
Normal user
Posts: 1090
Joined: 10 Jun 2018, 12:06
Location: NL

Re: PCF8591 AD-Wandler Analog-Digital

#7 Post by Ath » 08 Aug 2021, 18:43

What .bin file have you installed on your ESP? Then I can fetch the same from the Github actions build.

Edit: The original PR has already been merged into the 'mega' branch (current active ESPEasy branch, comparable to the usually used 'master') but not yet released. I have also added a PR to enable 1..4 measured values instead of only 1, that you are very much invited to test ;) I'll provide a .bin from that instead.
/Ton

User avatar
Ath
Normal user
Posts: 1090
Joined: 10 Jun 2018, 12:06
Location: NL

Re: PCF8591 AD-Wandler Analog-Digital

#8 Post by Ath » 08 Aug 2021, 20:06

I've guessed, based on earlier messages, that a ESP32_normal should do :)
ESPEasy_normal_ESP32_4M316k.zip
(1.85 MiB) Downloaded 19 times
(Removed the ELF file because of upload size restrictions)
/Ton

Franzel007
Normal user
Posts: 4
Joined: 01 Aug 2021, 16:18

Re: PCF8591 AD-Wandler Analog-Digital

#9 Post by Franzel007 » 22 Aug 2021, 15:00

Hihi,
sorry for the late feedback but I must go to an job traveling.
I have tested the new version and I think the most things are ok.
I have a little problem that the channel 0 and 1 on the adress 0x48 change the value syncron and not seperatly.
The second problem was that the display 2004 on i2c stop the funktion after several days. If I cut the power the ESP32 funktion with the display ist ok for more days.

Thanks and regards
Franzel

User avatar
Ath
Normal user
Posts: 1090
Joined: 10 Jun 2018, 12:06
Location: NL

Re: PCF8591 AD-Wandler Analog-Digital

#10 Post by Ath » 24 Aug 2021, 22:22

I've been working on other stuff, so this is a little bit neglected, I'm afraid. I'll see what I can do to investigate and possibly fix.

The I2C freezing can have several issues, and there is an open PR to detect and fix that, not sure when that will be picked up again, but it could be helpful here.
You are using pull-up resistors on both the I2C SDA and SCL lines, I assume? When they are not used, that could also cause bus-issues.
/Ton

User avatar
Ath
Normal user
Posts: 1090
Joined: 10 Jun 2018, 12:06
Location: NL

Re: PCF8591 AD-Wandler Analog-Digital

#11 Post by Ath » 27 Aug 2021, 15:23

I have done tests and a little investigation (browsing the chip specs), and the result is that for this device the 'Force Slow I2C Speed' checkbox must be enabled to get reliable measurements. At least when reading multiple ports, but as the chip specification states it has a max. I2C clock frequency of 100 kHz, it is safe to assume it doesn't support the ESPEasy standard I2C Clock Speed of 400 kHz. I've updated the documentation to reflect this.
/Ton

Post Reply

Who is online

Users browsing this forum: No registered users and 25 guests