deividasn Posted March 19, 2022 Report Posted March 19, 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!
Mark- Posted March 19, 2022 Report Posted March 19, 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
panic mode Posted March 20, 2022 Report Posted March 20, 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
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now