Hello guys. New to codesys here, and trying to write into a position.
What i want is the following:
For the positions between 42 and 60, if tool "status" is valid, that tool gets the positions number, if not continue.
My code does not work, i get values between 45 and 65.
Code:
//====================Write Tool Numbers X3 =================
FOR X3:=42 TO 60 DO
FOR Index3:=1 TO 22 DO
IF DbAutomatic.PosX3.Index = 3 THEN
IF DbAutomatic.PosX3.Status[Index3] THEN
DbAutomatic.PosX3.ToolNumber[Index3]:=X3;
DbAutomatic.AllTools[X3].Number:=X3;
DbAutomatic.AllTools[X3].Xpos:=DbAutomatic.PosX3.XPosition[Index3];
DbAutomatic.AllTools[X3].Ypos:=DbAutomatic.PosX3.YPosition[Index3];
Hello guys. New to codesys here, and trying to write into a position.
What i want is the following:
For the positions between 42 and 60, if tool "status" is valid, that tool gets the positions number, if not continue.
My code does not work, i get values between 45 and 65.
Code:
//====================Write Tool Numbers X3 =================
FOR X3:=42 TO 60 DO
FOR Index3:=1 TO 22 DO
IF DbAutomatic.PosX3.Index = 3 THEN
IF DbAutomatic.PosX3.Status[Index3] THEN
DbAutomatic.PosX3.ToolNumber[Index3]:=X3;
DbAutomatic.AllTools[X3].Number:=X3;
DbAutomatic.AllTools[X3].Xpos:=DbAutomatic.PosX3.XPosition[Index3];
DbAutomatic.AllTools[X3].Ypos:=DbAutomatic.PosX3.YPosition[Index3];
Can you tell me what i am doing wrong?
Thank you!
X3:=X3+1; is part of your issue.
a FOR loop automatically increments your loop variable.