Changing a value of integer

martin3885

Member
Join Date
Aug 2005
Location
Saarland
Posts
144
How can I change an integers lets say 1040 to 40, 2356 to 365, 5001 to 1 and so on(no by substracting 1000, 2000, 5000)? I think there is a combination of rotational functions slw and srw that make this. Or maybe it can be done in other way?
 
Here's my solution assuming the number has been loaded into the accumalator. Note that -20897 will produce 897. Is that what you want for negative numbers or don't you use them ?

ITD //convert to 32 bit signed
DTB //convert to BCD
AD DW#16#FFF //mask all but last 3 digits
BTI //convert back to int
 
I used cut/paste from the block editor into the post so I know it is ok in my editor. Have you tried cut/paste from the post into your editor ?
 
Yes, I did it exaxtly as you. cut and paste. do you work with english oder german version of Step7? but this instruction are identical in both.
 
martin3885 said:
Yes, I did it exaxtly as you. cut and paste. do you work with english oder german version of Step7? but this instruction are identical in both.
Depending on setting for language and mnemonics (Simatic or International), it could be that AD (And Double) has to be translated to UD (Und Doppelwort). Just a thought.

Kind regards,
 

Similar Topics

Hi All, I am currently at the beginning of a new project for writing a PLC program (using CCW) for an old sugar centrifugal. Most of our...
Replies
3
Views
1,988
Hello All I am new to the forum and also to the world of PLCs. I would like to have your expert advice, If I can change the floating point value...
Replies
15
Views
5,773
Hello What would be the best way to write a value into "Source B" of a GEQ SLC500 PLC instruction from Wonderware? I would like the operator to...
Replies
2
Views
1,784
I am new to this line of work so please excuse me if this is extremely simple. I have also Searched the forums and web for answeres and am getting...
Replies
1
Views
1,278
Hello, I am trying to make a sequence program by using MOV function to change the value of a register. So far I have always used SET and RSET for...
Replies
5
Views
2,197
Back
Top Bottom