Byte swapping large arrays in RSLogix 5000

gardarog

Member
Join Date
Jul 2015
Location
Egilsstadir
Posts
23
I'm having trouble byte swapping data in RSLogix 5000.
I'm reading data from a couple of power analyzers and controllers for refrigeration compressors via a Profibus network.

The controllers for the refrigeration compressors are called UNISAB, manufactured by Sabroe (I think now Johnson Controls Inc.) and the power analyzers are of make Janitza UMG 508.

The network consists of:
1. A ProSoft MVI56-PDPMV1 DP-V1 master
2. Thirteen UNISAB controllers
3. Three Janitza power analyzers

The UNISAB controllers use high/low byte swapping for their profibus inputs, so I've configured the DP-V1 master to accumulate for that.
However the power analyzers don't use swapped inputs so I somehow need to swap their 62 input words.

I've tried using a COP operand to copy the relevant input data for the power analyzers to a SINT[124] array (62words x 2bytes/word=124bytes) and used that SINT[124] array as an input parameter for the SWPB operand. However it seems the SWPB of RSLogix 5000 doesn't handle arrays as well as the SWP operand of Logix 500, and returns an 'invalid data type' error.

Does any of the PLC guru's here perhaps have a quick workaround for this issue, as it would be a very tedious and tiresome task to do this manually for each and every one of the inputs...

TL;DR
How would one go about swapping a SINT[124] array in RSLogix 5000 without succumbing to suicidal tendencies?
 
If you read the RSLogix help, SWPB only accepts INT, DINT and REAL tags as source (not arrays). Even the RSLogix provides you an example of how to swap all elements in an array:


Code:
index := 0;
SIZE (array[0],0,array_length);
REPEAT
  SWPB(array[index],HIGHLOW,array_swapped[index]);
  index := index + 1;
UNTIL(index >= array_length) END_REPEAT;
I changed the order code to HIGHLOW. Each element will be swapped this way: ABCD -> BACD.

If you copy from your SINT array to a DINT array, then the higher two bytes will be zero.
 
RSL5K's SWPB instruction works fine with arrays but it doesn't like SINT data types.

One solution would be to create an AOI with a reference to a SINT input, copy the input SINT to a temporary DINT and then use the SWPB command (or use straight logic to map the bit order change), then copy the newly organized data to the SINT. I then would set up a loop to execute the AOI 124 times, increasing an index register as it executes.
 
Last edited:
Right, seems I was to hasty blaming this on the operand, i.e. that it didn't support arrays.
Sint's, being of length one byte, of course can't undergo a byte swap.
It now seems that I need to construct an INT/DINT array from my data, use the SWPB operand on that array,
and then deconstructing it again to SINT's, as I already have an AOI which knits four SINT's to a FLOAT.

Thank you both for your input! 🍻
 
A couple of years back I built an AOI for exactly this purpose. Well, not quite exactly, this was using strings and there was another factor in there which messed up the order even further. But I'll attach it below, you might be able to use it with a few tweaks here and there!
 
Thanks for that ASF!
I'll look into your AOI as it will definitely come in handy in future expansions of the Profibus network.
As it turns out though I've figured out a work-around.

I mentioned in my reply to jstolaruk and nhatsen I have an AOI for knitting 4 SINT's to a FLOAT.
Well that AOI requires 4 SINT's as input parameters, so I just mixed up the order I read the SINT's into the AOI.

I tend to over-complicate things...:sick:
 

Similar Topics

Hi All I am currently trying to control a weigher over Profibus from an Experion DCS. I know there is byte swapping as I have successfully...
Replies
4
Views
2,305
Hello Guys, Device: Siemens Step 7 5.5 IM151-8 PLC &Festo CPX valve bank w/ CPI Module I am using a festo valve bank with CPI inputs. The CPI...
Replies
0
Views
1,684
Our system utilises INPUT_BYTE to capture NMEA0183 ASCII stream which sends data to the NOM multiple times a second. The NOM module can either be...
Replies
0
Views
384
Hello everyone, friends. I need help with something. I want to read and change Bit and Byte numbers via HMI. I found a code snippet for this as...
Replies
18
Views
3,020
Hello everyone :) I just want to start with learning PLC programming, so I need advice. I have SIMATIC S7-1200, CPU with integrated memory...
Replies
5
Views
921
Back
Top Bottom