Changing a value of integer

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
 
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, greetings from Culiacán Sinaloa México :D I'm new to the PLC world; I recently purchased an analog input module 1762-IF4 because the analog...
5
Replies
2,168
Views
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...
3
Replies
3,138
Views
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...
15
Replies
8,503
Views
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...
2
Replies
2,579
Views
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...
1
Replies
2,417
Views
Top