<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Converting UINT into bytes and converting 2Bytes into UINT</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/336b396136/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/336b396136/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/336b396136/</id><updated>2023-12-08T09:53:09.409000Z</updated><subtitle>Recent posts to Converting UINT into bytes and converting 2Bytes into UINT</subtitle><entry><title>Converting UINT into bytes and converting 2Bytes into UINT</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/336b396136/?limit=25#10f9/0eb1" rel="alternate"/><published>2023-12-08T09:53:09.409000Z</published><updated>2023-12-08T09:53:09.409000Z</updated><author><name>abjha1998</name><uri>https://forge.codesys.com/u/abjha1998/</uri></author><id>https://forge.codesys.comc057b70fc75ec8758c5c2aad67829b5410c70d91</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thank you for the reply. I got an error saying that &lt;br/&gt;
 MEM.PackBytesToWord(GVL.Actual_Speed_DUT_high,GVL.Actual_Speed_DUT_low) = u; is not a valid statement. Am I missing some library?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Converting UINT into bytes and converting 2Bytes into UINT</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/336b396136/?limit=25#10f9/acc0" rel="alternate"/><published>2023-12-08T09:53:02.617000Z</published><updated>2023-12-08T09:53:02.617000Z</updated><author><name>abjha1998</name><uri>https://forge.codesys.com/u/abjha1998/</uri></author><id>https://forge.codesys.com14de827eb875529a023062270feae72a53b6fb20</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thank you for the reply. I got an error saying that &lt;br/&gt;
 MEM.PackBytesToWord(GVL.Actual_Speed_DUT_high,GVL.Actual_Speed_DUT_low) = u; is not a valid statement. Am I missing some library?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Converting UINT into bytes and converting 2Bytes into UINT</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/336b396136/?limit=25#10f9" rel="alternate"/><published>2023-12-08T07:13:18.411000Z</published><updated>2023-12-08T07:13:18.411000Z</updated><author><name>kislov</name><uri>https://forge.codesys.com/u/kislov/</uri></author><id>https://forge.codesys.com819f856373cb2c579e6f165a8cc428d2864db954</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;a href="https://content.helpme-codesys.com/en/libs/CAA%20Memory/Current/CAA_Memory/Packing/PackBytesToWord.html" rel="nofollow"&gt;https://content.helpme-codesys.com/en/libs/CAA%20Memory/Current/CAA_Memory/Packing/PackBytesToWord.html&lt;/a&gt; + WORD_TO_UINT&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Converting UINT into bytes and converting 2Bytes into UINT</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/336b396136/?limit=25#cf70" rel="alternate"/><published>2023-12-07T20:27:30.713000Z</published><updated>2023-12-07T20:27:30.713000Z</updated><author><name>voffi</name><uri>https://forge.codesys.com/u/voffi/</uri></author><id>https://forge.codesys.coma66069b0bdb8f24cbdd2130227d5370fa1d7ed54</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;There are some ways. One is to use SHR and SHL and it depends on your byte order in the data array. . For Motorola byte order:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class="n"&gt;PROGRAM&lt;/span&gt; &lt;span class="n"&gt;PLC_PRG&lt;/span&gt;
&lt;span class="kr"&gt;VAR&lt;/span&gt;
    &lt;span class="n"&gt;u&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;UINT&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;byte_array_in&lt;/span&gt;  &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;ARRAY&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;..&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="kr"&gt;OF&lt;/span&gt; &lt;span class="kt"&gt;BYTE&lt;/span&gt;
            &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="mi"&gt;11&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="o"&gt;#&lt;/span&gt;&lt;span class="mi"&gt;17&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="n"&gt;byte_array_out&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;ARRAY&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;..&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="kr"&gt;OF&lt;/span&gt; &lt;span class="kt"&gt;BYTE&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;END_VAR&lt;/span&gt;

&lt;span class="n"&gt;u&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;SHL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;TO_UINT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;byte_array_in&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;TO_UINT&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;byte_array_in&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;

&lt;span class="n"&gt;byte_array_out&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;TO_BYTE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="n"&gt;byte_array_out&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;TO_BYTE&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SHR&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If it's Intel byte order just change 1 and 2 in the array indexes.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Converting UINT into bytes and converting 2Bytes into UINT</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/336b396136/?limit=25#57e5" rel="alternate"/><published>2023-12-07T15:51:39.949000Z</published><updated>2023-12-07T15:51:39.949000Z</updated><author><name>abjha1998</name><uri>https://forge.codesys.com/u/abjha1998/</uri></author><id>https://forge.codesys.com66f71e0c426a3d8c32520d49e06eab482fe076a2</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;br/&gt;
I have been working on Codesys V3.5 with PFC200 controller and Can Gateway 750-658. I want to convert the incoming CAN data from bytes into UINT and for outgoing data bytes to UINT. Does anyone has experience with this kind of data? I tried few different ways but it doesn't seem to be working.  &lt;/p&gt;&lt;/div&gt;</summary></entry></feed>