<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Var declaration AT %MW...voiding memory overlapping</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/2da232ec91/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/2da232ec91/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/CODESYS-V2/thread/2da232ec91/</id><updated>2020-02-27T23:26:52.316000Z</updated><subtitle>Recent posts to Var declaration AT %MW...voiding memory overlapping</subtitle><entry><title>Var declaration AT %MW...voiding memory overlapping</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/2da232ec91/?limit=25#d1c1" rel="alternate"/><published>2020-02-27T23:26:52.316000Z</published><updated>2020-02-27T23:26:52.316000Z</updated><author><name>Jonascox</name><uri>https://forge.codesys.com/u/jonascox/</uri></author><id>https://forge.codesys.com096f8e19fdfbd8c234ae23661e3313afb348dea0</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I found that each timer uses 4 DINT's.&lt;/p&gt;
&lt;p&gt;So I would put the timer names in a spreadsheet and add the %md** in the column next to them. Fill out the first 2 or 3 names and addresses then drag the cells down to have the spreadsheet auto-fill the rest of the memory names. In this way you can determine where each timer memory starting point will fall.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Var declaration AT %MW...voiding memory overlapping</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/2da232ec91/?limit=25#d01d" rel="alternate"/><published>2020-02-27T23:26:50.630000Z</published><updated>2020-02-27T23:26:50.630000Z</updated><author><name>hki75</name><uri>https://forge.codesys.com/u/hki75/</uri></author><id>https://forge.codesys.com09c070cce95c90d48d8ffc2d1ace9cce6b5137f6</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I know it's easier to define FB without physical memory addressing, but I need it..&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Var declaration AT %MW...voiding memory overlapping</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/2da232ec91/?limit=25#9e97" rel="alternate"/><published>2020-02-27T23:26:46.005000Z</published><updated>2020-02-27T23:26:46.005000Z</updated><author><name>Jonascox</name><uri>https://forge.codesys.com/u/jonascox/</uri></author><id>https://forge.codesys.com47389f6a1963e8c0cc79e3ee36b3598e78ba5c76</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;hki75 hat geschrieben:&lt;/strong&gt;&lt;br/&gt;
Hi Jonascox,&lt;br/&gt;
thanks for reply.&lt;br/&gt;
I try to insert your suggestion into Codesys but it doesn't work..for the following reasons:&lt;br/&gt;
TON (timer cannot to be defined AT odd address %W:&lt;br/&gt;
ex: &lt;br/&gt;
Timer1 AT %MW1 : TON; --&amp;gt; return error compiler 3729&lt;br/&gt;
Defining &lt;br/&gt;
Timer1 AT %MW0 : TON;&lt;br/&gt;
Timer2 AT %MW2 : TON;&lt;br/&gt;
--&amp;gt; compiler return:&lt;br/&gt;
the only way I found to void memory overlapping during compiling is this:&lt;br/&gt;
Timer1 AT :TON;&lt;br/&gt;
Timer2 AT :TON;&lt;br/&gt;
(it seems each timer needs 6 dword memory allocation)&lt;br/&gt;
But my question was: how to know it in advance without try with different data type (MB or MW or MD...) and compiling every time until I get&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Is there a reason you need the TON's defined at an absolute memory location?&lt;/p&gt;
&lt;p&gt;It is much simpler to define them without an absolute address.&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;p&gt;Timer3:TON;&lt;/p&gt;
&lt;p&gt;The timer bits can be used in your code directly. They are predefined and shouldn't be added to any variable list. &lt;br/&gt;
Example:&lt;/p&gt;
&lt;p&gt;Timer3.Q (&lt;em&gt;Done Bit)&lt;br/&gt;
Timer3.ET (&lt;/em&gt;Elapsed Time&lt;em&gt;)&lt;br/&gt;
Timer3.PT (&lt;/em&gt;Preset Time*)&lt;br/&gt;
Etc.&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: Bild" rel="nofollow" src="http://forum.codesys.com/download/file.php?mode=view&amp;amp;id=1380"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: Bild" rel="nofollow" src="http://forum.codesys.com/download/file.php?mode=view&amp;amp;id=1382"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Var declaration AT %MW...voiding memory overlapping</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/2da232ec91/?limit=25#ea0f" rel="alternate"/><published>2020-02-27T23:26:44.363000Z</published><updated>2020-02-27T23:26:44.363000Z</updated><author><name>hki75</name><uri>https://forge.codesys.com/u/hki75/</uri></author><id>https://forge.codesys.comc3d39e484e2cce6fd2ca35bb6dc95959c00839d1</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi Jonascox,&lt;br/&gt;
thanks for reply.&lt;br/&gt;
I try to insert your suggestion into Codesys but it doesn't work..for the following reasons:&lt;/p&gt;
&lt;p&gt;TON (timer cannot to be defined AT odd address %W:&lt;br/&gt;
ex: &lt;br/&gt;
Timer1 AT %MW1 : TON; --&amp;gt; return error compiler 3729&lt;/p&gt;
&lt;p&gt;Defining &lt;br/&gt;
Timer1 AT %MW0 : TON;&lt;br/&gt;
Timer2 AT %MW2 : TON;&lt;br/&gt;
--&amp;gt; compiler return:&lt;/p&gt;
&lt;p&gt;the only way I found to void memory overlapping during compiling is this:&lt;br/&gt;
Timer1 AT &lt;strong&gt;%MD0&lt;/strong&gt;:TON;&lt;br/&gt;
Timer2 AT &lt;strong&gt;%MD6&lt;/strong&gt;:TON;&lt;/p&gt;
&lt;p&gt;(it seems each timer needs 6 dword memory allocation)&lt;br/&gt;
But my question was: how to know it in advance without try with different data type (MB or MW or MD...) and compiling every time until I get&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: Bild" rel="nofollow" src="http://forum.codesys.com/download/file.php?mode=view&amp;amp;id=1380"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: Bild" rel="nofollow" src="http://forum.codesys.com/download/file.php?mode=view&amp;amp;id=1382"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Var declaration AT %MW...voiding memory overlapping</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/2da232ec91/?limit=25#803a" rel="alternate"/><published>2020-02-27T23:26:42.719000Z</published><updated>2020-02-27T23:26:42.719000Z</updated><author><name>Jonascox</name><uri>https://forge.codesys.com/u/jonascox/</uri></author><id>https://forge.codesys.com354c6dda43bede483d7a6e77905d3c8688f58132</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;hki75, unlike Siemens, you don't need to offset your variables of like kind.&lt;/p&gt;
&lt;p&gt;Timer1 AT %MW0 : TON;&lt;br/&gt;
Timer2 AT %MW1 : TON;&lt;br/&gt;
Word3  AT %MW2 : word;&lt;/p&gt;
&lt;p&gt;However, if you use Bytes as a starting point, you can overlap memory. Like this:&lt;/p&gt;
&lt;p&gt;Word1  AT %MB0 : Word;&lt;br/&gt;
Word2  AT %MB2 : Word;&lt;br/&gt;
Word3  AT %MB3 : word; (&lt;em&gt; This variable will be overwritten by the variable starting at %MB2 &lt;/em&gt;)&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Var declaration AT %MW...voiding memory overlapping</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/2da232ec91/?limit=25#51fb" rel="alternate"/><published>2020-02-27T23:26:38.119000Z</published><updated>2020-02-27T23:26:38.119000Z</updated><author><name>hki75</name><uri>https://forge.codesys.com/u/hki75/</uri></author><id>https://forge.codesys.com07b558dc77897f2b89a1b8047668506dece2a635</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I need to declare some variable mapped to %M address, something like:&lt;/p&gt;
&lt;p&gt;Timer1 AT %MW0 : TON;&lt;/p&gt;
&lt;p&gt;The question is: how to know the right offset for each variable to void memory overlapping? &lt;br/&gt;
ex:&lt;br/&gt;
&lt;strong&gt;Timer1&lt;/strong&gt; &lt;span style="color: #0000FF;"&gt;AT&lt;/span&gt; &lt;strong&gt;%MW0&lt;/strong&gt; : TON;&lt;br/&gt;
&lt;strong&gt;Timer2&lt;/strong&gt; &lt;span style="color: #0000FF;"&gt;AT&lt;/span&gt;&lt;strong&gt; %MW ??&lt;/strong&gt; : TON;&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>