Ascii

jimcav

Member
Join Date
Dec 2004
Location
new jersey
Posts
229
Hello

I am using a micro logic 1500 and i need to convert a floating point value to a string, i know i can convert a integer to a sting with an AIC command. i was thing floating point to long integer then to string. my goal is to write the value out to channel 1 with AWT command.

thanks
jim cav
 
Greetings Jim.

I posted a program over at the Mr PLC forum downlosd section that will round and truncate a floating point number that might be useful for this.
http://forums.mrplc.com/index.php?download=761
However a few more steps will be required, and depending on what you want to do, there might be much simpler ways, so I have a couple of questions...

Are you using a float because the number is larger than 32767? Or are you using a float because you need to represent a fractional number? If the latter, how many places do you require after the decimal point in your output string?
 
Last edited:
Do you need to include any digits after the decimal point? The truncate program I posted earlier is mainly for use in a SLC500 and since the ML1500 supports 32 bit data there may be better tools. The simplest is what you have already suggestes, just MOV the float to a long and then AIC the long. If you need some digits after the decimal then it takes a couple of more steps.

For two decimal places and floats smaller than 21 million*, this might work:

String ST10:2 is set to "." so we can insert a decimal point.
MUL F8:0 100.0 F8:1 Multiply by 100 and put in F8:1 because compiler returns size mismatch when specifying a long as the destination.
MOV F8:1 L9:0 Move to long (this will round)
AIC L9:0 ST10:0 Convert to String
MOV ST10:0.LEN N7:0 Copy string length to N word because compiler won't let ST10:0.LEN be used in a math instruction.
SUB N7:0 2 N7:0 Subtract two from the string length
AEX ST10:0 N7:0 2 ST10:1 Copy the last two characters of the string to a new string ST10:1
MOV N7:0 ST10:0.LEN Delete the last two characters.
ACN ST10:0 ST10:2 ST10:0 Add the decimal point.
ACN ST10:0 ST10:1 ST10:0 Add the last two characters after the decimal point.


(* note that beyond 16 million a float won't have any resolution in the tenths or hundredths column)

edit: BTW, there is a similar thread on another forum for a ControlLogix where Gerry has given a very elegant solution :geek: for the CLX platform.
http://forums.mrplc.com/index.php?act=ST&f=1&t=14631&st=0
 
Last edited:

Similar Topics

Hi, We couldn’t find anything specific, so am starting a new thread. I’m trying to migrate a config from a ML1400 to a micro820 & am experiencing...
Replies
1
Views
92
I have an L24ER-QB1B with a 1769-ASCII card in slot number 4. I'm looking to send data to this zebra printer after every completed sequence. I'm a...
Replies
2
Views
435
Hi to everybody. I need to read the first 12 characters of the message that a barcode reader sends to the ascii card (1734-rs232 ascii) and I...
Replies
8
Views
725
I am trying to import addresses and symbols from a PanelBuilder32 application into the RSLogix 5 Address/Symbol database - however each time I...
Replies
5
Views
533
Good day! I am working on a project at our campus to integrate fleet vehicle chargers with load management so we don't overwhelm our service. The...
Replies
37
Views
3,799
Back
Top Bottom