![]() |
||
|
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc. |
||
| ||
New Here? Please read this important info!!!
|
|
#1 |
|
Member
![]() Join Date: Jan 2006
Location: solihull
Posts: 2
|
Could anybody send me a program illustrating usng s7 how to convert a hexiecimal vaue into a decimal value
Thanks Steve. |
|
|
|
#2 |
|
Member
|
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 |
|
|
|
#3 |
|
Member
![]() 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. |
|
|
|
#4 |
|
Lifetime Supporting Member
|
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?). |
|
|
|
#5 |
|
Member
|
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 !
|
|
|
|
#6 |
|
Member
![]() 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. |
|
|
|
#7 |
|
Member
|
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. |
|
|
|
#8 |
|
Member
![]() 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.
|
|
|
|
#9 | |
|
Member
![]() Join Date: Nov 2008
Location: CARACAS
Posts: 58
|
Quote:
Regards, |
|
|
|
|
#10 |
|
Supporting Member
![]() Join Date: Nov 2006
Location: UK
Posts: 4,542
|
NB: thread is only three years old..
|
|
|
|
#11 | |||
|
Member
![]() Join Date: Apr 2008
Location: UK
Posts: 60
|
Quote:
Quote:
Quote:
|
|||
|
|
|
#12 |
|
Member
![]() Join Date: Sep 2008
Location: nowhere
Posts: 1
|
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... |
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
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 |