Converting hex to dec/bcd

R

Thread Starter

Richard Bland

Anyone know the command for converting hex to dec/bcd in S7?

Any help greatly appreciated!

Cheers

 
A

Andrew Hawdon

There is not a command to convert from Hex to decimal. For example the number 467D in hex is 18045 in decimal. Therefore I assume it is just the format of the represntation of the number that you wish to change. This you can do by using the MOVE instruction to transfer the number to a memory lacation that is defined in the Symbol table or Data Block as an INT (integer). The number will then be displayed as a decimal number. To convert the Integer to BCD is simple. If you look under convert instructions you will find an instruction to convert I_BCD which is all you will need

Andrew
 
R

Richard Bland

Thanks Andrew. This works a little differently from the Omron PLC's I am more used to where you actually have to convert hex values using a BIN command e.g making analogues available for BCD maths.

Much appreciated
 
Z

Zan Von Flue

hi
In the case of a integer +/- 999 to BCD the AWL command is ITB (Integer to BCD). Then BCD to Integer is BTI. This is a 16bit command. I believe there is a 32 bit SFC but didn't look for it.
-123(integer) or FF85(hex)
= -123(BCD) or 1000 0001 0010 0011 (binary) bcd - bits 12..14 are not looked at.
insert BTI or BTI, then F1. The help is very good.
I hope this helps
zan
 
Top