Read Ascii data into SLC500 COM port

jake789

Member
Join Date
Jan 2009
Location
Illinois
Posts
4
Hello.

I am trying to read in ascii data (from a welder) to a slc504 com port. I have looked at the ascii instruction set but I am not familiar with ascii.

I was wondering if someone could help me get on the right track.

I used a demo software (Serial Port Terminal by Eltima) to look at the ascii data that is being sent from a welder.

It 'prints' these 5 lines every 15sec or so:
4 1 475VL 476V 12739A .55PF 7C
4 2 475VL 475V 12594A .65PF 7C
4 3 475VL 477V 12551A .60PF 7C
4 4 475VL 476V 12722A .59PF 7C
4 5 475VL 476V 12577A .63PF 7C

I would like to read this into the plc and get this info into intergers:
N7:0 = 1
N7:1 = 12739
N7:2 = 2
N7:3 = 12594
N7:4 = 3
N7:5 = 12551
N7:6 = 4
N7:7 = 12722
N7:8 = 5
N7:9 = 12577


Can someone help me get on the right path? Thanks!
 
Your CH0 serial port will need to be configured for ASCII which can be done from within RSLogix. There are options for baud rate and error checking which will need to match the set up of the welder.

in RSLogix500, You will need to watch the ASCII buffer in the SLC by using the ABL or ACB instructions.

All of your examples appear to be the same length, or number of characters, but it may be possible to get garbage or other strings from the welder, which you want to ignore or treat separately.

When your logic find that there is at least one complete string (correct number of characters), you can read them using the ARL instruction.

This will read one line up to the termination character from the buffer and move the data into the destination ST file address.

From there, you will need to parse the data (AEX instruction). If the string is always guaranteed, no exceptions, just like the examples you posted, then you can fire off instructions that simply extract, then convert the string data into types that you prefer:​

Example: (quotation marks are not actually present in data tables)
ST99:123="4 1 475VL 476V 12739A .55PF 7C"​

AEX
Source: ST99:123
Index: 5
Number: 3
Dest: ST99:10​

Result
ST99:10="475"​

Then use ACI (convert string to integer) to get an actual integer if required by your logic...​

ACI
Source: ST99:10
Dest: N7:150​

If your values within the string can affect the length of the string, making it of variable length, then further logic would be required to search (ASC) for the spaces or other characters in between the values you want so that you can calculate the positions of the needed chunks you wish to extract.​

The logic to deal with your strings may end up being long and seemingly complex, and often worthy of its own conditional subroutine, so that it does not clutter up the flow of your existing program.​

Hope this helps,
Paul​
 
Last edited:
OkiePC has outlined the basics of ASCII handling well. I'd just add an observation.

Since the data sent has the same form each time, it might not be necessary (keeping in mind that we don't know what you intend to do with the information) to store the 1,2,3,4,5 parts. If each set of 5-digit numbers, ie. 12739, is stored in N7:0-4 or N7:1-5 the position could be indicated by its location in the file via indirect addressing.

As an aside, you've done well by supplying enough clear information to quickly get in return a useable answer. Many don't.
 

Similar Topics

I am working on a project, inside an AB CLX, I implemented the Modbus TCP Client AOI published on AB website, to interreact with a Modbus ASCII...
Replies
7
Views
3,586
Good morning to all, I need to modify an existing PLC MIcrologix 1500 configured with a Modem on Channel 1 (DF1 Full Duplex) and an...
Replies
7
Views
1,434
PLC is ControlLogix 1756-L73 CPU with firmware 28 In the PLC the value for A60[110] is "AT", Style ASCII, Data Type INT. In KEPServerEX I tried...
Replies
4
Views
1,557
Hi all, this is the first time I have posted on here, I have been reading with interest for a few years now. The problem I have is regarding...
Replies
1
Views
1,521
I have a micrologix 1200 and I am trying to get a barcode scanner to talk to the COM 0 port. I know the scanner baude rate is 9600 because I...
Replies
0
Views
1,780
Back
Top Bottom