G_DeMark

How to check for a Null value

3 posts in this topic

I am reading in a data matrix string from a Cognex camera.  On one occasion there was an error with the barcode (it was missing some data).  Does anyone know if there is a way to check for Null values.  For example, how would I check 'READ[1].DM_HSG.DATA[0]' to see if it is holding the null value ($00)?  I am using Logix 5000 version 30.

Any ideas?

Thanks

 

Capture.JPG

Share this post


Link to post
Share on other sites

You can check each SINT register with EQU instructions comparing it to 0. That's a little brute force, though. Or you can use a FIND instruction to look for $00 in the string tag:

NullCheck.PNG.f52fbdb7fd37f5c586bf5dcfe4

Tinker with that a little. With a valid string value in NullCheck_String, the FIND instruction returns 0. If there's an extra null in there, it returns the location of the null:

NullCheck_Expanded.thumb.PNG.de5cf3b6b9a

 

 

Share this post


Link to post
Share on other sites

Perfect solution.  Thanks very much

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