Hi Jonascox,
thanks for reply.
I try to insert your suggestion into Codesys but it doesn't work..for the following reasons:
TON (timer cannot to be defined AT odd address %W:
ex:
Timer1 AT %MW1 : TON; --> return error compiler 3729
Defining
Timer1 AT %MW0 : TON;
Timer2 AT %MW2 : TON;
--> compiler return:
the only way I found to void memory overlapping during compiling is this:
Timer1 AT %MD0:TON;
Timer2 AT %MD6:TON;
(it seems each timer needs 6 dword memory allocation)
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hki75 hat geschrieben:
Hi Jonascox,
thanks for reply.
I try to insert your suggestion into Codesys but it doesn't work..for the following reasons:
TON (timer cannot to be defined AT odd address %W:
ex:
Timer1 AT %MW1 : TON; --> return error compiler 3729
Defining
Timer1 AT %MW0 : TON;
Timer2 AT %MW2 : TON;
--> compiler return:
the only way I found to void memory overlapping during compiling is this:
Timer1 AT :TON;
Timer2 AT :TON;
(it seems each timer needs 6 dword memory allocation)
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
Is there a reason you need the TON's defined at an absolute memory location?
It is much simpler to define them without an absolute address.
Example:
Timer3:TON;
The timer bits can be used in your code directly. They are predefined and shouldn't be added to any variable list.
Example:
Timer3.Q (Done Bit)
Timer3.ET (Elapsed Time)
Timer3.PT (Preset Time*)
Etc.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I need to declare some variable mapped to %M address, something like:
Timer1 AT %MW0 : TON;
The question is: how to know the right offset for each variable to void memory overlapping?
ex:
Timer1 AT %MW0 : TON;
Timer2 AT %MW ?? : TON;
hki75, unlike Siemens, you don't need to offset your variables of like kind.
Timer1 AT %MW0 : TON;
Timer2 AT %MW1 : TON;
Word3 AT %MW2 : word;
However, if you use Bytes as a starting point, you can overlap memory. Like this:
Word1 AT %MB0 : Word;
Word2 AT %MB2 : Word;
Word3 AT %MB3 : word; ( This variable will be overwritten by the variable starting at %MB2 )
Hi Jonascox,
thanks for reply.
I try to insert your suggestion into Codesys but it doesn't work..for the following reasons:
TON (timer cannot to be defined AT odd address %W:
ex:
Timer1 AT %MW1 : TON; --> return error compiler 3729
Defining
Timer1 AT %MW0 : TON;
Timer2 AT %MW2 : TON;
--> compiler return:
the only way I found to void memory overlapping during compiling is this:
Timer1 AT %MD0:TON;
Timer2 AT %MD6:TON;
(it seems each timer needs 6 dword memory allocation)
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
Is there a reason you need the TON's defined at an absolute memory location?
It is much simpler to define them without an absolute address.
Example:
Timer3:TON;
The timer bits can be used in your code directly. They are predefined and shouldn't be added to any variable list.
Example:
Timer3.Q (Done Bit)
Timer3.ET (Elapsed Time)
Timer3.PT (Preset Time*)
Etc.
I know it's easier to define FB without physical memory addressing, but I need it..
I found that each timer uses 4 DINT's.
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.