ConnectedComponents UserDefinedDataType

PLC Pie Guy

Member
Join Date
Jun 2013
Location
Halifax
Posts
1,144
Hey Folks.
I'm using V11 developer edition.

COP and MOV do not work to move UDT elements in CCW.

So, in order to move the UDT, I needed to use ST. I have never done this before.

Here is what I have....

if Kettle1.Control.CurrentStep = 1 THEN Kettle1.Steps[1] =; Kettle1SequenceStep
if Kettle1.Control.Currentstep = 2 THEN Kettle1.Steps[2] =; Kettle1SequenceStep
if Kettle1.Control.Currentstep = 3 THEN Kettle1.Steps[3] =; Kettle1SequenceStep
if Kettle1.Control.Currentstep = 4 THEN Kettle1.Steps[4] =; Kettle1SequenceStep
if Kettle1.Control.Currentstep = 5 THEN Kettle1.Steps[5] =; Kettle1SequenceStep



Does this look like it should work?
What I want is for Kettle1.Steps[X] to move to the tag Kettle1SequenceStep when the step number is a match to the value in X. Both tags are of the same UDT type.

Any other way to get this done that you can think of?

Thanks you!
 
Ahh, I believe that is what I was going for at first but I ended up with what I showed when it wouldn't work for me.
I had the ":=" written like "=;"

Thank you!
 
So, I'm using the statement like this now.

Kettle1.Steps[kettle1.control.currentstep] := Kettle1SequenceStep


The statement is fine, however when I attempt to build, I get the error...

" ;:expected before this statement"

I have tried : I have tried ;: and ; I'm not sure what else to do.

Any suggestions? Thanks
 
If Kettle1.Control.CurrentStep = 1 THEN
Kettle1.Steps[1] := Kettle1SequenceStep;
End_If;

If Kettle1.Control.CurrentStep = 2 THEN
Kettle1.Steps[2] := Kettle1SequenceStep;
End_If;

If Kettle1.Control.CurrentStep = 3 THEN
Kettle1.Steps[3] := Kettle1SequenceStep;
End_If;

And so forth.
 
Last edited:
The ; comes at the end of the statement.
Kettle1.Steps[kettle1.control.currentstep] := Kettle1SequenceStep; <---


ST in CCW is slightly different in that you need to put the ; at the end of END_IF/END_CASE etc, you don't need to do that in the Codesys flavors.


Send a screenshot of the code
 
OK, So both methods work. Once typed correctly with the semicolon at the end of the statement!

Kettle1.Steps[Kettle1.Control.CurrentStep] := Kettle1SequenceStep; Is my preferred method, I think.



IF kettle1.Control.CurrentStep = 1 THEN kettle1.Steps[1] := Kettle1SequenceStep; END_IF;
IF kettle1.Control.CurrentStep = 2 THEN kettle1.Steps[2] := Kettle1SequenceStep; END_IF;
IF kettle1.Control.CurrentStep = 3 THEN kettle1.Steps[1] := Kettle1SequenceStep; END_IF;
IF kettle1.Control.CurrentStep = 4 THEN kettle1.Steps[2] := Kettle1SequenceStep; END_IF;
IF kettle1.Control.CurrentStep = 5 THEN kettle1.Steps[1] := Kettle1SequenceStep; END_IF;
IF kettle1.Control.CurrentStep = 6 THEN kettle1.Steps[2] := Kettle1SequenceStep; END_IF;

and so on....... This works as well!

So, my question is, what is the := called.... Its like a move statement but what would be the proper term for this function in context to the structure text language?

Also, thanks for the assistance!
 
The := is the "assignment" operator. It assigns the value of whatever is to the right of it to the variable on its left.
 
Kettle1.Steps[Kettle1.Control.CurrentStep] := Kettle1SequenceStep; Is my preferred method, I think.



IF kettle1.Control.CurrentStep = 1 THEN kettle1.Steps[1] := Kettle1SequenceStep; END_IF;
IF kettle1.Control.CurrentStep = 2 THEN kettle1.Steps[2] := Kettle1SequenceStep; END_IF;
IF kettle1.Control.CurrentStep = 3 THEN kettle1.Steps[1] := Kettle1SequenceStep; END_IF;
IF kettle1.Control.CurrentStep = 4 THEN kettle1.Steps[2] := Kettle1SequenceStep; END_IF;
IF kettle1.Control.CurrentStep = 5 THEN kettle1.Steps[1] := Kettle1SequenceStep; END_IF;
IF kettle1.Control.CurrentStep = 6 THEN kettle1.Steps[2] := Kettle1SequenceStep; END_IF;


Also, thanks for the assistance!

This may be your preferred method and I'm glad it worked for you, but keep in mind that programming is also about "Readability", someone else at some point in time will have to edit your program. Everything on a single line sometimes makes it hard to READ!

Just my extra 2 cents worth!!
 
This may be your preferred method and I'm glad it worked for you, but keep in mind that programming is also about "Readability", someone else at some point in time will have to edit your program. Everything on a single line sometimes makes it hard to READ!

Just my extra 2 cents worth!!
I agree! There is definitely a trade off here between simplicity and readability, particularly in regards to debugging/troubleshooting.
 
This may be your preferred method and I'm glad it worked for you, but keep in mind that programming is also about "Readability", someone else at some point in time will have to edit your program. Everything on a single line sometimes makes it hard to READ!

Just my extra 2 cents worth!!

Understood. However, outside of the ST, was absolutely fine with the concept of the indirect addressing. That "preferred" statement is what I had initially started with but I just didn't have it set up right. I would hope that if somebody were in to modify the program they could understand that concept.... After all, I'm no PLC superstar, just a guy that builds some machines. Is it generally frowned upon to see indirect addressing or you think its too much simply for he fact that I'm using it in ST?
I tend to use it a fair bit in Ladder for recipe based and sequencer driven applications.
 

Similar Topics

Hello all, hope your week is going well. I am currently working on debugging a Micro850 with Category number 2080-LC50-24QWB. When I connect...
Replies
8
Views
2,341
Back
Top Bottom