Micrologix 1500: String to hex to integer?

asteroide

Member
Join Date
Jul 2010
Location
der
Posts
158
Hello friends



I am reading 32 bytes from a display through ML1500 COM1, configured as ascii and storing in ST file



What I am reading is:



ST9:2 ^S¡001F40001046F0011005F________%



I have extracted to :



ST9:3 046F



ST9:5 0011



That are the values that I am interested



Everything is ok, but...



These values are Hex, how can I get as integer?



I mean, I want to see:



1135



17





Is it possible, or should I change something?



Thanks in advance
 
Move ST9:3 and ST9:5 to an integer (N file). This will display them in integer format. Does that help?
 
Hello

I have done what you said, but:


"The processor searches the source for the first character between 0-9. All numeric characters are extracted until a non-numeric character or the end of the string is reached. Action is taken only if the numeric characters are found. "

So, like this is an hex value, for example:

00F6

after ACI instruction = 0


Do you have another idea?

Thanks
 
You're right that the ACI instruction will not work when the string is hexadecimal, because it looks only for the digits 0 through 9.

I think you're going to have to decode this by hand.

It's going to be tricky because of the way that the MicroLogix uses 16-bit data elements to store 2 characters at a time in the String datatype, and because it has no 8-bit datatype.

The good news is that the MicroLogix 1500 does have a Long Integer datatype (a Signed one, no Unsigned U32) so you'll be able to represent any 4-byte value as a signed integer.
 
I worked on this a little last night and it reminded me how accustomed I've gotten to the ControlLogix datatypes and instruction set.

This is going to take a little on-demand subroutine to mask, shift, swap, subtract, and reassemble this data one byte at a time.
 
Attached is a subroutine example that will take a four-byte hex string in ST9:0 and convert it into a signed integer value in N10:11.

This could probably be done in fewer rungs, but this method shows each step explicitly. Using 4-bit shifts and byte swaps and masked moves is confusing enough !
 

Similar Topics

Hello, I am a veteran Mitsubishi programmer, but am new to AB. I have a Micrologix 1500. I am receiving a string via RS232 on Channel 1. In...
Replies
3
Views
5,014
I have been working on this for a while now and I can't seem to get it. I was finally able to view the 1500 on the PanelView under the serial...
Replies
1
Views
99
Hello, I have a 1764 1500 LSP Series A that keeps failing with DTL_E_FAIL I/O error. Searching around it seems there's a weird issue specifically...
Replies
2
Views
110
Good Day i Have Micrologix 1500 LSP, and I want to get data from plc and send it through Modbus RTU slave; I have only ch0 on that plc I Order...
Replies
6
Views
923
Hello folks, Hope everyone is doing fine. I got an OMRON NS10-TVOOB-V2 hmi screen last day and planning to use it with Micrologix 1500. 1. Is...
Replies
4
Views
1,211
Back
Top Bottom