Integer to binary conversion

Guest Wuchi

Recommended Posts


How is it possible to convert a data from PLC to convert it to Binary data.

Best regards,


Maybe i haven't asked from the right angle :(

I have for example integer of value 400, how can i convert it to binary data in DAQ?


Link to comment
Share on other sites

Guest Guest_AzeoTech

There actually is no simple way to do this, even in Release 5.3 which allows easy conversion from dec to hex and dec to octal.

That said, you can use the TestBit() function to examing each bit your number, which is usually what you want to do. For example, TestBit(503,2) returns 1.

If you actually want to do a conversion, you could write a simple sequence function:

Private.strOut = ""

for (Private.x = 7, Private.x >= 0, Private.x--)

Private.strOut += Format("%.0f",TestBit(Private.arg0,Private.x))



This will convert a decimal number into an 8 bit binary number. Change the 7 to 15 and you can do 16 bit binary.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.