RickyQ Posted March 14, 2012 Report Posted March 14, 2012 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! Quote
Michael Walsh Posted March 14, 2012 Report Posted March 14, 2012 Use the HEX (or NUM4, I think) code to convert 1234 ASCI to 1234 Hex. Then use the BIN command to convert the 1234 Hex (which is a BCD number actually) to a binary number (decimal). Quote
RickyQ Posted March 15, 2012 Author Report Posted March 15, 2012 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! Quote
RickyQ Posted March 15, 2012 Author Report Posted March 15, 2012 (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 March 15, 2012 by RickyQ Quote
Michael Walsh Posted March 15, 2012 Report Posted March 15, 2012 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. Quote
ParaffinPower Posted March 16, 2012 Report Posted March 16, 2012 Hi FLTL converts directly from ASCII to REAL. Works for scientific notation, too. Pp Quote
chelton Posted March 16, 2012 Report Posted March 16, 2012 I think Pp might be referring to FVAL not FLTL. Used it on a recent project, works a treat. Quote
RickyQ Posted March 20, 2012 Author Report Posted March 20, 2012 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? Quote
Recommended Posts
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.