<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to LREAL from four WORDs?</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/518d01ae30/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/518d01ae30/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/518d01ae30/</id><updated>2022-11-18T11:57:51.294000Z</updated><subtitle>Recent posts to LREAL from four WORDs?</subtitle><entry><title>LREAL from four WORDs?</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/518d01ae30/?limit=25#e598" rel="alternate"/><published>2022-11-18T11:57:51.294000Z</published><updated>2022-11-18T11:57:51.294000Z</updated><author><name>ignat</name><uri>https://forge.codesys.com/u/ignat/</uri></author><id>https://forge.codesys.com8c84bcb10214d19caf78ea5a63dfc35f1ceab625</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;if it is about modbus you could try first the following:&lt;/p&gt;
&lt;p&gt;1) in the settings of the channel set length of reading 4. So in the Mapping it shows like ARRAY&lt;span&gt;[0..3]&lt;/span&gt; OF WORD&lt;br/&gt;
2) when map this value directly to LREAL variable.&lt;/p&gt;
&lt;p&gt;Must be tested, but it works for me for REAL values. In the channel settings like ARRAY &lt;span&gt;[0..1]&lt;/span&gt; OF WORD but can be directly mapped to REAL var (Codesys &amp;gt; 3.5.12)&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>LREAL from four WORDs?</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/518d01ae30/?limit=25#1637" rel="alternate"/><published>2022-11-17T08:24:31.054000Z</published><updated>2022-11-17T08:24:31.054000Z</updated><author><name>paulpotat</name><uri>https://forge.codesys.com/u/paulpotat/</uri></author><id>https://forge.codesys.com371b326dff55e96d110911ad4e696193400c620e</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I would create a type like this :&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;TYPE LREAL_WORD :&lt;/span&gt;
&lt;span class="err"&gt;  UNION&lt;/span&gt;
&lt;span class="err"&gt;    value : LREAL;    // Needs 8 Bytes in memory&lt;/span&gt;
&lt;span class="err"&gt;    regs : ARRAY [0..3] OF WORD;&lt;/span&gt;
&lt;span class="err"&gt;  END_UNION&lt;/span&gt;
&lt;span class="err"&gt;END_TYPE&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Then in your program you can declare your variables like this :&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;my_var&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;LREAL_WORD&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;reg_1&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;WORD&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;reg_2&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;WORD&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;reg_3&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;WORD&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;reg_4&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;WORD&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// ...&lt;/span&gt;

&lt;span class="c1"&gt;// Maybe you'll have to change the order here...&lt;/span&gt;
&lt;span class="n"&gt;my_var&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;regs&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="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;reg_1&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;my_var&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;regs&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="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;reg_2&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;my_var&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;regs&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="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;reg_3&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;my_var&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;regs&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;reg_4&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Then it will automatically update &lt;code&gt;my_var.value&lt;/code&gt; to the corresponding LREAL value (Beware of the endianess of the value though).&lt;br/&gt;
It should work but I've never tested this with WORD, only did it with BYTE...&lt;/p&gt;
&lt;p&gt;Hope this helps !&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>LREAL from four WORDs?</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/518d01ae30/?limit=25#31ae" rel="alternate"/><published>2022-11-17T06:53:44.804000Z</published><updated>2022-11-17T06:53:44.804000Z</updated><author><name>hajduk</name><uri>https://forge.codesys.com/u/esotericsystems/</uri></author><id>https://forge.codesys.come955bb416a3e0ca71ff0db075071658142170a04</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I need to take 4 registers and assemble them to a LREAL. I don't know bit order so I may been have to invert all the bits.&lt;/p&gt;
&lt;p&gt;What's the best approach to this? Tried and don't think Example_LREAL AT %IW4 : LREAL will read in the 4 WORDs.. Do I create an array, address that memory pointer and read it in that way?&lt;/p&gt;
&lt;p&gt;Looking for advice/example, have never manipulated LREALs before..&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>