Twincat hexadecimal string conversion

allemel

Member
Join Date
Sep 2012
Location
samsun
Posts
3
Hi,

i want to convert a hexadecimal string like 'FFFFFD0E' to integer. i know it equals -754. but i can not convert it in twincat. i can do it in .net easily(convert.int32) but i can not find how to do with twincat. there is a function dword_to_hexstr but i can not find any hexstr_to_dword function or something does the same thing. Is there anyone knows how can it be done. Thanks.
 
answer:
DWORD_TO_DINT
it is a conversion
when pressing F2 it is in a long list of type conversions.
because you have a dword you will need a dint to get the full range
after this you can convert to real.
 
I use the following code to convert a string to a integer:

nStringLength := LEN (File.Data[10]);
nStringLengthMinus := nStringLength-1;
MachineParams.nClampTime := STRING_TO_DINT(LEFT (File.Data[10], nStringLengthMinus ));
 
i found the solution

sHex02 := CONCAT('16#','FFFFFD0E');
iDInt := STRING_TO_DINT(sHex02);

it works. thanks for your help
 

Similar Topics

I'm trying to control a device via MODBUS RTU and the ModbusRtuMasterV2_PcCOM in Twincat 3. I've configured a device with the right com port and...
Replies
6
Views
130
Hi! I am trying to run the 'SimpleSample' (https://infosys.beckhoff.com/content/1033/TF5100_TC3_NC_I/Resources/3438746891/.zip ) to understand the...
Replies
2
Views
100
I am developing a library in twincat and one of the function uses IID_ITcVnAccess_TcVnPoint2_DINT and the definition of this type is defined in...
Replies
0
Views
70
Sorry if this has been asked before, and apologies if this seems like a trivial issue, but I am new to Beckhoff and have been banging my head...
Replies
2
Views
148
Hi everyone, This is my first time posting, so please forgive any omissions or mistakes. I am attempting to control the velocity of a stepper...
Replies
18
Views
985
Back
Top Bottom