Aoto10

How to check for non HEX characters in ASCII data

3 posts in this topic

I have a machine that will sometimes execute the HEX instruction with characters that are not HEX values. The instruction gives the 4100 operation error, the PLC goes to stop and machine will stop entirely. I don't want to change PLC RAS to continue if this error occurs. I have no way of changing the data I receive since it comes from a outside machine. I'd prefer to just check the data before the HEX instruction executes and prevent the execution entirely if the data is going to cause an alarm. I made a sample ladder below of what I came up with to check each of the 4 characters of data. It seems kind of redundant and I feel could be made shorter using different functions. Is there an easier way to do this? If had many more characters this would take many rungs of ladder to accomplish. Thanks.

 

Capture.thumb.PNG.81b81f1621326217462570

Share this post


Link to post
Share on other sites

For the test string part you could have used $mov (stringmov).

With LEN you can check the characterlength of the string and than make a FOR NEXT loop checking each character.

Which PLC are you using ? 

 

Share this post


Link to post
Share on other sites
1 hour ago, Gambit said:

For the test string part you could have used $mov (stringmov).

With LEN you can check the characterlength of the string and than make a FOR NEXT loop checking each character.

Which PLC are you using ? 

 

Machine has a Q50UDEHCPU. I tried the FOR NEXT loop you mentioned. I see where this accomplishes the same thing with less ladder for a longer string. Is this what you had in mind? I tested and it does work. Could this be improved more? Like using a break to exit the loop if a bad value was found?

 

Capture2.thumb.PNG.f729504a7f959cfe92049

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