Twincat 3 - dynamic matrix size

naturephoenix

Member
Join Date
Jan 2015
Location
Vienn
Posts
181
Hello guys
I have an object actually FB. Inside my FB i got matrix which size I want to be declared once you create instance of my object in Main program. I have done like this: Input parameter of my FB is ppMymatrixPointer : Pointer to Pointer to Lreal; but inside program Iam not sure how to use it this pointer to pointer since this is not working ppMymatrixPointer[x, y].
 
Hello guys
I have an object actually FB. Inside my FB i got matrix which size I want to be declared once you create instance of my object in Main program. I have done like this: Input parameter of my FB is ppMymatrixPointer : Pointer to Pointer to Lreal;

Ialso have pPointer : Pointer to Real; but inside my FB program Iam not sure how to use it this pointer to pointer since this is not working ppMymatrixPointer[x, y].


I put
pPointer := __NEW(pointer to real, x) ;
ppMymatrixPointer :=__NEW(pointer to pointerto real, y) ;
 
Last edited:
a pointer from a pointer is not working good, as you are talking about memoryplaces of memoryplaces. and that is no good.
 
Admittedly, I have never used TwinCat, but I have never seen a PLC that allowed for dynamic array declaration. What I have seen the ability to pass an array in as a type of pointer, and then use whatever operations I want. The actions aren't stored in a local version of the array, they go straight back to the original.

Wherever the array is declared, it is fixed at compile time, but you can process it dynamically. This prevents things like memory leaks, but still allowed a lot of flexibility.
 
My goal is to pass size of matrix so just INT to a FB where I make matrix. Operafor __NEW allows that. ITS like mallic in C.

In my example pPointer[] works but ppMymatrixPointer [x,x] does not
 

Similar Topics

Hi, What is the best way to set dynamically time for TON timer ? Time should be in ms. Example: timer1: TON; calculatedTime : UINT...
Replies
1
Views
3,103
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
98
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
69
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
142
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
957
Back
Top Bottom