<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to How to read I2C without specified device from FB</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/010acaa90c/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Runtime/thread/010acaa90c/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Runtime/thread/010acaa90c/</id><updated>2023-01-05T13:30:24.358000Z</updated><subtitle>Recent posts to How to read I2C without specified device from FB</subtitle><entry><title>How to read I2C without specified device from FB</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/010acaa90c/?limit=25#7e34/e9ce" rel="alternate"/><published>2023-01-05T13:30:24.358000Z</published><updated>2023-01-05T13:30:24.358000Z</updated><author><name>shinxis</name><uri>https://forge.codesys.com/u/shinxis/</uri></author><id>https://forge.codesys.com83745f3aa529d30d84c11dbe6a559e18ea89af5e</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi! I'm a newbie and spent too much time with the same problem. Here's a solution that hopefully saves some time for someone else.&lt;/p&gt;
&lt;p&gt;First of all, add I2C Library; Choose Library Manager device, click Add Library button, search for i2c and select "i2c". Right-click I2C in the Devices list, select Add Device, I2C master. We can now use the functions in the Raspberry Pi Peripherals package (included in Codesys) or whatever you're on. Here's two function Blocks that'll do the magic. &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="nt"&gt;----------&lt;/span&gt; &lt;span class="nt"&gt;PLC_PRG&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;Defines&lt;/span&gt;
&lt;span class="nt"&gt;I2C_read&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nd"&gt;I2C_read&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;I2C_write&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nd"&gt;I2C_write&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="nt"&gt;----------&lt;/span&gt; &lt;span class="nt"&gt;PLC_PRG&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;The&lt;/span&gt; &lt;span class="nt"&gt;code&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;Here&lt;/span&gt; &lt;span class="nt"&gt;you&lt;/span&gt; &lt;span class="nt"&gt;call&lt;/span&gt; &lt;span class="nt"&gt;them&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="nt"&gt;I2C_read&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;Device&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="nt"&gt;Register&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="nt"&gt;Data&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="nt"&gt;I2C_write&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;Device&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="nt"&gt;Register&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="nt"&gt;Data&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

&lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="nt"&gt;----------&lt;/span&gt; &lt;span class="nt"&gt;READING&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;Defines&lt;/span&gt;
&lt;span class="nt"&gt;FUNCTION_BLOCK&lt;/span&gt; &lt;span class="nt"&gt;I2C_read&lt;/span&gt; &lt;span class="nt"&gt;EXTENDS&lt;/span&gt; &lt;span class="nt"&gt;i2c&lt;/span&gt;
&lt;span class="nt"&gt;VAR_INPUT&lt;/span&gt;
    &lt;span class="nt"&gt;Device&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nd"&gt;BYTE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;   &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="nt"&gt;Example&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;16&lt;/span&gt;&lt;span class="p"&gt;#&lt;/span&gt;&lt;span class="nn"&gt;76&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;BMP280&lt;/span&gt; &lt;span class="nt"&gt;pressure&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nt"&gt;temperature&lt;/span&gt; &lt;span class="nt"&gt;sensor&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="nt"&gt;Register&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nd"&gt;BYTE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="nt"&gt;Example&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;16&lt;/span&gt;&lt;span class="p"&gt;#&lt;/span&gt;&lt;span class="nn"&gt;D0&lt;/span&gt;
&lt;span class="nt"&gt;END_VAR&lt;/span&gt;
&lt;span class="nt"&gt;VAR_OUTPUT&lt;/span&gt;
    &lt;span class="nt"&gt;Data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nd"&gt;BYTE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;     &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="nt"&gt;Example&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;16&lt;/span&gt;&lt;span class="p"&gt;#&lt;/span&gt;&lt;span class="nn"&gt;58&lt;/span&gt;
&lt;span class="nt"&gt;END_VAR&lt;/span&gt;
&lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="nt"&gt;----------&lt;/span&gt; &lt;span class="nt"&gt;READING&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;The&lt;/span&gt; &lt;span class="nt"&gt;code&lt;/span&gt;
&lt;span class="nt"&gt;SUPER&lt;/span&gt;&lt;span class="o"&gt;^();&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="nt"&gt;Needed&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;because&lt;/span&gt; &lt;span class="nt"&gt;of&lt;/span&gt; &lt;span class="s1"&gt;'EXTENDS'&lt;/span&gt; &lt;span class="nt"&gt;in&lt;/span&gt; &lt;span class="nt"&gt;the&lt;/span&gt; &lt;span class="nt"&gt;defines&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;
&lt;span class="nt"&gt;I2C_master&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;write&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;usiAddress&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nt"&gt;Device&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;pbyBuffer&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;ADR&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;Register&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt; &lt;span class="nt"&gt;nBufferLen&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;1&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="nt"&gt;I2C_master&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;read&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;usiAddress&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nt"&gt;Device&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;pbyBuffer&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;ADR&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;Data&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt; &lt;span class="nt"&gt;nBufferLen&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;1&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; 

&lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="nt"&gt;----------&lt;/span&gt; &lt;span class="nt"&gt;WRITING&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;Defines&lt;/span&gt;
&lt;span class="nt"&gt;SUPER&lt;/span&gt;&lt;span class="o"&gt;^();&lt;/span&gt;
&lt;span class="nt"&gt;FUNCTION_BLOCK&lt;/span&gt; &lt;span class="nt"&gt;I2C_write&lt;/span&gt; &lt;span class="nt"&gt;EXTENDS&lt;/span&gt; &lt;span class="nt"&gt;i2c&lt;/span&gt;
&lt;span class="nt"&gt;VAR_INPUT&lt;/span&gt;
    &lt;span class="nt"&gt;Device&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nd"&gt;BYTE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nt"&gt;Register&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nd"&gt;BYTE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nt"&gt;Data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nd"&gt;BYTE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;END_VAR&lt;/span&gt;
&lt;span class="nt"&gt;VAR&lt;/span&gt;
    &lt;span class="nt"&gt;WriteOutBuffer&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;ARRAY&lt;/span&gt;&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="nx"&gt;..1&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt; &lt;span class="nt"&gt;OF&lt;/span&gt; &lt;span class="nt"&gt;BYTE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;END_VAR&lt;/span&gt;
&lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="nt"&gt;----------&lt;/span&gt; &lt;span class="nt"&gt;WRITING&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;The&lt;/span&gt; &lt;span class="nt"&gt;code&lt;/span&gt;
&lt;span class="nt"&gt;WriteOutBuffer&lt;/span&gt;&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nt"&gt;Register&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;WriteOutBuffer&lt;/span&gt;&lt;span class="cp"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="cp"&gt;]&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nt"&gt;Data&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;I2C_master&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;write&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;usiAddress&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nt"&gt;Device&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;pbyBuffer&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;ADR&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;WriteOutBuffer&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt; &lt;span class="nt"&gt;nBufferLen&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;2&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; 
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</summary></entry><entry><title>How to read I2C without specified device from FB</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/010acaa90c/?limit=25#470d/ec5c/2b17/cc31/9a44/1e96/417c" rel="alternate"/><published>2021-03-24T22:29:26.720000Z</published><updated>2021-03-24T22:29:26.720000Z</updated><author><name>powertrick</name><uri>https://forge.codesys.com/u/powertrick/</uri></author><id>https://forge.codesys.comd21666db5d547b3bd9c7e490a42709287f734a79</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;After a lot of frustration the key to us getting this working well was to practice with I2Ctools until we knew exactly what we were doing.  We then took several weeks to develop a rubust FB that could be controlled through a OOP method interface for 8 or 16 bits and a few other features.  In our FB we added small/big endian support with Pragma IF statements by simply switching the datatostore&lt;a class="alink" href="/forge/talk-ru/1/"&gt;[1]&lt;/a&gt; and datatostore&lt;a class="alink" href="/forge/talk-ru/2/"&gt;[2]&lt;/a&gt; around.  As I2C to Azure is the crux of our application it was the best thing we did to spend a lot of time with our I2C FB until it was robust.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>How to read I2C without specified device from FB</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/010acaa90c/?limit=25#470d/ec5c/2b17/cc31/9a44/1e96" rel="alternate"/><published>2021-03-24T13:31:35.284000Z</published><updated>2021-03-24T13:31:35.284000Z</updated><author><name>krishemanth</name><uri>https://forge.codesys.com/u/krishemanth/</uri></author><id>https://forge.codesys.com25e6b2cc936495c26c6c5dc008adce1709fbadf0</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;powertrick Thank you for having patience and supporting me. Above example helped me. &lt;/p&gt;
&lt;p&gt;Thanks,&lt;br/&gt;
-Kris.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>How to read I2C without specified device from FB</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/010acaa90c/?limit=25#470d/ec5c/2b17/cc31" rel="alternate"/><published>2021-03-23T10:06:48.946000Z</published><updated>2021-03-23T10:06:48.946000Z</updated><author><name>krishemanth</name><uri>https://forge.codesys.com/u/krishemanth/</uri></author><id>https://forge.codesys.com5e5ed4cc55e83427d6acaf4ff67760e0a6a4c994</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;powertrick thanks for your quick response&lt;br/&gt;
you mean i2cbus-number by the i2c part? or the slave device?&lt;/p&gt;
&lt;p&gt;its a controler stm with slave address of 0x18 on i2c-1 bus&lt;br/&gt;
iam doing something like i2cset -y 2 0x18 0x02 0x00 0x00 0x72 0x80 0x00 0x00 0x00 0x00 0x72 0x72 0x72 0x72 0x42 i from my target board.&lt;br/&gt;
how can i do the same from the codesys &lt;/p&gt;
&lt;p&gt;thanks in advance,&lt;br/&gt;
-kris&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>How to read I2C without specified device from FB</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/010acaa90c/?limit=25#470d/ec5c" rel="alternate"/><published>2021-03-23T07:29:15.910000Z</published><updated>2021-03-23T07:29:15.910000Z</updated><author><name>krishemanth</name><uri>https://forge.codesys.com/u/krishemanth/</uri></author><id>https://forge.codesys.com1ae2d8a326371650edf0e428539a20222f2b24d5</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi powertrick,&lt;br/&gt;
i am trying to read and write data to registers of a controller from my arm board through Codesys.&lt;br/&gt;
if you have managed to make it work, can you share the code. i couldn't find an example project for this.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;br/&gt;
-Kris&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>How to read I2C without specified device from FB</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/010acaa90c/?limit=25#28eb/f869" rel="alternate"/><published>2021-03-12T01:49:32.287000Z</published><updated>2021-03-12T01:49:32.287000Z</updated><author><name>audi0615</name><uri>https://forge.codesys.com/u/audi0615/</uri></author><id>https://forge.codesys.com4ae3ccf5b03b485068ab3883cfcc14ca6ff59805</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thanks for your reply&lt;br/&gt;
LSM303 accelerometer and magnetometer.&lt;br/&gt;
I have decided to use library + xml file.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>How to read I2C without specified device from FB</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/010acaa90c/?limit=25#28eb" rel="alternate"/><published>2021-03-10T19:17:13.702000Z</published><updated>2021-03-10T19:17:13.702000Z</updated><author><name>yledermann</name><uri>https://forge.codesys.com/u/yledermann/</uri></author><id>https://forge.codesys.com826c97d511e8711293ec01edbbb7fc2280cda6aa</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi &lt;a class="user-mention" href="/u/audi0615/"&gt;@audi0615&lt;/a&gt; and &lt;a class="user-mention" href="/u/powertrick/"&gt;@powertrick&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I just discovered your pm in my spam folder.&lt;/p&gt;
&lt;p&gt;Im sorry but im not using codesys with i2c at the moment.&lt;br/&gt;
and in 2018 i was just reading some bytes from a UPS Hat and never wrote to an i2c device.&lt;/p&gt;
&lt;p&gt;I have not that many experience with i2c.&lt;/p&gt;
&lt;p&gt;What kind of i2c device you want to write to?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>How to read I2C without specified device from FB</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/010acaa90c/?limit=25#d233" rel="alternate"/><published>2021-03-10T01:35:47.981000Z</published><updated>2021-03-10T01:35:47.981000Z</updated><author><name>powertrick</name><uri>https://forge.codesys.com/u/powertrick/</uri></author><id>https://forge.codesys.com75d8aa2af72dfc8945cfb3b307e186c46873c97a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Bear in mind the following:&lt;br/&gt;
We are interacting with a device with 16 bit data words so adjust accordingly for 8 bit data words&lt;br/&gt;
In our case we created a function method to read and a method to write the devices and this is not shown supporting small/big endian and also 8/16 bit data words so it can get very complex&lt;br/&gt;
We struggled so spent some time to master I2Cget and I2Cset (I2Ctools) on the linux terminal to cross check the device interaction..do this first and master it to save your sanity ie.&lt;br/&gt;
1) i2cset -y 0 0x68 0x15 0x8000 w //will set the data reg 21d as 0x8000 &lt;br/&gt;
2) i2cget -y 0 0x68 0x15 w //this will get the data in 16 bit format just written above...omit the 'w' for 8 bit words.  The '0' is our specific I2C port...maybe yours is 1 or 2 or 3&lt;br/&gt;
This cycles fast enough for us now at 10ms tasks to do repeated reads or writes however in future we will streamline this with a I2C bus analyzer to have repeats much faster.  Read generally can be fast although some device have a buffer write time of several ms so consult the datasheet of the device you are using.&lt;/p&gt;
&lt;p&gt;//ReadFromDevice method-Read from I2C device one 16bit word at a time&lt;br/&gt;
    I2C_master.write(16#68, 16#15, 1);&lt;br/&gt;
    I2C_master.read(16#68, ADR(datatostore), 2); //2 the is for 2 nibbles&lt;/p&gt;
&lt;p&gt;If you are using 16 bit data words then here is something as a guide from our code as the array needs to be in a 16 bit word&lt;br/&gt;
                datatostore&lt;a class="alink" href="/forge/talk-ru/1/"&gt;[1]&lt;/a&gt; := OSCAT_BASIC.BYTE_OF_DWORD (regdata_to_write, 0);          //Buffer low nibble of the 16 bit data word&lt;br/&gt;
                datatostore&lt;a class="alink" href="/forge/talk-ru/2/"&gt;[2]&lt;/a&gt; := OSCAT_BASIC.BYTE_OF_DWORD (regdata_to_write, 1);          //Buffer high nibble of the 16 bit data word&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>How to read I2C without specified device from FB</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/010acaa90c/?limit=25#470d/95b2" rel="alternate"/><published>2021-03-09T11:44:33.847000Z</published><updated>2021-03-09T11:44:33.847000Z</updated><author><name>audi0615</name><uri>https://forge.codesys.com/u/audi0615/</uri></author><id>https://forge.codesys.comcb1b5bd7411552d2b061720c1583b40312b7cb03</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi &lt;br/&gt;
Have you made it working?&lt;br/&gt;
I am also looking for how to write a value to a register with I2C Master write method.&lt;br/&gt;
I would appreciate if you can share your code.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>How to read I2C without specified device from FB</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/010acaa90c/?limit=25#470d" rel="alternate"/><published>2021-02-15T05:23:01.371000Z</published><updated>2021-02-15T05:23:01.371000Z</updated><author><name>powertrick</name><uri>https://forge.codesys.com/u/powertrick/</uri></author><id>https://forge.codesys.com04cbbe917b6b025458a9988ca2e643289f8ff232</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Yiedermann thank you for the snippet as my codesys is reading an i2c slave.....any chance you know how to write to a slave as I tried anything I could think of.  Seems the usage mimics the I2C method comparing the read so for write I tried below:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;datatoread&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;  &lt;span class="n"&gt;ARRAY&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;..&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="n"&gt;OF&lt;/span&gt; &lt;span class="n"&gt;BYTE&lt;/span&gt;  &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;)];&lt;/span&gt;

        &lt;span class="n"&gt;I2C_master&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;write&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="mi"&gt;68&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;  
        &lt;span class="n"&gt;I2C_master&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;write&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="mi"&gt;68&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ADR&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;datatostore&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</summary></entry></feed>