<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to I2C - PCF8591 - 8-bit A/D and D/A converter</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/256d0e756f/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Runtime/thread/256d0e756f/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Runtime/thread/256d0e756f/</id><updated>2021-05-22T16:46:39.429000Z</updated><subtitle>Recent posts to I2C - PCF8591 - 8-bit A/D and D/A converter</subtitle><entry><title>I2C - PCF8591 - 8-bit A/D and D/A converter</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/256d0e756f/?limit=25#a68f" rel="alternate"/><published>2021-05-22T16:46:39.429000Z</published><updated>2021-05-22T16:46:39.429000Z</updated><author><name>abner</name><uri>https://forge.codesys.com/u/abner/</uri></author><id>https://forge.codesys.come331d1ff9da08c3c20aa33ecb406657893299cf9</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi, did you could work with the Analog Output?&lt;br/&gt;
I can´t find the way to work with it.&lt;br/&gt;
I am using a pre-configured module, now I can read the 4 Analog Inputs but I can´t write anything to the AOut...&lt;br/&gt;
What I am doing is setting a value of 255 on variable "out", the unique thing that I see is that change the value of my AN0,AN1,... but I get 0V on the Output...&lt;br/&gt;
I don´t know if it is something bad in the Library&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>I2C - PCF8591 - 8-bit A/D and D/A converter</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/256d0e756f/?limit=25#a4f2" rel="alternate"/><published>2020-02-27T16:44:38.683000Z</published><updated>2020-02-27T16:44:38.683000Z</updated><author><name>klima</name><uri>https://forge.codesys.com/u/klima/</uri></author><id>https://forge.codesys.com714ffc442a853cae3a3916c614c43aeb7b0becae</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Working all is on Forum Repo ;] &lt;br/&gt;
 l &lt;a class="" href="https://forum.codesys.com/viewtopic.php?f=23&amp;amp;t=5872&amp;amp;x=10868&amp;amp;p=11015&amp;amp;lan=en" rel="nofollow"&gt;viewtopic.php?f=23&amp;amp;t=5872&amp;amp;p=10868#p11015&lt;/a&gt; l &lt;br/&gt;
The End.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>I2C - PCF8591 - 8-bit A/D and D/A converter</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/256d0e756f/?limit=25#65b2" rel="alternate"/><published>2020-02-27T16:44:37.794000Z</published><updated>2020-02-27T16:44:37.794000Z</updated><author><name>klima</name><uri>https://forge.codesys.com/u/klima/</uri></author><id>https://forge.codesys.com406597190ab9c3445e4e9b4c41fcd9161677dbc8</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Ok im only can read from one input like &lt;/p&gt;
&lt;p&gt;PCF8591.in0 or 1 or 2 or 3 switching to PCF8591.control :=16#40/41/42/43 &lt;/p&gt;
&lt;p&gt;How to read all ?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>I2C - PCF8591 - 8-bit A/D and D/A converter</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/256d0e756f/?limit=25#cdfc" rel="alternate"/><published>2020-02-27T16:44:35.243000Z</published><updated>2020-02-27T16:44:35.243000Z</updated><author><name>christos</name><uri>https://forge.codesys.com/u/christos/</uri></author><id>https://forge.codesys.coma8eff830c58b9a795807551b5023cbfd4114e845</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I solved it forgot to write an address on my PCF8591 device.&lt;/p&gt;
&lt;p&gt;Address the device you add under the I2C master with the value 16#48&lt;/p&gt;
&lt;p&gt;and just make an ST POU and write:&lt;/p&gt;
&lt;p&gt;input0 := BYTE_TO_REAL (PCF8591.IN_A);&lt;/p&gt;
&lt;p&gt;and you should get a value on IN_A if you connected something to the first port on the IC.&lt;/p&gt;
&lt;p&gt;//Christos&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>I2C - PCF8591 - 8-bit A/D and D/A converter</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/256d0e756f/?limit=25#4544" rel="alternate"/><published>2020-02-27T16:44:34.334000Z</published><updated>2020-02-27T16:44:34.334000Z</updated><author><name>christos</name><uri>https://forge.codesys.com/u/christos/</uri></author><id>https://forge.codesys.com447df29a681eb6a8a6f8e93e3dc9616607fb0de4</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I just wrote a program in python and tried out the PCF8591 with a potentiometer connected to the first port and the program ran nicely everything worked. So i know now the ic works 100%. But i can still not get it to work in codesys Ive added an i2c master and under that the device PCF8591 wich i downloaded from the forum. Part of the problem is i cant understand the functionblock 100% as I understand it know you want me to send the init byte to PCF8591.CNF and that will activate the ports to be able to recive data. Right now im running and ST program that looks like this:&lt;/p&gt;
&lt;p&gt;PCF8591.CNF := 16#48;&lt;/p&gt;
&lt;p&gt;Potentiometer := BYTE_TO_LREAL(PCF8591.IN_A);&lt;br/&gt;
Potentiometer1 := BYTE_TO_LREAL(PCF8591.IN_B);&lt;br/&gt;
Potentiometer2 := BYTE_TO_LREAL(PCF8591.IN_C);&lt;br/&gt;
Potentiometer2 := BYTE_TO_LREAL(PCF8591.IN_D);&lt;/p&gt;
&lt;p&gt;Im out of ideas, so i hope someone on the forum have any.&lt;/p&gt;
&lt;p&gt;//Christos&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>I2C - PCF8591 - 8-bit A/D and D/A converter</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/256d0e756f/?limit=25#6ab7" rel="alternate"/><published>2020-02-27T16:44:33.435000Z</published><updated>2020-02-27T16:44:33.435000Z</updated><author><name>christos</name><uri>https://forge.codesys.com/u/christos/</uri></author><id>https://forge.codesys.com1a52f90d5d7ae12fc6364a5ed98949ee10504408</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I have the same problem i cant get PCF8591 to send a signal from my potentiometer&lt;/p&gt;
&lt;p&gt;im useing this code in a ST POU&lt;/p&gt;
&lt;p&gt;PROGRAM PCF8591_Test&lt;br/&gt;
VAR&lt;br/&gt;
    Potentiometer : LREAL;&lt;br/&gt;
END_VAR&lt;/p&gt;
&lt;p&gt;PCF8591.CNF := 16#40;&lt;br/&gt;
Potentiometer := BYTE_TO_LREAL(PCF8591.IN_A);&lt;/p&gt;
&lt;p&gt;//Christos&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>I2C - PCF8591 - 8-bit A/D and D/A converter</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/256d0e756f/?limit=25#7339" rel="alternate"/><published>2020-02-27T16:44:30.866000Z</published><updated>2020-02-27T16:44:30.866000Z</updated><author><name>eschwellinger</name><uri>https://forge.codesys.com/u/eschwellinger/</uri></author><id>https://forge.codesys.com28a580fba0a65d69f75165b9e269efb006cc1ac5</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;we need more description, what exactly does not work,&lt;br/&gt;
any screenshot of debugging it, would be great.&lt;/p&gt;
&lt;p&gt;BR&lt;br/&gt;
Edwin&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>I2C - PCF8591 - 8-bit A/D and D/A converter</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/256d0e756f/?limit=25#3111" rel="alternate"/><published>2020-02-27T16:44:29.967000Z</published><updated>2020-02-27T16:44:29.967000Z</updated><author><name>kdebu</name><uri>https://forge.codesys.com/u/kdebu/</uri></author><id>https://forge.codesys.com5ac1afa22a7c6e072de8d8f374fed6083f48dc0c</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello Zdenko,&lt;/p&gt;
&lt;p&gt;i updated my project (see attached file(s)) but it still doesn't work...   &lt;/p&gt;
&lt;p&gt;I think the program logic should be correct... Please take a look again.&lt;/p&gt;
&lt;p&gt;BR&lt;br/&gt;
kdebu&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="https://forum.codesys.com//download/file.php?id=668" rel="nofollow"&gt;PCF8591.zip &lt;span&gt;&lt;span&gt;[275.49 KiB]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>I2C - PCF8591 - 8-bit A/D and D/A converter</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/256d0e756f/?limit=25#4a94" rel="alternate"/><published>2020-02-27T16:44:27.389000Z</published><updated>2020-02-27T16:44:27.389000Z</updated><author><name>switcher</name><uri>https://forge.codesys.com/u/switcher/</uri></author><id>https://forge.codesys.comf0dd506e65d55711e9021e39118f13576c5da27f</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi Kdebu,&lt;/p&gt;
&lt;p&gt;yes, you are right. To enable DAC you have to write 0x40 into control register. I missed one bit.&lt;/p&gt;
&lt;p&gt;But in your case, you are not writing this value in the device control register nowhere. Please make sure that write value to control register will be performed before reading/writing DAC/ADCs.&lt;/p&gt;
&lt;p&gt;BR&lt;br/&gt;
Zdenko.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>I2C - PCF8591 - 8-bit A/D and D/A converter</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/256d0e756f/?limit=25#56b5" rel="alternate"/><published>2020-02-27T16:44:26.447000Z</published><updated>2020-02-27T16:44:26.447000Z</updated><author><name>kdebu</name><uri>https://forge.codesys.com/u/kdebu/</uri></author><id>https://forge.codesys.comc0594602f2d927a3270053d4c4481c2d0a8e35fa</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi Zdenko,&lt;/p&gt;
&lt;p&gt;To enable the DAC i have to write 0x40 (0&lt;strong&gt;1&lt;/strong&gt;00 0000) into the control register.&lt;/p&gt;
&lt;p&gt;Reading AIN0: 0x00 (or 0x40 with enabled DAC) - single ended input&lt;br/&gt;
Reading AIN1: 0x01 (or 0x41 with enabled DAC) - single ended input&lt;br/&gt;
Reading AIN2: 0x02 (or 0x42 with enabled DAC) - single ended input&lt;br/&gt;
Reading AIN3: 0x03 (or 0x43 with enabled DAC) - single ended input&lt;/p&gt;
&lt;p&gt;The device address 0x4F must be correct. A0, A1 and A2 are connected to Vdd. I checked this also with i2c-tools.&lt;/p&gt;
&lt;p&gt;Reading the ADC-inputs and writing into the DAC-register still does not work correctly. The read ADC-values and the DAC-output voltage (measured with a multimeter) are not correct.&lt;/p&gt;
&lt;p&gt;I checked the function of my board with a c- and python-script. The PCF8591 worked correctly... So it must be a "CODESYS-problem". &lt;/p&gt;
&lt;p&gt;BR&lt;br/&gt;
kdebu&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>