I am currently working on a project to built a fully functional calculator through Ladder Logic Programming and could perform all forms of mathematical solutions(in a way that if switches 1, 2, 3 are toggled the number 123 (One hundred and twenty three) will be executed, and so on) on a Siemens S7-1200 and TIA v14, no specifics have been given only that it must be done in Ladder Logic (No SCL) and no HMI.
Based on readings and online tutorials, I've figured that my best bet (within my level of knowledge in this subject) is that I should use and Array [0..9] and the usage of the MOVE box function to move single digits into a Data Block that holds an array [0..9] blocks and each array block is attached to the output of individual MOVE box functions through Switches assign via %I0.x port addresses and store in each Array element such as the MOVE box function executes and moves data (e.g: 1 -> array.[0]).
The next step that I am deriving to be is, to either use the MOVE_BLK box function or another MOVE box function to grab the integers in each array block and combine them into one as a block of data and convert using either CONV or S_STRING from INT to REAL to a temp_value variable within a second DATA BLOCK that has an array [0..1] . I'm thinking I am only in need of two array blocks. Array block. [0] to store the initial value, and after the input of a Mathematical operation move or to array block [1]as the inputs are broken down by the math operators.
So far I have only being able to generate single digit calculations, but have failed on converting the array into a whole number. I've tried using an index variable in the data block to help me point to the array block, but with no success.
I've also tried a Ladder Logic in the form of Case (Like in Pascal) that utilizes number ranges to define the first number, and once the second number is added multiply the first number by 10 and add the second number to it, but have problems with storing the numbers in memory for later execution of the mathematical problem.
I've also tried to use a mathematical approach (Num1*10) +Num2 and store the new value into a Temp_number Memory Block. My challenge to this approach is how to initiate the values (single digit input) and passing down the values as a single value could have a range of 1 to X amount of digits.
My main three questions are:
1- Is it possible to extract values from array blocks and combine, like if you do on a array to string conversation in standard programming.
2- Could a different approach be taken to solve the input challenge of the program.
3- If the mathematical approach a posibilty for success, how could you determine the size of the number pass through the mathematical logic of (Num1*10) +Num2 and adding a decimal point as the user enters the number to be calculated
I am hoping to see if guidance could be provided on how to execute the above. I've being doing some heavy reading for two weeks on Array to String conversion, Multi digit input conversion, and so on, with little result. Must of the examples have predefined values (which technically is in my case) but haven't encounter solutions on combining the single inputs into a whole number.
The scope and goal of project is that if the user toggles switches each individual number will be combined and form a new whole number (E.g.: 123 * 3 / 456 * 2 + 35 - 6 + 1.252, etc...) Just like any current calculator
I truly appreciate any and all guidance support to complete this project.
Yours Truly
Based on readings and online tutorials, I've figured that my best bet (within my level of knowledge in this subject) is that I should use and Array [0..9] and the usage of the MOVE box function to move single digits into a Data Block that holds an array [0..9] blocks and each array block is attached to the output of individual MOVE box functions through Switches assign via %I0.x port addresses and store in each Array element such as the MOVE box function executes and moves data (e.g: 1 -> array.[0]).
The next step that I am deriving to be is, to either use the MOVE_BLK box function or another MOVE box function to grab the integers in each array block and combine them into one as a block of data and convert using either CONV or S_STRING from INT to REAL to a temp_value variable within a second DATA BLOCK that has an array [0..1] . I'm thinking I am only in need of two array blocks. Array block. [0] to store the initial value, and after the input of a Mathematical operation move or to array block [1]as the inputs are broken down by the math operators.
So far I have only being able to generate single digit calculations, but have failed on converting the array into a whole number. I've tried using an index variable in the data block to help me point to the array block, but with no success.
I've also tried a Ladder Logic in the form of Case (Like in Pascal) that utilizes number ranges to define the first number, and once the second number is added multiply the first number by 10 and add the second number to it, but have problems with storing the numbers in memory for later execution of the mathematical problem.
I've also tried to use a mathematical approach (Num1*10) +Num2 and store the new value into a Temp_number Memory Block. My challenge to this approach is how to initiate the values (single digit input) and passing down the values as a single value could have a range of 1 to X amount of digits.
My main three questions are:
1- Is it possible to extract values from array blocks and combine, like if you do on a array to string conversation in standard programming.
2- Could a different approach be taken to solve the input challenge of the program.
3- If the mathematical approach a posibilty for success, how could you determine the size of the number pass through the mathematical logic of (Num1*10) +Num2 and adding a decimal point as the user enters the number to be calculated
I am hoping to see if guidance could be provided on how to execute the above. I've being doing some heavy reading for two weeks on Array to String conversion, Multi digit input conversion, and so on, with little result. Must of the examples have predefined values (which technically is in my case) but haven't encounter solutions on combining the single inputs into a whole number.
The scope and goal of project is that if the user toggles switches each individual number will be combined and form a new whole number (E.g.: 123 * 3 / 456 * 2 + 35 - 6 + 1.252, etc...) Just like any current calculator
I truly appreciate any and all guidance support to complete this project.
Yours Truly