mparodi91
Member
Hello everyone!,
I am having a problem encoding decimals to ASCII, I need to store all 256 decimal characters (0-255) but ASCII encoded in Sting format.
the need arises from wanting to establish serial communication between the PLC (micrologix 1400) and a Liquid Control IQ controller that handles ASCII, so when receiving and sending messages I need to know which node it belongs to. For this particular case, by default the controller has the address 250, that is, I am going to have to read that message.
The conversion is done with a MOV, where in the integer N7 I store the product between 256 and the decimal number that corresponds to the ASCII symbol. Then I concatenate the address of the string of the new value, with the address of the string where I am assembling the chain.
The first image shows the aforementioned.
N7: 0 = 126 * 256 = 32256,
N7: 1 = 65 * 256 = 16640,
N7: 2 = 55 * 256 = 14080,
Now when I want to do the same methodology to represent those greater than 128, I count to find the complement -> ((X-128) * 256) -32768
using the same program, I reloaded the values into the N7 file with the following reasoning
N7: 0 = (250-128) * 256-32768 = -1536,
N7: 1 (144-128) * 256-32768 = -28852
N7: 2 = (160-128) * 256-32768 = -246576
As seen in the second photo, the conversion adds symbols. I tried to extract a part of the string to rebuild the message, but could not find the solution
I have been reading previous threads, but the truth is that none of them addresses characters greater than 127
This is my first job as a professional, any help will do, thank you very much in advance!
I am having a problem encoding decimals to ASCII, I need to store all 256 decimal characters (0-255) but ASCII encoded in Sting format.
the need arises from wanting to establish serial communication between the PLC (micrologix 1400) and a Liquid Control IQ controller that handles ASCII, so when receiving and sending messages I need to know which node it belongs to. For this particular case, by default the controller has the address 250, that is, I am going to have to read that message.
The conversion is done with a MOV, where in the integer N7 I store the product between 256 and the decimal number that corresponds to the ASCII symbol. Then I concatenate the address of the string of the new value, with the address of the string where I am assembling the chain.
The first image shows the aforementioned.
N7: 0 = 126 * 256 = 32256,
N7: 1 = 65 * 256 = 16640,
N7: 2 = 55 * 256 = 14080,
Now when I want to do the same methodology to represent those greater than 128, I count to find the complement -> ((X-128) * 256) -32768
using the same program, I reloaded the values into the N7 file with the following reasoning
N7: 0 = (250-128) * 256-32768 = -1536,
N7: 1 (144-128) * 256-32768 = -28852
N7: 2 = (160-128) * 256-32768 = -246576
As seen in the second photo, the conversion adds symbols. I tried to extract a part of the string to rebuild the message, but could not find the solution
I have been reading previous threads, but the truth is that none of them addresses characters greater than 127
This is my first job as a professional, any help will do, thank you very much in advance!