alpha91

Convert decimal to hex manually

9 posts in this topic

Dear all, did anyone did this before.

Actually I require to store the weighing reading in hex in order for SCADA to read. But now the weighing value is in decimal format.

For example: 

Indicator display 1234 KG

suppose I need to store this value in 1234(hex) in data register, but now is 1234(decimal).

Does anyone here know how to do it? or can i do it manually? i have no idea on how to convert it.

Share this post


Link to post
Share on other sites
On 4/21/2017 at 9:29 PM, kaiser_will said:

Decimal = 1234 kg

Hex => 1234/16 = 77 plus remainder of 2; next...77/16 = 4 plus remainder 13 (which is D); next...4/16 = 0 plus remainder 4.  Thusly, Decimal 1234 = Hex 4D2

http://www.rapidtables.com/convert/number/decimal-to-hex.htm

http://www.permadi.com/tutorial/numDecToHex/

 

Hi, yes, I got 4D2 when displaying in hex. But what i need is I need to show 1234kg in hex instead of 4D2.

Share this post


Link to post
Share on other sites

Convert decimal number to BCD and display in Hex

1234 (decimal) =  0001001000110100 (BCD)

0001001000110100 (BCD) displayed in HEX format = 1234(hex)

Edited by Moggie

Share this post


Link to post
Share on other sites
23 hours ago, Moggie said:

Convert decimal number to BCD and display in Hex

1234 (decimal) =  0001001000110100 (BCD)

0001001000110100 (BCD) displayed in HEX format = 1234(hex)

Hi, thank you very much for your help.

But i found that there is no function block in my Panasonic PLC can perform this function. 

So is that means i need to do it manually, for example, write a calculation function for this conversion? or is there any better way to do this?

Share this post


Link to post
Share on other sites
55 minutes ago, alpha91 said:

Hi, thank you very much for your help.

But i found that there is no function block in my Panasonic PLC can perform this function. 

So is that means i need to do it manually, for example, write a calculation function for this conversion? or is there any better way to do this?

What model PLC are you using - or look at P80(BCD) / P82(DBCD)

Share this post


Link to post
Share on other sites
9 hours ago, Moggie said:

What model PLC are you using - or look at P80(BCD) / P82(DBCD)

Hi, it works! with the P80. Thank you very much.

May I know what is happening for this function? Sorry that i rarely do data conversion. I just roughly get the concept.

Is it the current decimal i reading now is BCD? 

9 hours ago, panic mode said:

Hi, thank you very much for the manual. 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now