Twincat 3 User info required

SHKODRAN

Member
Join Date
May 2010
Location
Italy
Posts
102
Hi everyone.

How i can declare this vaariable in twc3 ?

Code:
VAR_INPUT
  in_0 : BOOL ;
  in_0_b AT in_0 : ARRAY[0..0] OF BOOL; 
END_VAR

Thanks.
 
Might try here : https://infosys.beckhoff.com/englis.../1033/tc3_plc_intro/9007201784205195.html&id=

>>>
ARRAY
TwinCAT supports one-, two- and three-dimensional arrays of elementary data types. You can define arrays in the declaration part of a function block and in the global variable lists.

Only VAR_IN_OUT variables of function blocks, functions and methods can be declared with the data type of an array of variable length.

For variable-length arrays, the operators LOWER_BOUND (<array name>,<dim>) and UPPER_BOUND (array name,<dim>) provide the lower and upper bounds.



Syntax for declaring an array with a defined length:

<array_name> : ARRAY [<ll1>..<ul1>,<ll2>..<ul2>] OF <elem. type>

ll1, ll2, ll3 indicate the lower bound of a field dimension, ul1, ul2 and ul3 the upper limit. These limits must be integral values.

Example:

aCardGame : ARRAY [1..13, 1..4] OF INT;


Syntax for declaring an array with variable length:

<array_name> : ARRAY [*|, *|, *] OF <data type>;

Example:

//An diese Additionsfunktion können Arrays mit verschiedener Längen übergeben werden
FUNCTION F_Sum : DINT;
VAR_IN_OUT
aSample: ARRAY [*] OF INT;
END_VAR
VAR
nI, nSum2 : DINT;
END_VAR

nSum2 := 0;

//Die Länge des jeweiligen Arrays wird ermittelt
FOR nI:= LOWER_BOUND(aSample,1) TO UPPER_BOUND(aSample,1) DO
nSum2 := nSum2 + aSample[nI];
END_FOR;

F_Sum := nSum2;
Initialization of arrays
>>>

Poet.
 
Maybe like this:
Code:
	in_0   AT %MX0.0 : BOOL;
	in_0_b AT %M0 : ARRAY [0..0] OF BOOL;
I dont know Twincat, but it looks odd to me.

I am guessing that %MX0.0 and %M0 points to a global memory address.
in_0 is a VAR_INPUT, so it will get an address assignment when the block is called. That would conflict with a fixed global address assignment.
 
I dont know Twincat, but it looks odd to me.

I am guessing that %MX0.0 and %M0 points to a global memory address.
in_0 is a VAR_INPUT, so it will get an address assignment when the block is called. That would conflict with a fixed global address assignment.
You are completely right. I overlooked the "INPUT", so linking to a marker address space will create overlapping memory issues amongst instances of function blocks.
 
If it not has to be declared to same memory location you can point in_0_b array with pointer in the program of function.
 

Similar Topics

Here is a How To video showing how to install, configure, and run TwinCAT for for anyone that has never used it before. It is only 6 minutes...
Replies
1
Views
10,685
Hi! I am trying to run the 'SimpleSample' (https://infosys.beckhoff.com/content/1033/TF5100_TC3_NC_I/Resources/3438746891/.zip ) to understand the...
Replies
2
Views
96
I am developing a library in twincat and one of the function uses IID_ITcVnAccess_TcVnPoint2_DINT and the definition of this type is defined in...
Replies
0
Views
68
Sorry if this has been asked before, and apologies if this seems like a trivial issue, but I am new to Beckhoff and have been banging my head...
Replies
2
Views
141
Hi everyone, This is my first time posting, so please forgive any omissions or mistakes. I am attempting to control the velocity of a stepper...
Replies
18
Views
950
Back
Top Bottom