Shifting parts of a word - RSLogix 500

gardarog

Member
Join Date
Jul 2015
Location
Egilsstadir
Posts
23
I'm having some trouble reading messages on a Profibus network.

The problem is that one message from the device I'm communicating with contains three different pieces of information in a single word.
The device in question is a UNISAB II control system for a screw compressor in a fish processing plant, and it's configured for 16 Input and 16 Output words.
The Profibus network's master is an SST Profibus Scanner and the PLC being used is an Allen-Bradley SLC5/05.

The first word from the UNISAB device contains information about the compressor's capacity, it's running state, and running mode.
The structure of the word is as follows:

zVIeGuU.png


Now I want to mask out the most significant 10 bits, i.e. the compressor capacity, and right shift them so that they sit in the place
of the least significant 10 bits in a new data file, as I need to display the measurement on an operator screen.

I've properly masked out the bits I'm interested in:

iYjf2KU.png


but I'm having trouble shifting them six places to the right so that the SCADA system doesn't print the compressor's capacity as total gibberish.
I've tried the BSR instruction but it seems to me that it's only good for shifting a single bit through a data file.

Does anyone here have any idea of how this partial word shift might be accomplished, or is there perhaps an even easier way to get the desired result?
 
The brute force method will be the easiest to follow:

XIC SourceBit_6 OTE CapacityBit_0
XIC SourceBit_7 OTE CapacityBit_1
XIC SourceBit_8 OTE CapacityBit_2
and so on and so forth...

But if you DIVide by 2^6 (64) wouldn't that give you the correct result?

Since the source has the uppermost bit set in your example (the sign bit), you may try first copying the source value to a long integer before dividing so that the sign bit does not interfere with the math.
 
Doug-P: This was just what I was looking for!

OkiePC: If I don't copy to a long int I guess I'd have to make a second mask for the upper bits.

Thank you both for your help!
 
FYI;

Playing around with Starter lite reveals that copying to a long the sign is extended into the new location. Thus, dividing by 64 after doing this will give an undesired result if bit 15 is set in the argument. And as OkiePC points out this applies to the 16-bit word also.
 
Does the SLC500 platform have unsigned integers? I would think that could make the 15th bit issue go away.
 
Since the source has the uppermost bit set in your example (the sign bit), you may try first copying the source value to a long integer before dividing so that the sign bit does not interfere with the math.
I didn't account for that but, I don't recollect the 5/05 having long integers. OP may be back to the brute force technique (which does have the advantage of being pretty fast).
 
I would doubt that the 5/05 has longs. RSLogix 5000 doesn't allow any math operations on longs (very annoying since their timestamps are longs).
 
None of the mainline A-B controllers have an unsigned data type.

The COP, CPW, and MVM instructions all act on a Word in a bitwise fashion, so it doesn't matter if the datatype is signed or unsigned. The Copy Word (CPW) instruction and the Long datatype are not supported by the SLC-5/05 like they are by the MicroLogix 1100/1400.


I think the best solution is a rung with a MVM and a DIV instruction. Be sure to explain what you're doing in the rung comment !
 
The brute force method is not very practical in this scenario, since there are actually four refrigeration controllers on the network, which would call for a pretty ugly ladder script.
The way I'm going about this is by masking and dividing.
There shall be no explanation of what I am doing, my successors will have to figure that out themselves.
Just kidding...
 

Similar Topics

Greetings, I am trying shift data in an array (such as Array[0] is shifted into Array[1], Array[1] is shifted into Array[2]......all...
Replies
10
Views
358
Hello Guys, I think I need to use SCL for the following task but am very weak using SCL in tia portal. I have results history data block. It is...
Replies
14
Views
3,022
Why encremental encoder have a phase shift of 90°between A,B phases ,if it's 60° 30° what happen what's the difference ,can we change the 90°in...
Replies
47
Views
10,783
Hello everyone, I am working on trying to record a history of user logins with a time stamp. It will record their user ID and the time that they...
Replies
15
Views
3,826
Hey guys, What do you suggest for doing a shift of dints within an array like this? Thanks, Kevin
Replies
12
Views
2,556
Back
Top Bottom