Simatic S7: DINT to INT conversion

JumpyPLC

Member
Join Date
Jul 2006
Location
Helsinki
Posts
10
What is the easiest way to make this conversion: DINT to INT?
I did not find a solution for this from the Simatic help file.
 
Use a move instruction to copy the DINT to the INT. If the DINT is in the range -32768 to +32767, this should do. If the DINT is outside this range, the operation is useless.

Kind regards,
 
if you need to go the other way (int to dint), use the I_DI function as the MOVE only does a bitwise copy. The I_DI will extend the bit 15 of the int into the high order word of the dint.
 
Quick and dirty:

L DW#16#FFFF
L Dint
<D
JC err
T Int
err: NOP 0 // set error bit here if you need any

Something like that should do the trick. (I hope) But just remember, when you transfer to say MW10, you should be carefull as the data in MW8 will be erased. (transferred 32 bits and such.....)
 

Similar Topics

HI i would like to know how to get a variable that will store the amount of times a program has been executed. The issue is I have 3 DBs for 1 FB...
Replies
2
Views
84
Dear sir, I am using SIMATIC 300, CPU 315-2DP , (6ES7 315-2AF03-0AB0) VIPA 603-1CC21 A1.0 RAM 32KB, Firmware=V4.0.8 The problem Im using MPI...
Replies
2
Views
173
Hi, I received this SIMATIC S7-300 training kit for maintenance. When I power it up, the PLC doesn't go to RUN mode and the STOP mode led is...
Replies
7
Views
311
I'm trying to build my Classic Step 7 programming skills this weekend. I get stuck on little things that are not covered in YouTube tutorials. I'm...
Replies
7
Views
322
I am utilizing both HMI and SCADA for my project. Both HMI and SCADA have identical tags. When I modify the tag value on HMI, it is reflected in...
Replies
2
Views
158
Back
Top Bottom