maverick2986
Member
Hello,
I'm currently working on a vision system project where a camera takes a stored image of a pattern and compares it to an image just taken via a trigger (in this case sent from the PLC) and calculate the offset (X, Y in units of pixels; R in degrees). This ASCII string is then read into the PLC. I then "chop it up" into separate ASCII strings to extract the X, Y, and R from the data string. This then get concatenated with a transmission start code ($) along with a few other things and sent to a robot to calculate the offset before moving. I have the format roughly down, however I do have two problems. 1) The string output must be in Hex format so a "-2300" must be output as "FFFFF704". I have no idea of how to do this conversion. Even if I were to convert the ASCII value to an integer, how would I be able to then go ahead and convert it back into an ASCII value but in Hexadecimal format? 2) Many times the offset value is rather large and would probably cause an overflow if I were to convert the ASCII value to an integer. I thought about converting it to a Float but could not find an instruction for ASCII to FLOAT conversion.
Any help would be appreciated. Thank you.
Brian
I'm currently working on a vision system project where a camera takes a stored image of a pattern and compares it to an image just taken via a trigger (in this case sent from the PLC) and calculate the offset (X, Y in units of pixels; R in degrees). This ASCII string is then read into the PLC. I then "chop it up" into separate ASCII strings to extract the X, Y, and R from the data string. This then get concatenated with a transmission start code ($) along with a few other things and sent to a robot to calculate the offset before moving. I have the format roughly down, however I do have two problems. 1) The string output must be in Hex format so a "-2300" must be output as "FFFFF704". I have no idea of how to do this conversion. Even if I were to convert the ASCII value to an integer, how would I be able to then go ahead and convert it back into an ASCII value but in Hexadecimal format? 2) Many times the offset value is rather large and would probably cause an overflow if I were to convert the ASCII value to an integer. I thought about converting it to a Float but could not find an instruction for ASCII to FLOAT conversion.
Any help would be appreciated. Thank you.
Brian