
adccommunitymod (AutomationDirect) asked a question.
Created Date: December 22,2017
Created By: voiceafx
**** This post has been imported from our legacy forum. Information in this post may be outdated and links contained in the post may no longer work.****
We are using the Productivity PLC to control 6 different servos. The ladder logic for each servo is functionally identical, except for the names of the inputs and outputs. Changing one item in the design is a major headache, because the change must be repeated for every servo. This creates enormous potential for bugs and makes the program much larger than is necessary. I 've been looking for a way to reuse duplicate code. It would be amazing if a custom function block could be created so that the servo control logic only needs to be implemented once, with inputs and outputs adjustable. Aside from embracing the headache, the only other option is to move away from PLCs altogether and make a custom control board.
Created Date: December 22,2017
Created by: voiceafx
We are using the Productivity PLC to control 6 different servos. The ladder logic for each servo is functionally identical, except for the names of the inputs and outputs.
Changing one item in the design is a major headache, because the change must be repeated for every servo. This creates enormous potential for bugs and makes the program much larger than is necessary.
I 've been looking for a way to reuse duplicate code. It would be amazing if a custom function block could be created so that the servo control logic only needs to be implemented once, with inputs and outputs adjustable.
Aside from embracing the headache, the only other option is to move away from PLCs altogether and make a custom control board.
Created Date: December 23,2017
Created by: juance
There is a way of implementing dynamic I/O programmaticaly. I am currently using it to be able to reuse code.
Basically what you do is to have an array of the outputs assigned to your logic outputs, so you know which physical output is associated with your logic output. Each logic output is fed by the same task, say SERVO_TASK and inside it you decide which portion of the logic outputs will get dealt with. (Eg. servo 1 will use logic outputs 1-5, servo 2 6-10, and so on), so when something happens inside SERVO_TASK, the logic output array will get set or reset.
Then every scan (could be another task) find the current physical output for each logic output and use that as a pointer to feed another array called say physical_output_image(xx), then you check the status (set/reset) of the logic output and assign it to this physical_output_image(xx) where xx is the physical output assigned to this logic output.
At the end of all this, use copy data instruction to copy each element of that physical_output_image(xx) to each of the physical output on the physical output module.
The reason I am using copy data is because there is no way that I know if (at least I couldn't do it) to copy an array to a physical module.
Hope this helps.
J
Created Date: December 23,2017
Created by: RogerR
One work around is to use array elements with each array index being a separate servo and each element being one data item required.
Run the code in a FOR Loop. Change the index after each loop of the code.
This would allow for the same code to be utilized on all servos.
Adding some conditional code within the loop for a specific index, would also allow for some variance between the servos logic if required.
Created Date: December 28,2017
Created by: cefisher15
I second voiceafx's dilemma. I am developing a project that simulates 75+ identical devices. Each device has about 70 variables associated with it. I would love the ability to create a custom instruction for the various logic segments (similar to the ControlLogiix AOI). As far as I can tell, I am destined to spend a week copying code and changing tags. It is not immediately clear to me that juance's suggestion will be beneficial in my situation.
Created Date: December 28,2017
Created by: juance
I am sure you can do something with the arrays and pass pointers to them and act accordingly. Your device should be one and only one, and use variables from there to refer to each specific one.
Created Date: December 30,2017
Created by: ControlsGuy
Productivity PLC - Function calls with parameters?
Aside from embracing the headache, the only other option is to move away from PLCs altogether and make a custom control board.
Really? If Productivity doesn't do it, it's time to write off PLCs as a class??? That's the story you 're going to stick with? Good thing you didn't post this on the AB, Siemens, or Host forum. They'd probably get their feelings hurt. All THEIR PLCs do subroutines.
Created Date: January 04,2018
Created by: cefisher15
Arrays & for loops will definitely be the answer for me in this design. Still would be nice to have an ability to make a custom instruction/function capability.
Created Date: January 04,2018
Created by: juance
Arrays & for loops will definitely be the answer for me in this design. Still would be nice to have an ability to make a custom instruction/function capability.
I assume you have considered calling task and pointing to the right area of memory and outputs/inputs ?
Created Date: November 21,2018
Created by: FBotello666
I am sure you can do something with the arrays and pass pointers to them and act accordingly. Your device should be one and only one, and use variables from there to refer to each specific one.
Hi!
could you please expand on that? I'm having the same problem. I read your first post too but didn't quite get how to use the arrays and pointers. Any example code?
Thanks in advance.
Created Date: November 21,2018
Created by: ADC_CommTeam02
{ "data-align ": "none ", "data-size ": "custom ", "height ": "403 ", "width ": "682 ", "data-attachmentid ":119173}