<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Home</title><link>https://forge.codesys.com/drv/i2c-te-m3200/home/Home/</link><description>Recent changes to Home</description><language>en</language><lastBuildDate>Thu, 25 Aug 2022 03:51:04 -0000</lastBuildDate><atom:link href="https://forge.codesys.com/drv/i2c-te-m3200/home/Home/feed" rel="self" type="application/rss+xml"></atom:link><item><title>Home modified by drewegatti</title><link>https://forge.codesys.com/drv/i2c-te-m3200/home/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v1
+++ v2
@@ -1,7 +1,140 @@
-Welcome to your wiki!
+I tried to integrate the Sensor into the Device Library but gave up because reading it direct form the device is easier

-This is the default page, edit it as you see fit. To add a new page simply reference it within brackets, e.g.: [SamplePage].
+Enable usage in CODESYS
+installing the i2c software tools after connecting
+the hardware and activation of the i2c bus.

-The wiki uses [Markdown](/drv/i2c-te-m3200/home/markdown_syntax/) syntax.
+~~~
+sudo raspi-config
+~~~
+Choose Advanced Options -&amp;gt; "activate I2C" -&amp;gt; "Yes" and exit the tool.
+Now update the repository and install i2c-tools
+
+~~~
+sudo apt-get update
+sudo apt-get install i2c-tools
+~~~
+
+check the addressing/connections
+Once you have it installed check that the RTC has been detected using:
+
+~~~
+sudo i2cdetect -y 0  # (if using Raspberry Pi 1 or)
+sudo i2cdetect -y 1  # (if using Raspberry Pi 2 or later)
+~~~
+
+Note:
+The MC3200 has 4 possible i2c addresses in my case it is 0x28.
+This output should now look something like this;
+
+admin@CodesysPLC:~ $ i2cdetect -r -y 1
+     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
+00:                         -- -- -- -- -- -- -- --
+10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+20: -- -- -- -- -- -- -- -- 28 -- -- -- -- -- -- --
+30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
+70: -- -- -- -- -- -- -- --
+
+*Make sure to convert this address to decimal from Hex*
+
+~~~
+//Pressure Sensor Structure
+TYPE M3200 :
+   STRUCT
+       //Device Setup
+       Address : USINT; //In Decimal Form
+       WriteBuffer : BYTE := 1;
+       ReadBuffer : ARRAY [0..15] OF BYTE  := [15(0)];
+       WriteLength : DINT;
+       ReadLenght: DINT;
+   
+       
+       Praw : UINT;
+       Pmax : REAL;
+       Pmin : REAL;
+       PSI : REAL;
+   
+       Traw : UINT;
+       Tmax : REAL;
+       Tmin : REAL;
+       TEMP : REAL;
+   END_STRUCT
+END_TYPE
+~~~
+
+~~~
+//Structure Declaration
+
+PROGRAM PressureCRTL
+VAR
+   S01 : M3200; 
+END_VAR
+~~~
+
+
+~~~
+//Program
+
+//Device Setup
+S01.Address := 40; //In Decimal Form
+S01.Pmax := 100;
+S01.Pmin := 0;
+S01.Tmax := 131;
+S01.Tmin := 32;
+
+
+
+//Write Register to Initiate Communications    
+S01.WriteLength := I2C_master.write(S01.Address, ADR(S01.WriteBuffer), 1); 
+
+//Read Register into Bytes
+S01.ReadLenght := I2C_master.read(S01.Address, ADR(S01.ReadBuffer), 4);
+
+
+
+//Map Bytes to Int
+S01.Praw.0 := S01.ReadBuffer[1].0;
+S01.Praw.1 := S01.ReadBuffer[1].1;
+S01.Praw.2 := S01.ReadBuffer[1].2;
+S01.Praw.3 := S01.ReadBuffer[1].3;
+S01.Praw.4 := S01.ReadBuffer[1].4;
+S01.Praw.5 := S01.ReadBuffer[1].5;
+S01.Praw.6 := S01.ReadBuffer[1].6;
+S01.Praw.7 := S01.ReadBuffer[1].7;
+S01.Praw.8 := S01.ReadBuffer[0].0;
+S01.Praw.9 := S01.ReadBuffer[0].1;
+S01.Praw.10 := S01.ReadBuffer[0].2;
+S01.Praw.11 := S01.ReadBuffer[0].3;
+S01.Praw.12 := S01.ReadBuffer[0].4;
+S01.Praw.13 := S01.ReadBuffer[0].5;
+
+//CONVERT
+S01.PSI := ((((S01.Pmax - S01.Pmin) / 14000.0) * (S01.Praw - 1000.0)) + S01.Pmin);
+
+
+
+//Map Bytes to Int
+S01.Traw.0 := S01.ReadBuffer[3].5;
+S01.Traw.1 := S01.ReadBuffer[3].6;
+S01.Traw.2 := S01.ReadBuffer[3].7;
+S01.Traw.3 := S01.ReadBuffer[2].0;
+S01.Traw.4 := S01.ReadBuffer[2].1;
+S01.Traw.5 := S01.ReadBuffer[2].2;
+S01.Traw.6 := S01.ReadBuffer[2].3;
+S01.Traw.7 := S01.ReadBuffer[2].4;
+S01.Traw.8 := S01.ReadBuffer[2].5;
+S01.Traw.9 := S01.ReadBuffer[2].6;
+S01.Traw.10 := S01.ReadBuffer[2].7;
+
+//CONVERT
+S01.TEMP := ((((S01.Tmax - S01.Tmin) / 563.0) * (S01.Traw - 512.0)) + S01.Tmin);
+~~~
+
+
+

 [[members limit=20]]
+[[download_button]]
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">drewegatti</dc:creator><pubDate>Thu, 25 Aug 2022 03:51:04 -0000</pubDate><guid isPermaLink="false">https://forge.codesys.com246fb48b95aeb10559e2c5c0bc5aaa2b9029b1e9</guid></item><item><title>Home modified by drewegatti</title><link>https://forge.codesys.com/drv/i2c-te-m3200/home/Home/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Welcome to your wiki!&lt;/p&gt;
&lt;p&gt;This is the default page, edit it as you see fit. To add a new page simply reference it within brackets, e.g.: &lt;span&gt;[SamplePage]&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;The wiki uses &lt;a class="" href="/drv/i2c-te-m3200/home/markdown_syntax/"&gt;Markdown&lt;/a&gt; syntax.&lt;/p&gt;
&lt;h6&gt;Project Members:&lt;/h6&gt;
	&lt;ul class="md-users-list"&gt;
		&lt;li&gt;&lt;a href="/u/drewegatti/"&gt;drewegatti&lt;/a&gt; (admin)&lt;/li&gt;
		
	&lt;/ul&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">drewegatti</dc:creator><pubDate>Wed, 24 Aug 2022 05:31:43 -0000</pubDate><guid isPermaLink="false">https://forge.codesys.com85a429ddde66184e09e3fbc7c06dccf134a4c449</guid></item></channel></rss>