Pete Moss

Ascii

11 posts in this topic

I am working on code for micrologix1100; there is a point where an operator will use a PB to select option 'A' or option 'B'. There is a scada system which polls this plc for the A or B selection and displays either 'A' or 'B' in a field of its own. I see in the instructions upper case "A" is represented by "65" in ACSII and upper case "B" is represented by "66". I used the AIC function to convert the numeric to ASCII and place the result at ST14.1 and ST15.1 respectively. Howeve when I examine those words, I simply see 65 and 66. How do I create the ASCII string?

Share this post


Link to post
Share on other sites

I would simply assign this to a binary bit such as B3:0/0. This way A can be zero and B can be one.  Then in your HMI you can read the binary and have 0 represent A and 1 represent B.

Share this post


Link to post
Share on other sites

Not an option - Corporate wants to see the A or B designation

Share this post


Link to post
Share on other sites

Not sure I understand. It would still be an A or B on the HMI. It is just easier to work with numbers than ASCII in the HMI to PLC exchange. Might even for with an integer sich as N7:0 just in case there is ever an option C

Share this post


Link to post
Share on other sites
Quote

Howeve when I examine those words

Examine them where?

The programming software? Change the radix for viewing.

The SCADA. which SCADA and "examine them where" in the SCADA?

 

Share this post


Link to post
Share on other sites
15 hours ago, TWControls said:

Not sure I understand. It would still be an A or B on the HMI. It is just easier to work with numbers than ASCII in the HMI to PLC exchange. Might even for with an integer sich as N7:0 just in case there is ever an option C

I am developing the code for the ML1100 PLC, there is a systems integrator developing the server software, there is another person developing the MII with is where the data will be reviewed. The systems integrator wants me to provide the ASCII string representing upper case A and B; so that when their software captures the data, it is represented in alpha characters. Initially I was going to use a numeric value and wanted the systems integrator to convert that value to alpha characters in their software.

Share this post


Link to post
Share on other sites
2 hours ago, Pete Moss said:

I examine the ST14.1 and ST15.1 registers

Yes, but where? In which software program?

Are you setting the length byte in the ST register or only putting a value in ST14:1?

Share this post


Link to post
Share on other sites
4 minutes ago, Mark- said:

Yes, but where? In which software program?

Are you setting the length byte in the ST register or only putting a value in ST14:1?

I did not set a length; I am looking in the ST14 folder in RS logix 500. It shows a length of 2 characters under the length tab

Share this post


Link to post
Share on other sites
6 hours ago, Pete Moss said:

I did not set a length; I am looking in the ST14 folder in RS logix 500. It shows a length of 2 characters under the length tab

IIRC, that is the count of elements in the file.

IIRC, the first byte of each element is the length byte. It should be one for a single character.

 

Share this post


Link to post
Share on other sites

ST14.1 (as well as ST15.1) are incorrect addresses specifications. Let's see if we can clear this up.

ST14 is a file which can hold up to 255 strings. ST14:0 would be the first string in this file. ST14:1 would be the second string in this file.

Each string has two sections. First is an integer (16 bits) which holds a count of the number of characters in the string. It has a name of LEN (length). For ST14:0 the length section is addressable as ST14:0.LEN Most external devices which read a string require that this count is correct. It is maintained by the ASCII instructions. It is also updated if characters are placed in the string from the Data File view.

Following the length section is a space for up to 82 characters. It has a name of DATA. It is an array 41 long. It is addressed as ST:14.DATA[index] with the index being 0 to 40.These are 41 integers each holding 2 characters. This can sometimes get confusing as the 2 characters within a single 16 bit integer can sometimes be out of the order as expected by your remote device.

if you double click on the string file the Data File view window will open. You can manually place characters in a string by clicking just after the LEN heading under the under the 'String Text' area. After entering the character(s) you wish press ENTER and the LEN will be updated.

To view this better (since you can't change the radix of viewing in the Data File) create a rung with a MOV command of some value (it doesn't matter what, we won't be executing it) with a destination of ST14:0.DATA[0]. This will address the first integer (or 2 characters) of this string. On accepting the rung you should see shown under the ST14:0.DATA[0] the contents of this first integer. Using Data File window I placed an 'A' in the string. In the MOV command I see A\00 under the address. This indicates that the first integer has an 'A' and a null (\00) in it. It only has one character. If you use the Data File to place 'AB' in the string you see AB under the address.

Now let's place 'ABCD' into the string - remember to press ENTER. The length changes to 4. But in the instruction you still only see AB as it is only showing the first integer. If you change the destination of the MOV command to ST14:0.DATA[1] and accept the rung you will see the contents change to CD.

The MOV command - used by itself - can update the contents of the DATA area but DOES NOT automatically update the count (LEN). If a given string will be updated with various characters at runtime (using a MOV command) then you must maintain the count. If a given string will always have the same number of characters then don't worry. But it is not recommended to use the MOV command to update the characters. Investigate the COPY command to copy a complete string into another. Also check out the various ASCII commands.

 

 

 

Edited by b_carlton

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