I'm using Codesys V3 ST language I'm writing a code to communicate motor controller unit which uses CANOpen protocol I want to use CAN raw messages to communicate
I put CAN bus messages bytes in an array -- myDataFF82 : ARRAY [0..7] OF BYTE; //(incoming message)
Then I put together first byte and second byte
raw := UserVarGlobal.myDataFF82[1] ;
raw1 := UserVarGlobal.myDataFF82[0] ;
raw2 := MEM.PackBytesToWord(byHighByte:=raw1 , byLowByte:=raw); //real message is '01F4' which is Hex
At this point I want to convert '01F4' into Decimal value ('01F4' Hex is '500' in Dec)
I don't see any function to do that in Codesys Can you help?
Thank you in advance
You do not convert HEX to DEC because there is no conversion, it is the same set of bits. It is only a matter of representation. You can see the number as a HEX or as a DEC
a := 16#01F4;
b := 500;
You assign equal value to a
and b
, but you write this value as HEX or DEC.