You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old January 7th, 2020, 12:11 PM   #1
jrsnydley
Member
United States

jrsnydley is offline
 
Join Date: Dec 2014
Location: Minnesota
Posts: 141
MicroLogix 1400 - STRING to INT

Hey everybody, Happy New Year!

I have a PanelView Plus 600 that has a String Input Enable. This is communicating with a MicroLogix 1400 and the String Input Enable inputs to ST18:0. I am trying to move this into an Integer with the ACI instruction. The data in ST18:0 is RC 27. When I use the ACI instruction to move it into N15:2 then the data in N15:2 changes to 27. I have never used the ACI instruction before but it seems pretty straightforward. Am I missing something?
  Reply With Quote
Old January 7th, 2020, 12:51 PM   #2
cwal61
Member
United States

cwal61 is offline
 
Join Date: Jan 2011
Location: NC
Posts: 1,148
Quote:
Originally Posted by jrsnydley View Post
Hey everybody, Happy New Year!

I have a PanelView Plus 600 that has a String Input Enable. This is communicating with a MicroLogix 1400 and the String Input Enable inputs to ST18:0. I am trying to move this into an Integer with the ACI instruction. The data in ST18:0 is RC 27. When I use the ACI instruction to move it into N15:2 then the data in N15:2 changes to 27. I have never used the ACI instruction before but it seems pretty straightforward. Am I missing something?
yes, the RC.


it's not an integer value. What are you expecting the value to be?
  Reply With Quote
Old January 7th, 2020, 01:06 PM   #3
jrsnydley
Member
United States

jrsnydley is offline
 
Join Date: Dec 2014
Location: Minnesota
Posts: 141
Well, I guess I thought that String to Int (ACI) converted ASCII to a decimal value and put it into an integer. That is what I am trying to accomplish.
  Reply With Quote
Old January 7th, 2020, 01:08 PM   #4
GaryS
Member
United States

GaryS is offline
 
GaryS's Avatar
 
Join Date: Aug 2003
Location: Lancaster Pa.
Posts: 1,145
you need to first strip off the "27" from the sting
use the AEX function (ASCII extract) and them the ACI (ASCII to INT)
  Reply With Quote
Old January 7th, 2020, 02:00 PM   #5
jrsnydley
Member
United States

jrsnydley is offline
 
Join Date: Dec 2014
Location: Minnesota
Posts: 141
So, the end goal is to have 4 integers containing decimal values equivalent to the ASCII string. The string is 8 characters long.

I am trying to write this data to another processor (via a MSG instruction) within an array of INTS. When it reaches the other processor, it interprets the data there.

Is there a good way to do this or do I have to configure another MSG instruction just to write my string to the other processor?
  Reply With Quote
Old January 7th, 2020, 02:26 PM   #6
MikeyN
Lifetime Supporting Member
United States

MikeyN is offline
 
Join Date: Dec 2017
Location: Illinois
Posts: 66
Would something like this work?
Code:
 BST MOV ST18:0.DATA[0] N15:0 NXB MOV ST18:0.DATA[1] N15:1 NXB MOV ST18:0.DATA[2] N15:2 NXB MOV ST18:0.DATA[3] N15:3 BND
I don't think you need the ACI instruction to do what you want to do. The code above should extract two characters from the string at a time and place them into an integer. 8 ascii characters, 4 integers.
__________________
C:\Dos
C:\Dos Run
Run Dos Run
  Reply With Quote
Old January 7th, 2020, 02:34 PM   #7
jrsnydley
Member
United States

jrsnydley is offline
 
Join Date: Dec 2014
Location: Minnesota
Posts: 141
Thanks MikeyN! That did the trick. I guess I was just overthinking it
  Reply With Quote
Old January 7th, 2020, 09:16 PM   #8
bernie_carlton
Lifetime Supporting Member + Moderator
United States

bernie_carlton is offline
 
bernie_carlton's Avatar
 
Join Date: Apr 2002
Location: Yakima, Washington
Posts: 6,323
But that gives two integers containing two characters each. A need for four integers with one character each was stated.
__________________
Controlling outputs is the PLC's way of getting its inputs to change.

www.thePLCguy.com
  Reply With Quote
Old January 8th, 2020, 07:05 AM   #9
jrsnydley
Member
United States

jrsnydley is offline
 
Join Date: Dec 2014
Location: Minnesota
Posts: 141
Bernie, it is 4 integers N15:0 - N15:3
  Reply With Quote
Old January 8th, 2020, 10:42 AM   #10
bernie_carlton
Lifetime Supporting Member + Moderator
United States

bernie_carlton is offline
 
bernie_carlton's Avatar
 
Join Date: Apr 2002
Location: Yakima, Washington
Posts: 6,323
Thanks, failed to scroll the code box to see the rest. 😀
__________________
Controlling outputs is the PLC's way of getting its inputs to change.

www.thePLCguy.com
  Reply With Quote
Old January 8th, 2020, 03:20 PM   #11
GaryS
Member
United States

GaryS is offline
 
GaryS's Avatar
 
Join Date: Aug 2003
Location: Lancaster Pa.
Posts: 1,145
I need to clarify this for myself and maybe others
Without knowing all of the details of your application it’s hard to tell how to decode the data string.
The first question I would ask if the original string tag originates in the Panelview then why are you passing it to the plc as a string why not create it as the data type necessary in this case an INT array .
It looks to me like the original data is received in the Panelview from another source as a character string and you are just passing the string through to the plc.
Regardless of how the string is placed in the plc in your case in ST18:0 you now have to work with it
From the ST18:0 tells me that table ST18 in an array of strings and you are placing the string in the index 0 of that array. In the 1400 the data tables are all arrays
We must first understand what a string data type is a character / ASCII string is an array of ASCII characters stored as an array of SINT’s one for each character. Decimal numbers 0-255.
The data just tells the software how do display the data so us humans can more easily understand it.
Rockwell by default creates an array of 80 SINT[79] when you create a string data type
So the string “RC 27” would be an array of 5 characters but it is stores and an array of 80
If you simply moved or copied the value of each SINT to an INT array the data would not be what you want.
In your case you want “RC 27” it would be
[0] 82
[1] 67
[2] 32
[3] 50
[4] 55
If that’s the values you are looking for then that would be correct and simply pass them (Copy / Move) to the INT’s array
While I think you really want 27, so to change the character string 27 to INT 27 you need to use the AIC function(ASCII to Integer converter) to get the correct value.
With most String data sent and received there are characters added to the data you want to send / received.
And sent as one continues stream, some devices just continuously resend the same steam over and over.
The extra characters are added to the value so you know when the value you want starts so you can strip it out of the string.
So if the INT you are looking for is 27 then you need to use AEX Function (ASCII Extract) to extract the String 027 then us the ACI (ASCII convert to Integer), you could extract each character to a separate INT tag or indexed array depending your needs.
  Reply With Quote
Old January 9th, 2020, 02:49 PM   #12
MikeyN
Lifetime Supporting Member
United States

MikeyN is offline
 
Join Date: Dec 2017
Location: Illinois
Posts: 66
I made a few assumptions based on this quote:
Quote:
Originally Posted by jrsnydley View Post
So, the end goal is to have 4 integers containing decimal values equivalent to the ASCII string. The string is 8 characters long.
I assumed that OP wanted the entire ASCII string, not just the "27" out of "RC 27".

The Micrologix 1400 is programmed using RSLogix 500, not Logix 5000 so strings are handled differently. Two ASCII characters can fit into one 16 bit integer. Using the solution that I provided in post 6, the String and integer equivalents can be broken down like this:
Code:
ST18:0.DATA[0] = "RC"     --> N15:0 = 21059
ST18:0.DATA[1] = " 2"     --> N15:1 = 8242
ST18:0.DATA[2] = "7\00"   --> N15:2 = 14080
ST18:0.DATA[3] = "\00\00" --> N15:3 = 0
If OP was only looking for the 27 then yes an AEX (String Extract) and ACI (String to Integer) would be used. The code would look something like this:
Code:
 BST AEX ST18:0 4 2 ST18:1 NXB ACI ST18:1 N15:4 BND
The "27" is extracted from "RC 27" starting at position 4 and extracting 2 characters. This is then stored in another string variable, ST18:1. On the next branch ST18:1 is converted to an integer and stored in N15:4.
__________________
C:\Dos
C:\Dos Run
Run Dos Run
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Micrologix question Holly LIVE PLC Questions And Answers 20 October 12th, 2019 01:53 PM
Ultrasonic Induced Voltage into a Micrologix 1400 PLC? TimWilborne LIVE PLC Questions And Answers 3 August 7th, 2019 09:33 AM
Micrologix 1400 and Citect gnash- LIVE PLC Questions And Answers 12 September 24th, 2014 02:46 AM
Modbus TCP communications with Micrologix 1400 H2Otbaker LIVE PLC Questions And Answers 6 April 13th, 2014 01:41 AM
Micrologix 1400 + Panelview 550 + DH485 alexbeatle LIVE PLC Questions And Answers 2 September 13th, 2011 11:30 AM


All times are GMT -5. The time now is 10:27 PM.


.