Jump to content

PARSING ASCII STRINGS INTO UINTS, WORDS, FLOATS


Recommended Posts

Posted
Guys, I've been playing around with some instructions and have come to a minor road block, i need some help here... I'm receiving an ASCII String via TCP to a CJ2, for the purposes of this discussion lets say the string looks like this: "@IdNum1234" I'm using MOVD to organize the "1234" into a couple of words. How would you guys go about turning the "1234" in ASCII to a UNIT value? any help would be greatly appreciated!
Posted
Perfect, i knew i was missing something that was staring right at me. It's HEX to make 4 nibbles or (omron digits): 1234 Then BIN to make BCD to UINT. Now i have to get to the strings that look like this : "1234.12" THANK YOU!
Posted (edited)
How would you go about the sign? eg: +1234 Vs -1234 i found the BISL instruction to do signed BCD but im wondering if theres a better way to go about it... Edited by RickyQ
Posted
Is the sign going to be in the same place each time? If so, compare that part of the address to the hex code for minus. If the hex code for minus is there, multiply the conversion by -1 using a multiply instruction.
Posted
Hey guys, i have all the conversion working and am now diving into how fast i can process all of this stuff... i have what may be a silly question but i want to make sure: Let's say for arguments sake that the PLC is set to run at 30ms, and i am using the TCP FB from the library to receive data. If i use the status of the data received flag to trigger the FB to receive the data from the buffer, does that mean that i can only receive data at 30ms?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...