RSLogix 5000 Structured Text

rajy2r

Member
Join Date
Nov 2006
Location
Canada
Posts
167
I don't use structured text too much, but wanted to loop some items, so i thought i should try it. Got a hang up.

What i am trying to do is to check FIFO_ALM_RSLT_WORD array individual bits to see which one is set first, and copy some text and time values into a UDT Fifo and exit after first item is found.
How do i address bit level for looping? FIFO_ALM_RSLT_WORD[0].SUBSCRIPT, so i can check all bits. Would appreciate the help.

Code:
BMS1_ALM_LOG_NEW.YEAR := PLC_Year;
BMS1_ALM_LOG_NEW.MONTH := PLC_Month;
BMS1_ALM_LOG_NEW.DAY := PLC_Day;
BMS1_ALM_LOG_NEW.HOUR := PLC_Hour;
BMS1_ALM_LOG_NEW.MIN := PLC_Min;
BMS1_ALM_LOG_NEW.SEC := PLC_Second;

SUBSCRIPT0:=0;
SUBSCRIPT1:=0;

FOR SUBSCRIPT0:=0 to 31 by 1 do

IF FIFO_ALM_RSLT_WORD[0].SUBSCRIPT0 then
COP(FIFO_ALM_STRING_ARRAY[SUBSCRIPT0], BMS1_ALM_LOG_NEW.ALM, 1);
RET( );
END_IF;
END_FOR;

FOR SUBSCRIPT1:=0 to 31 by 1 do

IF FIFO_ALM_RSLT_WORD[1].SUBSCRIPT1 then
COP(FIFO_ALM_STRING_ARRAY[SUBSCRIPT1], BMS1_ALM_LOG_NEW.ALM, 1);
RET( );
END_IF;
END_FOR;

RET( );
 
Last edited:
how about doing a bitwise AND to get to the bit level..
something like:
FOR n:=0 to 31 by 1 do
IF (FIFO_ALM_RSLT_WORD[0] AND 2**n)=1 then
COP(FIFO_ALM_STRING_ARRAY[n], BMS1_ALM_LOG_NEW.ALM, 1);
RET( );
END_IF;
END_FOR;
 
how about doing a bitwise AND to get to the bit level..
something like:
FOR n:=0 to 31 by 1 do
IF (FIFO_ALM_RSLT_WORD[0] AND 2**n)=1 then
COP(FIFO_ALM_STRING_ARRAY[n], BMS1_ALM_LOG_NEW.ALM, 1);
RET( );
END_IF;
END_FOR;

That's a good way to do.
I tried FIFO_ALM_RSLT_WORD[0].[SUBSCRIPT0], and there are no compile errors. Would have to test and see if it works. If not, i think the Bitwise & a great approach.
 

Similar Topics

Hello, I please need your help why I cannot get the return parameter from the RET instruction to go into the return parameter in the JSR return...
Replies
6
Views
2,820
Hello All, Please how can i edit a structured text program in rslogix 5000. Thanks
Replies
5
Views
5,305
Hi. could someone give me an example about TONR instruction in structured text? I need to build a sort of "clock" wich set a bit at each...
Replies
3
Views
8,710
Hi, I Am trying to modify a Vendors program here on site and have just purchased Rockwells SFC Editor licence to add to my RSLOGIX 5000 ver13.02...
Replies
1
Views
6,862
Hi folks, in the alarm manager of Rslogix 5000, the tag-based alarm has been created. But when I tried to change the condition, it was found the...
Replies
2
Views
156
Back
Top Bottom