You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old January 10th, 2006, 11:35 AM   #1
steve500
Member
United Kingdom

steve500 is offline
 
Join Date: Jan 2006
Location: solihull
Posts: 2
Thumbs down converting hex to decimal

Could anybody send me a program illustrating usng s7 how to convert a hexiecimal vaue into a decimal value

Thanks

Steve.
  Reply With Quote
Old January 10th, 2006, 01:45 PM   #2
jvdcande
Member
Belgium

jvdcande is offline
 
jvdcande's Avatar
 
Join Date: Apr 2002
Location: Menen
Posts: 2,047
Steve,

ever thought of simply moving (copying) the hex variable to a variable defined as integer?

Regards,
__________________
Jean Pierre Vandecandelaere
Trainer nautical sector
VDAB Competentiecentrum
L. Blondeellaan 9
B-8380 Zeebrugge
Belgium
  Reply With Quote
Old January 10th, 2006, 02:03 PM   #3
chrisray
Member
United Kingdom

chrisray is offline
 
Join Date: Nov 2005
Location: Essex
Posts: 22
Numbers

Sorry I don't know what s7 is but you might find these useful

Use these links; http://www.tonymarston.net/php-mysql/converter.php

http://en.wikipedia.org/wiki/Hexadecimal

Chris

Last edited by chrisray; January 10th, 2006 at 02:06 PM.
  Reply With Quote
Old January 10th, 2006, 04:20 PM   #4
rdrast
Lifetime Supporting Member
United States

rdrast is offline
 
rdrast's Avatar
 
Join Date: Apr 2003
Location: South Carolina Lowcountry
Posts: 3,872
Windows Calculator.

You aren't looking to 'convert' a number, you are looking to change the representation of a value stored in a computer.
10 (base 10, decimal) is equal to 0A (base 16, hexadecimal) is equal to 12 (base 8, octal) is equal to 1010 (base 2, binary).

For that matter, it's also equal to 101 (base 3, trinary?) or 022 (base 4, quarnary?).
  Reply With Quote
Old January 11th, 2006, 02:37 AM   #5
SimonGoldsworthy
Member
United Kingdom

SimonGoldsworthy is offline
 
SimonGoldsworthy's Avatar
 
Join Date: Mar 2005
Location: England
Posts: 1,079
Why do you need this, which s7 plc is it for ? and what is your step 7 experience ? The reason I ask is that the implementation can be completely generalised and use pointers, or it can be simple and only work for a well defined set of circumstances. Give us a clue as to which way to go !
  Reply With Quote
Old January 11th, 2006, 04:51 AM   #6
steve500
Member
United Kingdom

steve500 is offline
 
Join Date: Jan 2006
Location: solihull
Posts: 2
The PLC is a siemens cpu 314.

My experience is limited and the application which I need the conversion software is as follows;

WE have a SCA gluing application which sends quantity data in the form of hexidecimal to our siemens PLC which inturn sends the data to our server as we need to keep gluing quantities for our records.

The SCA cannot convert from hex from there side and was hoping to convert the data in the PLC.
Is there a simple way???

Thanks for your help.
  Reply With Quote
Old January 11th, 2006, 05:31 AM   #7
RMA
Member
Scotland

RMA is offline
 
RMA's Avatar
 
Join Date: Sep 2004
Location: North of Hamburg, Germany
Posts: 2,046
As rdrast said above, if what you are receiving in the PLC is actually a number, then its format (hex, decimal, etc.) is irrelevant - the value is the same regardless of the display format.

If, on the other hand, what is actually being sent to the PLC is a text String (usually displayed in hex) representing the number, then you need to convert this String to a number using the IEC functions available in the Standard Library.

If you aren't sure what form the data is coming in, have a look at where it's being stored in the PLC. If it's in several Bytes in a DB for example, then it's probably a String.

If you can identify where the data is being stored and display the data in a VAT (preferably Byte for Byte) and post a screen dump of this display, we'll probably be able to identify the data and help you from there.
  Reply With Quote
Old February 8th, 2009, 06:49 AM   #8
greg1410
Member
United Kingdom

greg1410 is offline
 
Join Date: Feb 2009
Location: London
Posts: 1
You can use converter from here: http://calc.50x.eu/. It can shows you how to convert hex to dec and others.
  Reply With Quote
Old February 10th, 2009, 08:00 AM   #9
clemens
Member
Venezuela

clemens is offline
 
Join Date: Nov 2008
Location: CARACAS
Posts: 58
Quote:
Originally Posted by jvdcande View Post
Steve,

ever thought of simply moving (copying) the hex variable to a variable defined as integer?

Regards,
Just to illustrate what Jean Pierre said.

Regards,
Attached Images
File Type: jpg del.JPG (56.8 KB, 236 views)
  Reply With Quote
Old February 10th, 2009, 08:37 AM   #10
L D[AR2,P#0.0]
Supporting Member
United Kingdom

L D[AR2,P#0.0] is offline
 
Join Date: Nov 2006
Location: UK
Posts: 4,933
NB: thread is only three years old..
  Reply With Quote
Old February 10th, 2009, 09:17 AM   #11
MartinW
Member
United Kingdom

MartinW is offline
 
Join Date: Apr 2008
Location: UK
Posts: 70
Quote:
Originally Posted by rdrast View Post
Windows Calculator.

You aren't looking to 'convert' a number, you are looking to change the representation of a value stored in a computer.
10 (base 10, decimal) is equal to 0A (base 16, hexadecimal) is equal to 12 (base 8, octal) is equal to 1010 (base 2, binary).

For that matter, it's also equal to 101 (base 3, trinary?) or 022 (base 4, quarnary?).
I know its an old thread, but it gives me the opportunity for these:-

Quote:
I bought a book the other day - "1001 Interesting facts about Binary" I took it back as there was only 9 things in it.
Quote:
There are 10 types of people in the world, those that understand binary, and those that don't.
  Reply With Quote
Old September 5th, 2009, 07:26 AM   #12
kevin@amazingmedia.c
Member
Australia

kevin@amazingmedia.c is offline
 
Join Date: Sep 2008
Location: nowhere
Posts: 1
Post A step7 source. conversion of hex to decimal.

FUNCTION "Function_Hex_to_Dec" : VOID
TITLE =
//Hex to decimal conversion
//-------------------------
//Designed by: Kevin Bloch
//BlochTechnologies Australia Pty Ltd
//www.blochtech.com
VERSION : 0.1

VAR_INPUT
In_Hex : INT ;
END_VAR
VAR_OUTPUT
Out_Dec : INT ;
END_VAR
VAR_TEMP
DI_Temp1 : DINT ;
R_Temp1 : REAL ;
R_Temp2 : REAL ;
DI_Temp2 : DINT ;
R_Temp3 : REAL ;
R_Remainder1 : REAL ;
R_Remainder2 : REAL ;
R_Remainder3 : REAL ;
R_Remainder4 : REAL ;
R_Remainder5 : REAL ;
T_Real10 : REAL ;
T_FinalValue : REAL ;
END_VAR
BEGIN
NETWORK
TITLE =
A( ;
L #In_Hex;
ITD ;
T #DI_Temp1;
SET ;
SAVE ;
CLR ;
A BR;
) ;
JNB _001;
L #DI_Temp1;
DTR ;
T #R_Temp1;
_001: NOP 0;
NETWORK
TITLE =
A( ;
A( ;
L #R_Temp1;
L 1.600000e+001;
/R ;
T #R_Temp2;
AN OV;
SAVE ;
CLR ;
A BR;
) ;
JNB _002;
L #R_Temp2;
TRUNC ;
T #DI_Temp2;
AN OV;
SAVE ;
CLR ;
_002: A BR;
) ;
JNB _003;
L #DI_Temp2;
DTR ;
T #R_Temp3;
_003: NOP 0;
NETWORK
TITLE =
A( ;
L #R_Temp2;
L #R_Temp3;
-R ;
T #R_Remainder1;
AN OV;
SAVE ;
CLR ;
A BR;
) ;
JNB _004;
L #R_Remainder1;
L 1.600000e+001;
*R ;
T #R_Remainder1;
_004: NOP 0;
NETWORK
TITLE =
NETWORK
TITLE =
A( ;
A( ;
L #R_Temp3;
L 1.600000e+001;
/R ;
T #R_Temp2;
AN OV;
SAVE ;
CLR ;
A BR;
) ;
JNB _005;
L #R_Temp2;
TRUNC ;
T #DI_Temp2;
AN OV;
SAVE ;
CLR ;
_005: A BR;
) ;
JNB _006;
L #DI_Temp2;
DTR ;
T #R_Temp3;
_006: NOP 0;
NETWORK
TITLE =
A( ;
L #R_Temp2;
L #R_Temp3;
-R ;
T #R_Remainder2;
AN OV;
SAVE ;
CLR ;
A BR;
) ;
JNB _007;
L #R_Remainder2;
L 1.600000e+001;
*R ;
T #R_Remainder2;
_007: NOP 0;
NETWORK
TITLE =
NETWORK
TITLE =
A( ;
A( ;
L #R_Temp3;
L 1.600000e+001;
/R ;
T #R_Temp2;
AN OV;
SAVE ;
CLR ;
A BR;
) ;
JNB _008;
L #R_Temp2;
TRUNC ;
T #DI_Temp2;
AN OV;
SAVE ;
CLR ;
_008: A BR;
) ;
JNB _009;
L #DI_Temp2;
DTR ;
T #R_Temp3;
_009: NOP 0;
NETWORK
TITLE =
A( ;
L #R_Temp2;
L #R_Temp3;
-R ;
T #R_Remainder3;
AN OV;
SAVE ;
CLR ;
A BR;
) ;
JNB _00a;
L #R_Remainder3;
L 1.600000e+001;
*R ;
T #R_Remainder3;
_00a: NOP 0;
NETWORK
TITLE =
NETWORK
TITLE =
A( ;
A( ;
L #R_Temp3;
L 1.600000e+001;
/R ;
T #R_Temp2;
AN OV;
SAVE ;
CLR ;
A BR;
) ;
JNB _00b;
L #R_Temp2;
TRUNC ;
T #DI_Temp2;
AN OV;
SAVE ;
CLR ;
_00b: A BR;
) ;
JNB _00c;
L #DI_Temp2;
DTR ;
T #R_Temp3;
_00c: NOP 0;
NETWORK
TITLE =
A( ;
L #R_Temp2;
L #R_Temp3;
-R ;
T #R_Remainder4;
AN OV;
SAVE ;
CLR ;
A BR;
) ;
JNB _00d;
L #R_Remainder4;
L 1.600000e+001;
*R ;
T #R_Remainder4;
_00d: NOP 0;
NETWORK
TITLE =
NETWORK
TITLE =
A( ;
A( ;
L #R_Temp3;
L 1.600000e+001;
/R ;
T #R_Temp2;
AN OV;
SAVE ;
CLR ;
A BR;
) ;
JNB _00e;
L #R_Temp2;
TRUNC ;
T #DI_Temp2;
AN OV;
SAVE ;
CLR ;
_00e: A BR;
) ;
JNB _00f;
L #DI_Temp2;
DTR ;
T #R_Temp3;
_00f: NOP 0;
NETWORK
TITLE =
A( ;
L #R_Temp2;
L #R_Temp3;
-R ;
T #R_Remainder5;
AN OV;
SAVE ;
CLR ;
A BR;
) ;
JNB _010;
L #R_Remainder5;
L 1.600000e+001;
*R ;
T #R_Remainder5;
_010: NOP 0;
NETWORK
TITLE =
NETWORK
TITLE =
L #R_Remainder1;
T #T_FinalValue;
NOP 0;
NETWORK
TITLE =
A( ;
L #R_Remainder2;
L 1.000000e+001;
*R ;
T #T_Real10;
AN OV;
SAVE ;
CLR ;
A BR;
) ;
JNB _011;
L #T_FinalValue;
L #T_Real10;
+R ;
T #T_FinalValue;
_011: NOP 0;
NETWORK
TITLE =
A( ;
L #R_Remainder3;
L 1.000000e+002;
*R ;
T #T_Real10;
AN OV;
SAVE ;
CLR ;
A BR;
) ;
JNB _012;
L #T_FinalValue;
L #T_Real10;
+R ;
T #T_FinalValue;
_012: NOP 0;
NETWORK
TITLE =
A( ;
L #R_Remainder4;
L 1.000000e+003;
*R ;
T #T_Real10;
AN OV;
SAVE ;
CLR ;
A BR;
) ;
JNB _013;
L #T_FinalValue;
L #T_Real10;
+R ;
T #T_FinalValue;
_013: NOP 0;
NETWORK
TITLE =
A( ;
L #R_Remainder5;
L 1.000000e+004;
*R ;
T #T_Real10;
AN OV;
SAVE ;
CLR ;
A BR;
) ;
JNB _014;
L #T_FinalValue;
L #T_Real10;
+R ;
T #T_FinalValue;
_014: NOP 0;
NETWORK
TITLE =
A( ;
L #T_FinalValue;
TRUNC ;
T #DI_Temp1;
AN OV;
SAVE ;
CLR ;
A BR;
) ;
JNB _015;
L #DI_Temp1;
T #Out_Dec;
_015: NOP 0;
END_FUNCTION


Please test this first as I only ran a quick simulation to make sure it works...
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Converting Floating Point to Decimal zibby07 LIVE PLC Questions And Answers 3 October 26th, 2004 11:42 AM
Converting a decimal number to HEX. NoName LIVE PLC Questions And Answers 3 December 19th, 2003 09:00 AM
Hex / Decimal conversions TimothyMoulder LIVE PLC Questions And Answers 0 June 4th, 2003 02:38 PM
Converting ASCII to Decimal ettikudiappan LIVE PLC Questions And Answers 9 May 5th, 2003 10:40 AM


All times are GMT -5. The time now is 06:43 AM.


.