Converting Integers to ASCII in Step 7

Bobbeh

Member
Join Date
Oct 2007
Location
London
Posts
22
Hey guys,

I hope you can help me.

Not sure if I am totally missing something here but is there an easy way to convert an integer into ASCII in step 7 without returning the string version of it? I only say this as I have found FC5 in the IEC standard functions which allows you to convert DINT into ASCII, but outputs a string which I then cannot view.

What I need to do is convert integers into ASCII but still view the individual bytes. For example, 255 is 0xFF and each F is represented by 46 in ASCII so 255 becomes 4646. I then want to extract each ascii byte (46 in this case) so i can place it in a byte array and send over TCP/IP using the TSEND function.

Would it be best to do this using number extraction and maths for the conversion or by changing my byte array into a string array and then attempting to use the IEC converting block to produce a string of ascii characters?

Many thanks.
 
A string consists of two header bytes that define the maximum string length and the actual string length followed by bytes containing the characters in the string.

Generate the string using FC5 and then copy the characters from the string into the byte array you are using for the send. Note that the char data type is available - you can copy the bytes to an array of chars if you want to view the data dynamically.
 
Thank you very much, changing it from the string array to the char array did the job. Your code is much neater and compact than mine was.

I don't understand the string headers but they are not really needed anyway.

Thanks.
 
Sorry, it turns out I have found out what I actually asked was slightly incorrect. I have found that using the HEX to ASCII block FC95 gives me exactly what I need.

Thanks a lot for the help though.
 

Similar Topics

Hi, I am using a Phoenix Contact PLC and trying to use it to write a Floating point over Modbus. To do this I need to convert it to two 16 bit...
Replies
24
Views
6,786
i am communicating 1766-l32bwb with conzerv make energy meter em 6436. I have communicated it on Modbus rtu. but i am not able to decode the data...
Replies
2
Views
4,674
How do you convert 32 bit long integers into something that the AB PLC-5 can represent correctly? My problem is that I am trying to get values...
Replies
23
Views
22,367
I need help converting from a floating register to two integer words. I'm using a SLC 5/05 and need to be able to write 32 bit data to a servo...
Replies
2
Views
4,707
Hello everyone, can anyone help me with covert the STL code to ladder. Iam using plc s71200. A %DB1.DBX33.7 // angel of vaccum...
Replies
2
Views
208
Back
Top Bottom