I Need to write a function that takes a 2 digit number and converts this to a string. Yes i could use the I_STRNG function for this. But as i need to display the result with preceeding zero's they will dissapear with the I_STRNG function.
So here is what i have done so far. A 2 digit number is passed, and converted to a word consisting of the char code representation for the number in question.
This is the code i have so far in my FC10, i need to pass a string to an output of this FC.
Example: Decimal 29 is passed, this is converted to 0x3239 which is "29" in string format. ascii kodes 0x32 = "2" and 0x39 = "9". So far no problems. But now i need to construct a valid S7 string. And now i'm not sure how to continue the function.
I do now S7 string format is Actual Length + 2 bytes, and the extra bytes tells the maximum and the actual length of the string. I'm also familiar with the any pointer but still i don't manage to solve this one.
I need to see some similar constructs to learn how to do it. Any one out here with some examples ?
best regards
/pethoek
So here is what i have done so far. A 2 digit number is passed, and converted to a word consisting of the char code representation for the number in question.
This is the code i have so far in my FC10, i need to pass a string to an output of this FC.
Code:
L #In1 // Decimaltal
ITB // Omvandla till BCD
AW W#16#F0 // maska bort LSB
SLW 4 // Skifta vänster 4 bitar
T #L_TEMP // Mellanlagra MSW
L #In1 // Decimaltal
ITB // Omvandla till BCD
AW W#16#F // Maska bort MSB
L #L_TEMP // Ladda MSW
OW // Slå ihop med LSW
L W#16#3030 // 0x3030 = "00"
+I // Addera -> chr koder
OD DW#16#2020000 // Edit: added 2 lines of code to create a DW, which could be copied to the Str:Output
T #L_TEMP
Example: Decimal 29 is passed, this is converted to 0x3239 which is "29" in string format. ascii kodes 0x32 = "2" and 0x39 = "9". So far no problems. But now i need to construct a valid S7 string. And now i'm not sure how to continue the function.
I do now S7 string format is Actual Length + 2 bytes, and the extra bytes tells the maximum and the actual length of the string. I'm also familiar with the any pointer but still i don't manage to solve this one.
I need to see some similar constructs to learn how to do it. Any one out here with some examples ?
best regards
/pethoek
Last edited: