Rslogix problem

eababio

Member
Join Date
Jan 2011
Location
Gaborone
Posts
52
Hi,
I have a 16 bit word and i need to move the first 8 bits to an 8 bit tag and the second 8 bit to another 8 bit tag. Can this be achieved in Rslogix?
 
Just divide by 256: the quotient will be the high 8 bits and the remainder will be the low 8 bits (stored in the math registers such as s:13 and s:14 for Logix 500).
 
Just divide by 256

be careful there! ... what about a negative number? ...

eababio ... for the most detailed answers, you need to tell us what platform and software you're using ... RSLogix5, RSLogix500, or RSLogix5000 ...

in some cases it can make a difference ...
 
Last edited:
Yes you should ensure the divide is unsigned if it does 16 bit math. And be sure to verify it works when the high bit is set

I am trying to recall what effect a negative number will have? Its two's complement math. It just works. Problems occur on the opposite operation of multiplication: if you exceed 15 bits, the high bit can get interpreted as a negative number. But in division of twos complement, the high bit (the sign bit) has no effect: the division is performed identically regardless of sign. Thats the beauty of twos complement: positive and negative numbers are handled identically. Correct me if I'm wrong, but thats what I remember from my engineering courses :)

And, Ron, you are absolutely right. There ARE a lot of assumptions here and it sure is helpful to know exactly which PLC and software when answering a question.
 
Last edited:
MVM(mask move) the first move to register 1, then SWP (swaps the upper 8 to the lower 8) and MVM the second move to the second register. The SWP command is one of those cool little used instructions.
 
I'll go out on a limb, as he talks about tags and mentions rslogix it could be a control or micrologix processor with that in mind this should do the trick


bitdist.jpg


Steve
 
from nwboson:

What effect would you expect a negative number to have? Its two's complement math. It just works.

well, maybe (probably?) I'm just misunderstanding what you're saying ... but when I run the program that I "think" you're recommending in an actual SLC system, the figure below shows the results I'm worried about ...

it seems that things work "as planned" as long as the sign bit (15) in the "original" 16-bit word stays at a status of ZERO ... but I've got a hunch that anytime that particular bit happens to have a status of ONE then the conversion our original poster is shooting for won't give the proper results in one of those words ...

sorry if I've misinterpreted what you're saying ... I just cranked my original post (above) in between customer calls ... that's usually a recipe for a mistakes ... I apologize if I've muddied the waters for nothing ... still – it does look "crazy" when I look at it from my end of the pipe ...

I'm basically just trying to keep our original poster from using something that won't do exactly what he expects it to ...

party on ...

divide256.JPG
 
Last edited:
How about doing your masks and using CPW or CPB for copy word or copy byte. That way you can actually get away with using what you might think of as "untyped memory." Otherwise you get the "not-always-what-you-wanted" type conversions. I use this for placing things like byte reversed Modbus words into integers or better yet, 4 byte floats that can be all mixed up in some implementations.
 
I'll go out on a limb, as he talks about tags and mentions rslogix it could be a control or micrologix processor with that in mind this should do the trick


View attachment 17073


Steve

Thanks guys for the answers. Am actually using compact logix and rslogix 5000. I used BTD just like Nehpets did, my only problem was that in the second rung when i change the source bit for the source word from 0 to 8 , the one in the first rung also changes Thats what made using BTD difficult cos i couldnt understand why that will happen. Will try it again seeing as it worked for him else i will just have to duplicate the word and use it with BTD
 
Thanks guys for the answers. Am actually using compact logix and rslogix 5000. I used BTD just like Nehpets did, my only problem was that in the second rung when i change the source bit for the source word from 0 to 8 , the one in the first rung also changes Thats what made using BTD difficult cos i couldnt understand why that will happen. Will try it again seeing as it worked for him else i will just have to duplicate the word and use it with BTD

That definately should not happen as you described.

Can you post the two rungs in question for us to see ?

Attached Pic is from a ControlLogix L62 : works fine.

BTD.jpg
 
Last edited:

Similar Topics

Replies
49
Views
10,753
Hi, I'm having some problems with an ons structure in studio logix 5000. I latch the process_all_off and sometimes I end up in this state...
Replies
8
Views
2,649
Hi I have two Laptops both have same Windows10. As one of our old machine still has PLC-5 for which we need RSLox-5, So I installed the...
Replies
4
Views
3,287
Hi I have two Laptops both have same Windows10. As one of our old machine still has PLC-5 for which we need RSLox-5, So I installed the...
Replies
0
Views
1,102
Hello everyone, this is my first time asking for help here, so please bear with any problem my english or lack of experience can cause. i have a...
Replies
3
Views
2,687
Back
Top Bottom