<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Converting hex bytes to float</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fe0aa83fc0/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fe0aa83fc0/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/fe0aa83fc0/</id><updated>2024-08-06T13:40:33.865000Z</updated><subtitle>Recent posts to Converting hex bytes to float</subtitle><entry><title>Converting hex bytes to float</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fe0aa83fc0/?limit=250#ff1e" rel="alternate"/><published>2024-08-06T13:40:33.865000Z</published><updated>2024-08-06T13:40:33.865000Z</updated><author><name>dkugler</name><uri>https://forge.codesys.com/u/dkugler/</uri></author><id>https://forge.codesys.comc1a8a7f62422d4d532dd70cbdca0924c1657fdff</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;have a look at UNIONs. With a union you are able to write single bytes to the same adress area which belongs to a float variable at the same time.&lt;br/&gt;
I like to do a lot of convertions belonging to interfaces and fieldbus in this way, f.eg. word / byte swapping etc.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Converting hex bytes to float</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fe0aa83fc0/?limit=25#fd3c" rel="alternate"/><published>2024-08-05T21:34:48.573000Z</published><updated>2024-08-05T21:34:48.573000Z</updated><author><name>robert-o</name><uri>https://forge.codesys.com/u/robert-o/</uri></author><id>https://forge.codesys.com2887b0fe60d8101eec481cb2055dc3ce715dee11</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Try OSCAT_BASIC and Function DW_TO_REAL. DWORD_OF_BYTE my although help.&lt;br/&gt;
The Lib is open and free. It is not necessary to add this Lib, you can use/copy the source code just to get an idea.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Converting hex bytes to float</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/fe0aa83fc0/?limit=25#0409" rel="alternate"/><published>2024-08-02T21:35:50.142000Z</published><updated>2024-08-02T21:35:50.142000Z</updated><author><name>paulg</name><uri>https://forge.codesys.com/u/paulg/</uri></author><id>https://forge.codesys.com32b92e28a42148f8f86322dc3076178cceb4c0e5</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I'll be capturing a hex stream over serial into a RasPi and I'd like to convert a group of bytes into a float. I see this is available (https://content.helpme-codesys.com/en/CODESYS%20Development%20System/cdsoperatorrealto.html) but not its inverse (i.e. BYTE_TO_REAL). The packets will be 18 bytes but I'll be selecting 4 byte segments from the middle, swapping byte endianness (i.e. changing 0x51847641 to 0x41768451), and converting to float; I believe they adhere to IEEE 754.&lt;/p&gt;
&lt;p&gt;Is there a pre-built function for some or all of this, or do I need to follow (https://forge.codesys.com/forge/talk/Engineering/thread/dc5829c7ea/)?&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>