T_Antich

Convert ASCII to text, Studio 5000

6 posts in this topic

Hello

I am having an issue I am hoping someone can help with. I have an OCR camera system (Keyence CV-X402F) that is extracting an engraved serial number off a part that we are wanting to send to our MES so that it can use that serial number for tracking build information. I am sending the recognized string via Ethernet_IP to an AB 1769-L30ER as a DINT with an ASCII value. My MES needs to pick that up as human readable in order to work correctly. The serial number is 9 characters long and is stored in 9 different address'. I have been able to use the concatenate block to get it to one location and together but I cannot figure out how to convert it to its human readable form (seeing an M instead of 77). I have tried to use the DTOS block both before and after my concatenation but I always end up with just a string of ASCII code. This is what I am getting after is has been concatenated, 775048515451665057, which is correct, when you split it out it does translate to what I want, M20363B29. What do I need to do in the program itself for my final result to be M20363B29 instead of 775048515451665057? I am literally at my wits end and any help would be extremely appreciated.

Thanks 

Share this post


Link to post
Share on other sites

Hello, 

 

Create a new tag. The type has to be string. The string datatype have 2 kind of tag, the data and the length. Move the number how long do you need. Also when you create the datatype set the style to ascii.

 

I guess thats it. If you want I could send you an example ladder diagram.

1 person likes this

Share this post


Link to post
Share on other sites

@T_Antich To lay out what @ABlearner describes it will look like the following:

String Type Tag named MES_SerialNumber

DINT Tags Dint1, Dint2, Dint3, Dint4, Dint5, Dint6, Dint7, Dint8 and Dint9.

First Ladder Rung is a MOV 9 MES_SerialNumber.Length.

Next Ladder Rung is a MOV Dint1 MES_SerialNumber.Data[0]

Next Ladder Rung is a MOV Dint2 MES_SerialNumber.Data[1]

Next Ladder Rung is a MOV Dint3 MES_SerialNumber.Data[2]

Next Ladder Rung is a MOV Dint4 MES_SerialNumber.Data[3]

Next Ladder Rung is a MOV Dint5 MES_SerialNumber.Data[4]

Next Ladder Rung is a MOV Dint6 MES_SerialNumber.Data[5]

Next Ladder Rung is a MOV Dint7 MES_SerialNumber.Data[6]

Next Ladder Rung is a MOV Dint8 MES_SerialNumber.Data[7]

Next Ladder Rung is a MOV Dint9 MES_SerialNumber.Data[8]

Your MES System can then read t=the String Tag

1 person likes this

Share this post


Link to post
Share on other sites

@BobLfoot  🙇 🙇 

Thank you to fixing my poor explanation.

1 person likes this

Share this post


Link to post
Share on other sites

You're welcome @ABlearner but don't knock your explanation it was solid.  I just put flesh on the bones you laid out.

2 people like this

Share this post


Link to post
Share on other sites

@BobLfoot and @ABlearner

Thank you guys for your input and very elegant solution. I’m disappointed I left my programming laptop at the shop for the weekend now because I would like to try this out. 
 

I did actually come to a solution and am too new at this to be too embarrassed to share. I feel like it’s a little hokey and messy but it does work. Since my character pool was small and I only had 9 spots to worry about I wrote an ASCII decoder. I just made a no external control constant string tag for each character in my pool then got creative with what limited programming knowledge I have to do some comparing and replacing. I’d be more than happy to go into the details if anyone is interested but won’t list all the boring details unsolicited.

Thanks again for the help, I will throw this suggestion into the program see if I can get it figured out this way also.  
 

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