Sign in to follow this  
Followers 0
bobbyosborne01

Ascii conversion

6 posts in this topic

Greetings All! I have a Q series plc with a QJ71C24 serial card connected to a Keyence LS-7600 Digital Micrometer. I need to compare the keyence read out to a constant to control a servo motor. The Keyence is sending 13.978 in ascii characters to the serial card and the buffer memory looks like this: BM00-1540- 13 BM00-1541- .9 BM00-1542- 78 My question is how do I get the ascii out of the buffer memory into a D register (or somewhere else) and in a format I can use? I tried DMOVP U0\G1540 D600 (using a clock bit to trigger) and it looks like I get a 32 bit integer but I don't know what to do with that number. When I try to use WORD or HEX I get a 4100 (I think) error on the plc. I looked at similar post on this site but they all seem to have the ascii number already in a D register and in a hex format. Any help would be greatly appreciated. Bobby Osborne

Share this post


Link to post
Share on other sites
You need to convert the ASCII to real number. The command to do that is EVAL.

Share this post


Link to post
Share on other sites
Would that be EVAL U0\G1540 D600 or EVAL D600 D600?

Share this post


Link to post
Share on other sites
You should move that data into PLC registers first. So if it's 3 registers long, you can use BMOV U0\G1540 D600 k3 Then you need to make sure the next register (D603) has zero in it (terminator for ASCII is hex 00). MOV H0 D603 Then you can run the EVAL instruction to convert that data and place it into another register (32-bit floating point, so 2 registers). EVAL D600 D604 End result is a floating point number in D604 and D605.

Share this post


Link to post
Share on other sites
Nice one, that is quite handy for me as well. Thanks, Crossbow.

Share this post


Link to post
Share on other sites
Thanks, It will be a few days before I get back out to the facility to try this. I will let you know how it turns out. Bobby Osborne

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0