<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Analog Sgnals in CodeSys V3</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/a9c6cef95e/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/a9c6cef95e/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/a9c6cef95e/</id><updated>2020-02-27T13:54:22.180000Z</updated><subtitle>Recent posts to Analog Sgnals in CodeSys V3</subtitle><entry><title>Analog Sgnals in CodeSys V3</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/a9c6cef95e/?limit=25#c286" rel="alternate"/><published>2020-02-27T13:54:22.180000Z</published><updated>2020-02-27T13:54:22.180000Z</updated><author><name>Luigi</name><uri>https://forge.codesys.com/u/luigi/</uri></author><id>https://forge.codesys.combefc2ac99774dec19152d3a114b3466fbfc6dcd3</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thank you for your explanation&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Analog Sgnals in CodeSys V3</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/a9c6cef95e/?limit=25#315b" rel="alternate"/><published>2020-02-27T13:54:21.994000Z</published><updated>2020-02-27T13:54:21.994000Z</updated><author><name>nothinrandom</name><uri>https://forge.codesys.com/u/nothinrandom/</uri></author><id>https://forge.codesys.com58753a2ddb115f07d6b976732845778889c2357b</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;You can certainly write your own scaling function...assuming you just started Codesys:&lt;/p&gt;
&lt;p&gt;Create a function block and give it a name called Scale. Copy this part to the top&lt;/p&gt;
&lt;p&gt;FUNCTION_BLOCK Scale&lt;br/&gt;
VAR_INPUT&lt;br/&gt;
    xEN         : BOOL; (&lt;em&gt; enable &lt;/em&gt;)&lt;br/&gt;
    diInput     : DINT; (&lt;em&gt; raw digital input &lt;/em&gt;)&lt;br/&gt;
    diInputMin      : DINT; (&lt;em&gt; minimum value expected &lt;/em&gt;)&lt;br/&gt;
    diInputMax  : DINT; (&lt;em&gt; maximum value expected &lt;/em&gt;)&lt;br/&gt;
    diOutputMin : DINT; (&lt;em&gt; minimum scaled output &lt;/em&gt;)&lt;br/&gt;
    diOutputMax : DINT; (&lt;em&gt; maximum scaled output &lt;/em&gt;)&lt;br/&gt;
END_VAR&lt;br/&gt;
VAR_OUTPUT&lt;br/&gt;
    xENO        : BOOL; (&lt;em&gt; running &lt;/em&gt;)&lt;br/&gt;
    diScaledOutput  : DINT; (&lt;em&gt; scaled output &lt;/em&gt;)&lt;br/&gt;
END_VAR&lt;/p&gt;
&lt;p&gt;Now copy this part to the bottom half of screen&lt;/p&gt;
&lt;p&gt;diScaledOutput := (diInput-diInputMin)*(diOutputMax-diOutputMin)/(diInputMax-diInputMin)+ diOutputMin;&lt;/p&gt;
&lt;p&gt;For example your analog sensor reads 8000 (assuming some range between 0 and 32767), and this range represents a temperature value of 0 to 100 *C. You should set up your function block, where:&lt;br/&gt;
diInput is whatever raw value you have&lt;br/&gt;
diInputMin is 0&lt;br/&gt;
diInputMax is 32767&lt;br/&gt;
diOutputMin is 0&lt;br/&gt;
diOutputMax is 100&lt;br/&gt;
diScaledOutput should yield 24&lt;/p&gt;
&lt;p&gt;If you need decimal point, then multiply all inputs by 10, then divide by 10 at the very end and change your output from DINT to REAL&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Analog Sgnals in CodeSys V3</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/a9c6cef95e/?limit=25#0503" rel="alternate"/><published>2020-02-27T13:54:21.816000Z</published><updated>2020-02-27T13:54:21.816000Z</updated><author><name>Comingback4u</name><uri>https://forge.codesys.com/u/comingback4u/</uri></author><id>https://forge.codesys.com8b68348ffde4be7aaf6f25911256c23e381d7882</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;There are a lot of function blocks out there. A standard one is LIN_TRAFO but has some downfalls in my opinion. A good starting point none the less. For an example I would look in the help. If you go to Help-Index and search LIN_TRAFO it will give you everything you need to know. You can just map your inputs and scale values and you are set.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Analog Sgnals in CodeSys V3</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/a9c6cef95e/?limit=25#67bc" rel="alternate"/><published>2020-02-27T13:54:21.636000Z</published><updated>2020-02-27T13:54:21.636000Z</updated><author><name>Luigi</name><uri>https://forge.codesys.com/u/luigi/</uri></author><id>https://forge.codesys.com864f293c3e44ba21c5b98120448b42a870835e21</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Can anyone tell me if Codesys V3 has the ability for scaling and unscaling analog signals? Do anyone have a good example for working within CodeSys with analog signals as newbie? In TIA Portal we have function blocks, do CodeSys also have one?&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>