<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Convert INT to Binairy</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/611c1dc551/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/611c1dc551/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/611c1dc551/</id><updated>2022-08-31T09:57:03.490000Z</updated><subtitle>Recent posts to Convert INT to Binairy</subtitle><entry><title>Convert INT to Binairy</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/611c1dc551/?limit=25#f8ec" rel="alternate"/><published>2022-08-31T09:57:03.490000Z</published><updated>2022-08-31T09:57:03.490000Z</updated><author><name>sgronchi</name><uri>https://forge.codesys.com/u/sgronchi/</uri></author><id>https://forge.codesys.com846f3335081cb70ecaaabc03aedbea38b200e866</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Have you looked into Util.PACK? &lt;a href="https://help.codesys.com/webapp/dcArNB9jo1tNw8mpfoJaDnLo8No%2FPACK;product=Util;version=3.5.17.0" rel="nofollow"&gt;https://help.codesys.com/webapp/dcArNB9jo1tNw8mpfoJaDnLo8No%2FPACK;product=Util;version=3.5.17.0&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Convert INT to Binairy</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/611c1dc551/?limit=25#f8c1" rel="alternate"/><published>2022-08-30T11:29:24.406000Z</published><updated>2022-08-30T11:29:24.406000Z</updated><author><name>henk73</name><uri>https://forge.codesys.com/u/henk73/</uri></author><id>https://forge.codesys.coma119e19647680b0af0e26d4653a998b5a3c36b0d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello Fajean,&lt;/p&gt;
&lt;p&gt;Thanks for your explanation, but I don't quite get it yet. SORRY!!!!&lt;br/&gt;
In November i get training :)&lt;br/&gt;
Would you mind making an example for me in Codesys?&lt;br/&gt;
My example is as follows:&lt;br/&gt;
I have 4 inputs (sensors)&lt;br/&gt;
If sensor 1 high, output 1000&lt;br/&gt;
Sensor 2 high, then make output 0100&lt;br/&gt;
Sensor 3 high, then make output 0010&lt;br/&gt;
Sensor 5 high, then make output 0001&lt;/p&gt;
&lt;p&gt;thanks in advance&lt;br/&gt;
gr Henk&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Convert INT to Binairy</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/611c1dc551/?limit=25#29b2" rel="alternate"/><published>2022-08-30T11:29:22.015000Z</published><updated>2022-08-30T11:29:22.015000Z</updated><author><name>henk73</name><uri>https://forge.codesys.com/u/henk73/</uri></author><id>https://forge.codesys.com38dc4558ba78e2a2c39855135b2c745c2e101ab8</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello Fajean,&lt;/p&gt;
&lt;p&gt;Thanks for your explanation, but I don't quite get it yet. SORRY!!!!&lt;br/&gt;
In November i get training :)&lt;br/&gt;
Would you mind making an example for me in Codesys?&lt;br/&gt;
My example is as follows:&lt;br/&gt;
I have 4 inputs (sensors)&lt;br/&gt;
If sensor 1 high, output 1000&lt;br/&gt;
Sensor 2 high, then make output 0100&lt;br/&gt;
Sensor 3 high, then make output 0010&lt;br/&gt;
Sensor 5 high, then make output 0001&lt;/p&gt;
&lt;p&gt;thanks in advance&lt;br/&gt;
gr Henk&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Convert INT to Binairy</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/611c1dc551/?limit=25#35ec/9f2a/58a6" rel="alternate"/><published>2022-08-29T16:32:12.757000Z</published><updated>2022-08-29T16:32:12.757000Z</updated><author><name>fajean</name><uri>https://forge.codesys.com/u/fajean/</uri></author><id>https://forge.codesys.com2c0a6dabccce5f2ae60f92b559a747338cc5eabc</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Any type is binary, in the sense that all values are represented in memory as sequences of 0 and 1. Your INT is already made up of 0 and 1, which you can directly access.&lt;/p&gt;
&lt;p&gt;For instance, if you have a variable like this :&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;myint&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;INT&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;You can access each bit like this :&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt;first_bit := myint.0;&lt;/span&gt;
&lt;span class="err"&gt;last_bit := myint.15;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;You could also use bitwise operators (SHL, SHR, ROL, ROR) to perform bitwise manipulation of values.&lt;/p&gt;
&lt;p&gt;Getting specific bits out of a numerical value in CODESYS is therefore easy.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Convert INT to Binairy</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/611c1dc551/?limit=25#35ec" rel="alternate"/><published>2022-08-29T15:02:09.697000Z</published><updated>2022-08-29T15:02:09.697000Z</updated><author><name>fajean</name><uri>https://forge.codesys.com/u/fajean/</uri></author><id>https://forge.codesys.come74e819c1005826267a94dbd5ea2e993119838e8</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;When you say "to a 4 bit binary number", what is it that you mean by "binary number"?  A four-character string with each character being either 0 or 1?  A numeric variable (of 8, 16 , 32 or 64 bits) with only the four less significant bits assigned (which can code numbers from 0 to 15)?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Convert INT to Binairy</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/611c1dc551/?limit=25#7474" rel="alternate"/><published>2022-08-29T13:50:09.515000Z</published><updated>2022-08-29T13:50:09.515000Z</updated><author><name>henk73</name><uri>https://forge.codesys.com/u/henk73/</uri></author><id>https://forge.codesys.com5f8ce57f49a3d77f897cab0289d8755454516bd1</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;HAllo,&lt;br/&gt;
I am new with codesys.&lt;br/&gt;
I want to convert a INT to a 4 bit binairy number&lt;br/&gt;
I have 4 inputs&lt;br/&gt;
I connect all the input to a AND Block and the result must be an binairy number&lt;/p&gt;
&lt;p&gt;I want a VAR output like  for example 0010 or 0001 &lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>