Posted 19 Mar 2022 Hello programmers, maybe sameone can help me, i have a number for example 458 how to extract this number to digits ? 4 5 8 in Twincat or codesys? tx! Share this post Link to post Share on other sites
Posted 19 Mar 2022 You could convert to string and process each character to a number. Or you could divide by 10, multiple the remainder by 10. Then subtract the remainder from the divide result and repeat the above line until a single digit remains. 1 person likes this Share this post Link to post Share on other sites
Posted 20 Mar 2022 exactly... or convert it to BCD. many PLCs will have ready instruction for that. TwinCat has it too - lookup DEC_TO_BCD. in BCD each digit is in separate nibble (4 bit block) 1 person likes this Share this post Link to post Share on other sites