S7 Convert Word to Signed Integer

YoungWint

Member
Join Date
Dec 2012
Location
East Midlands
Posts
77
I may be being a bit slow here but is there any way in Step 7 that you can convert a Word value to a signed integer value?

Am sure its possible just not sure how?

I am receiving an Hex Number that can be either signed or unsigned so want to configure a block that allows toggling between types!
 
Basically the values are monitored values from and external system. I just want to take the 16 bit values, decode and change to real numbers for feedback to the site wide system.
 
I am guessing that the value enters your system via Profibus or Profinet as IO. And in the symbol table the word address(es) that contains the value(s) are formatted as WORDs.
WORDs will display as HEX values when you monitor them online.
Simply change these symbols to INTs and you are done. Maybe you have to save the blocks that use the word addresses and download again.
This doesnt actually do anything except from telling the program that the bit pattern is to be interpreted as INT values.

In case you mean that the dataword(s) are actually formatted as BCD, then you can convert to INT by the STL instruction BTI.

NB. INTs and REALs are different things.
 
For signed integer use

Code:
L wVariable
ITD
DTR
T rVariable

For unsigned "integer" use

Code:
L wVariable
DTR
T rVariable
 
I haven't tried it but believe if you just move the word into an integer you will have access to addresses where you can use the data as a word or an integer.
 

Similar Topics

Hello, I am new to Codesys 3.5 and I am trying to figure out how to convert a word into 2 bytes to send to another plc via ethernet/ip. Could...
Replies
5
Views
5,085
Thank you so much for your help! I am trying to use an INT or DINT as a setpoint for my remote device using Modbus TCP/IP. My code is...
Replies
2
Views
2,383
Hi, Im having a practice with a Siemens MM420, using siemens S7 via profibus, im struggling with the status PIW speed ref. I want to convert this...
Replies
9
Views
3,410
Hello guys, I'm using SCL to create the control for my drive. I have a value in the OS (0-100%) what stands for the speed of the drive= setpoint...
Replies
12
Views
7,517
Heya, My current method is below but am certain there is a more efficient way. Any ideas? JD L '23' T #Test_ASCII_Word...
Replies
8
Views
3,894
Back
Top Bottom