Hi,
I want to add a for loop using ladder language,
but I can not find a 'for' in the toolbox
I am not familiar with ladder language in codesys,
can someone give me a help ?
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Te best part of CoDeSys is that you can use the language that is best for a specific task. If everything else is in ladder and you just need one FOR loop, you can create an action in structured text and call it from the ladder.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
even if there is no built-in support for loops in LD, you can construct it with several simple operators.
1. Initialize a cycle index with MOVE operator.
2. In the next network(s) do your loop logic. Provide a label for the first network in the loop body. Say, MY_LABEL
3. Increment a cycle index (or decrement if you're creating a count down index) with assignment like i + 1 ------ i
4. Do a cycle condition check with GE (or LE for count down) operator which supplies a JUMP element to MY_LABEL.
Regards,
Roman
eric.lin hat geschrieben:
Hi,
I want to add a for loop using ladder language,
but I can not find a 'for' in the toolbox
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I want to add a for loop using ladder language,
but I can not find a 'for' in the toolbox
I am not familiar with ladder language in codesys,
can someone give me a help ?
Thanks
hi eric.lin,
unlikely codesys do not have For function in Ladder Diagram. If you want to use there is available for structured text.
Thank you
John Lee
Te best part of CoDeSys is that you can use the language that is best for a specific task. If everything else is in ladder and you just need one FOR loop, you can create an action in structured text and call it from the ladder.
Hi Eric,
even if there is no built-in support for loops in LD, you can construct it with several simple operators.
1. Initialize a cycle index with MOVE operator.
2. In the next network(s) do your loop logic. Provide a label for the first network in the loop body. Say, MY_LABEL
3. Increment a cycle index (or decrement if you're creating a count down index) with assignment like i + 1 ------ i
4. Do a cycle condition check with GE (or LE for count down) operator which supplies a JUMP element to MY_LABEL.
Regards,
Roman
Ok, I've done my for loop using other basic LD operators
Thanks for all the suggestions