<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Conversion of analogue input into Real measurement value</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/6c6bbcf65a/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/6c6bbcf65a/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/CODESYS-V2/thread/6c6bbcf65a/</id><updated>2026-01-14T20:28:18.335000Z</updated><subtitle>Recent posts to Conversion of analogue input into Real measurement value</subtitle><entry><title>Conversion of analogue input into Real measurement value</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/6c6bbcf65a/?limit=25#a526" rel="alternate"/><published>2026-01-14T20:28:18.335000Z</published><updated>2026-01-14T20:28:18.335000Z</updated><author><name>jackyrileap</name><uri>https://forge.codesys.com/u/jackyrileap/</uri></author><id>https://forge.codesys.com4fb0774dce5180dc01f51718284b6d5240b689a3</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;You need proper scaling from raw ADC counts to engineering units, handling underflow, overflow, and using linear conversion logic carefully.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Conversion of analogue input into Real measurement value</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/6c6bbcf65a/?limit=25#6349" rel="alternate"/><published>2020-02-27T22:29:06.692000Z</published><updated>2020-02-27T22:29:06.692000Z</updated><author><name>shooter</name><uri>https://forge.codesys.com/u/shooter/</uri></author><id>https://forge.codesys.com8477604fb7adf3c0a5ef02c8044910ee752ab66a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;dividing is not the same as shifting as divide gives something behind the comma, and you should discard it. just shift the shit and save it as a word as you did.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Conversion of analogue input into Real measurement value</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/6c6bbcf65a/?limit=25#ae5b" rel="alternate"/><published>2020-02-27T22:29:02.383000Z</published><updated>2020-02-27T22:29:02.383000Z</updated><author><name>Rolf-Geisler</name><uri>https://forge.codesys.com/u/rolf-geisler/</uri></author><id>https://forge.codesys.com104a228068ef9f8ad05c820f7032e3656d08f283</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello Yan,&lt;br/&gt;
your code seems to be ok (as far, as the sensor and the analogue input speak the same language - Volts or mAmps).&lt;br/&gt;
Setting the RAnalogIn.Ende to 2 converts an analogue signal of 0..10V to 0..2Amps, if you run the sensor in High mode, you will have to set RAnalogIn.Ende to 5.&lt;br/&gt;
For better understanding, I made a quick and dirty translation of used data types and FB_AnalogIn interface (will include it into the download package this weekend). Sorry for my poor English ...&lt;br/&gt;
Hope this will help. Have success&lt;br/&gt;
Rolf&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="https://forum.codesys.com//download/file.php?id=216" rel="nofollow"&gt;FB_AnalogIn_English.pdf &lt;span&gt;&lt;span&gt;[22.94 KiB]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Conversion of analogue input into Real measurement value</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/6c6bbcf65a/?limit=25#1699" rel="alternate"/><published>2020-02-27T22:29:00.839000Z</published><updated>2020-02-27T22:29:00.839000Z</updated><author><name>shooter</name><uri>https://forge.codesys.com/u/shooter/</uri></author><id>https://forge.codesys.comc77456f28e89099691478838153efd94e056b4d3</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;las rediel the above does not work correct, &lt;br/&gt;
the scale is 4/20 mA not 0..10 volt&lt;/p&gt;
&lt;p&gt;look at the txt of the oscat.de and you can find out how to calc it.&lt;/p&gt;
&lt;p&gt;it does work in 16 bit calcs yes like you do in analogin however it will not be precise.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Conversion of analogue input into Real measurement value</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/6c6bbcf65a/?limit=25#a6b7" rel="alternate"/><published>2020-02-27T22:28:56.502000Z</published><updated>2020-02-27T22:28:56.502000Z</updated><author><name>lasrediel</name><uri>https://forge.codesys.com/u/lasrediel/</uri></author><id>https://forge.codesys.coma363156ace33f9adf44cf181af7bac0114af1473</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thank you Rolf_Geisler ,&lt;/p&gt;
&lt;p&gt;for the hint,  strangely i was able to have the FB_AnalogIn Function block to word and initialise the value, but still not able with oscat, am probably too old   &lt;/p&gt;
&lt;p&gt;With the FB_AnalogIn tought, i was able to initialise as per the example provide in the PDF file. of course i initialise the as per the code below i set the RAnalogIn.Ende  to 2 but not sure if its ok, as the sensor got two setting (LOW: 0-2A &amp;amp; HIGH 0-5A)  and for being able to have a return value i need to set the PAnalogIn.Resolution:=0 , but that according the the software correspond to a 16 bits ADC resolution.    and the one i am using iis a 2x 16 bit measurement transmittion and 8 bits status per channel, per prior post shooter notify me that in fact the wago is using in fact 12 bits resolution (a bit confuse)   &lt;/p&gt;
&lt;p&gt;var```&lt;/p&gt;
&lt;p&gt;VAR &lt;br/&gt;
  AnalogIn   : FB_AnalogIn;  (&lt;em&gt; FB instance for converting in physics Scheme units &lt;/em&gt;)&lt;br/&gt;
  wInput AT %IW13 : WORD;  (&lt;em&gt;Input signal, as read by the ADC, the Input signal is define using the bits adress %IW12 &lt;/em&gt;)&lt;br/&gt;
 PhysWert   : REAL;  (&lt;em&gt; Physical measurement &lt;/em&gt;)&lt;br/&gt;
 bError     : BYTE;  (&lt;em&gt; Error Status Byte of Analogin &lt;/em&gt;)&lt;br/&gt;
 PAnalogIn  : TADC;  (&lt;em&gt; Parameter of the FB instance of Analogin &lt;/em&gt;)&lt;br/&gt;
 RAnalogIn  : TRange;  (&lt;em&gt; Physical range &lt;/em&gt;)&lt;br/&gt;
END_VAR&lt;br/&gt;
(&lt;em&gt; Set the properties of the AD converter and the signal.&lt;br/&gt;
    It may also be made ??variable with initial value &lt;/em&gt;) &lt;br/&gt;
PAnalogIn.Resolution := 0;     (&lt;em&gt; 16Bit Resolution &lt;/em&gt;)&lt;br/&gt;
PAnalogIn.SignalType := 3;     (&lt;em&gt; unipolar 0 .. +10 V &lt;/em&gt;)&lt;br/&gt;
(&lt;em&gt;  The range of physical measurement variable between 0 and +10 V &lt;/em&gt;)&lt;br/&gt;
RAnalogIn.Anfang     :=    0.0; (&lt;em&gt; phys. initial value&lt;/em&gt;)&lt;br/&gt;
RAnalogIn.Ende       := 2; (&lt;em&gt; phys. end value  &lt;/em&gt;)&lt;br/&gt;
(&lt;em&gt; Analog value process&lt;/em&gt;)&lt;br/&gt;
AnalogIn (iwIn    := wInput,     (&lt;em&gt; wInput is the analogue input &lt;/em&gt;)&lt;br/&gt;
          isADC   := PAnalogIn, &lt;br/&gt;
          isRange := RAnalogIn);&lt;br/&gt;
PhysWert := AnalogIn.qrValue;    (&lt;em&gt; the actual measured value, in the relevant operation &lt;/em&gt;)&lt;br/&gt;
bError   := AnalogIn.qbError;&lt;/p&gt;
&lt;p&gt;```&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Conversion of analogue input into Real measurement value</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/6c6bbcf65a/?limit=25#3dc4" rel="alternate"/><published>2020-02-27T22:28:54.936000Z</published><updated>2020-02-27T22:28:54.936000Z</updated><author><name>Rolf-Geisler</name><uri>https://forge.codesys.com/u/rolf-geisler/</uri></author><id>https://forge.codesys.coma8ebd46679da747abb5b6a9daed1a8e14cec594d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello Yan,&lt;br/&gt;
there is another way to read analogue inputs. See the download page of &lt;a class="" href="http://www.geisler-controls.de" rel="nofollow"&gt;http://www.geisler-controls.de&lt;/a&gt; and look for the AnalogEA.lib. It provides a function block , which lets you select a input mode (such as 4..20 mA) and the resolution of AD converter. Additionally there is an input to set the range of measured physical values (e.g. the pressure of a hydraulic aggregate). Then it returns straight the physical value.&lt;br/&gt;
Sorry, that documentation is still in German ...&lt;br/&gt;
Maybe, that solves your problem.&lt;br/&gt;
Have success&lt;br/&gt;
Rolf&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Conversion of analogue input into Real measurement value</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/6c6bbcf65a/?limit=25#51a6" rel="alternate"/><published>2020-02-27T22:28:53.340000Z</published><updated>2020-02-27T22:28:53.340000Z</updated><author><name>lasrediel</name><uri>https://forge.codesys.com/u/lasrediel/</uri></author><id>https://forge.codesys.comcc4c9ae2383eb05231b1088efb76616358441771</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;thanks both for the time you took for answering me. really appreciate.  &lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Zitat:&lt;/strong&gt;&lt;br/&gt;
resolution is only 12 bits not 16 however wago has a 15 bits version if needed more precision.&lt;br/&gt;
bit 1,2,3 are not in the analog world.&lt;br/&gt;
so if you get the word in discard these bits.&lt;br/&gt;
bit 15 is also not used as anaolg value.&lt;br/&gt;
you can divide the word by 8 or roll it etc&lt;br/&gt;
&lt;a class="" href="http://www.oscat.de" rel="nofollow"&gt;http://www.oscat.de&lt;/a&gt; has a good conversion for this.&lt;br/&gt;
look for function AIN&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;Shooter&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt;if i got what you said right,   dividing the receive value from my analogue input by 8 i shall get the REAL amperes measured value or is it in order to use the AIN oscat function?  &lt;/p&gt;
&lt;p&gt;if not can you elaborate a little more, sorry for the incovenience but i am trying to get familiar to the PLC world and ST programming. &lt;br/&gt;
And i can also use some hints on how to use efficiently the oscat function, meaning i can open them as a project and see both var set up and prg. but i must admit i am a little bit lost on how to actually use them to my benefits. sadly got no one to help me with that at work.&lt;/p&gt;
&lt;p&gt;heres the code that i am working on so far. any advice are more then welcom&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;PROGRAM&lt;/span&gt; &lt;span class="nv"&gt;prg1&lt;/span&gt;
&lt;span class="nv"&gt;VAR&lt;/span&gt;
   &lt;span class="nv"&gt;A1&lt;/span&gt;: &lt;span class="nv"&gt;ARRAY&lt;/span&gt; [&lt;span class="mi"&gt;0&lt;/span&gt;..&lt;span class="mi"&gt;30&lt;/span&gt;] &lt;span class="nv"&gt;OF&lt;/span&gt; &lt;span class="nv"&gt;WORD&lt;/span&gt;&lt;span class="c1"&gt;;      (*Declaring array A1 of a size of *)&lt;/span&gt;
   &lt;span class="nv"&gt;k&lt;/span&gt;: &lt;span class="nv"&gt;INT&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
   &lt;span class="nv"&gt;avg&lt;/span&gt;: &lt;span class="nv"&gt;WORD&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;END_VAR&lt;/span&gt;
 &lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="nv"&gt;DO1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;TRUE&lt;/span&gt; &lt;span class="k"&gt;THEN&lt;/span&gt;     &lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nv"&gt;those&lt;/span&gt; &lt;span class="nv"&gt;lines&lt;/span&gt; &lt;span class="nv"&gt;are&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nv"&gt;the&lt;/span&gt; &lt;span class="nv"&gt;purpose&lt;/span&gt; &lt;span class="nv"&gt;of&lt;/span&gt;  &lt;span class="nv"&gt;activating&lt;/span&gt; &lt;span class="nv"&gt;my&lt;/span&gt; &lt;span class="nv"&gt;digital&lt;/span&gt; &lt;span class="nv"&gt;output&lt;/span&gt; &lt;span class="nv"&gt;that&lt;/span&gt; &lt;span class="nv"&gt;control&lt;/span&gt; &lt;span class="nv"&gt;my&lt;/span&gt; &lt;span class="nv"&gt;relay&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;
   &lt;span class="nv"&gt;DO1&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;FALSE&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;ELSE&lt;/span&gt;
   &lt;span class="nv"&gt;DO1&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;TRUE&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;END_IF&lt;/span&gt;
 &lt;span class="nv"&gt;k&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;k&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;A1&lt;/span&gt;[&lt;span class="nv"&gt;k&lt;/span&gt;]:&lt;span class="o"&gt;=%&lt;/span&gt;&lt;span class="nv"&gt;IW12&lt;/span&gt;&lt;span class="c1"&gt;;      (* Array A1[k] is being filled with the value provide by the Analogue input located at the bits adress "%IW12"*)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;yan&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="https://forum.codesys.com//download/file.php?id=215" rel="nofollow"&gt;Standard Data Format AI 750 466.doc &lt;span&gt;&lt;span&gt;[273.5 KiB]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Conversion of analogue input into Real measurement value</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/6c6bbcf65a/?limit=25#8b94" rel="alternate"/><published>2020-02-27T22:28:49.019000Z</published><updated>2020-02-27T22:28:49.019000Z</updated><author><name>shooter</name><uri>https://forge.codesys.com/u/shooter/</uri></author><id>https://forge.codesys.com37b3422567999b073ad1587b60f8b522072e4366</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;resolution is only 12 bits not 16 however wago has a 15 bits version if needed more precision.&lt;/p&gt;
&lt;p&gt;bit 1,2,3 are not in the analog world.&lt;br/&gt;
so if you get the word in discard these bits.&lt;br/&gt;
bit 15 is also not used as anaolg value.&lt;br/&gt;
you can divide the word by 8 or roll it etc&lt;/p&gt;
&lt;p&gt;w &lt;a class="" href="http://www.oscat.de" rel="nofollow"&gt;www.oscat.de&lt;/a&gt; w  has a good conversion for this.&lt;br/&gt;
look for function AIN&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Conversion of analogue input into Real measurement value</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/6c6bbcf65a/?limit=25#b67e" rel="alternate"/><published>2020-02-27T22:28:47.461000Z</published><updated>2020-02-27T22:28:47.461000Z</updated><author><name>bllueapple</name><uri>https://forge.codesys.com/u/bllueapple/</uri></author><id>https://forge.codesys.com75575cc90b6266a02eacf5340cff4718d281670d</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi Yan,&lt;/p&gt;
&lt;p&gt;There's a standard function block in codesys library called LIN_TRAFO which is in REAL. Try that.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Conversion of analogue input into Real measurement value</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/6c6bbcf65a/?limit=25#1b61" rel="alternate"/><published>2020-02-27T22:28:43.112000Z</published><updated>2020-02-27T22:28:43.112000Z</updated><author><name>lasrediel</name><uri>https://forge.codesys.com/u/lasrediel/</uri></author><id>https://forge.codesys.coma1e15d3ef5475c68a4b4bba2646a3caa00306bd8</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Good day all, &lt;br/&gt;
i am a new comer in the forum as well as  in the world of programming and more specifically with PLC programming.  &lt;/p&gt;
&lt;p&gt;I am working actually with a wago 750-841 PLC on wich a Analogue Input module is attach (750-466) .  What  i am trying to do is to read from the analogue input module port the values from the sensor that will return values (numerical decimal value) according to the analogue module manual from 4096 to 32760 (lower and higher value are underflow and overflow values) as the module read from 4mA to 20 mA with a 16bits measurements. &lt;/p&gt;
&lt;p&gt;I am stuck in the conversion from WORD to REAL. as i want to save(archive) those input data with time stamp and TREND them later on from the archive.  I checked the oscat AIN and AIN1 but still confused in how to adapt those library code to my situation.&lt;/p&gt;
&lt;p&gt;forgot to mention am beginning in ST   &lt;/p&gt;
&lt;p&gt;All the help is really more then welcom!!!&lt;/p&gt;
&lt;p&gt;Thanks in advance&lt;/p&gt;
&lt;p&gt;Yan&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>