Bit shifting?

You don't need a fifo

Make a stack for the errors. I am hoping my FX2N is similar to your A series. I am assuming there is a stack at D100. This stack can be a big as you wish but you implied that you have only a few errors that can be represented by individual bits in a word.

The code below is for the three routines you need.

1. Push a new error on the stack. Put the new error in D98 and call this routine.

2. Clear the error from the stack. Put the error to be removed in D98 and call this subroutine.

3. Find the bits/errors that must blink and the bits/errors that blink.

PUSH A NEW ERROR ON THE STACK THAT IS PUT IN D99. INCREMENT THE Z REGISTER. THE Z REGISTER MUST BE SET TO 0 ON FIRST SCAN. THIS ROUTINE CAN BE CALLED FROM ANYWHERE AND MULTIPLE TIMES PER SCAN.

Code:
    MOV D99 Z            MOVE THE STACK COUNT INTO INDEX REGISTER Z
    BMOV D98 D100Z 1     PUT THE NEW ERROR ON THE TOP OF THE STACK
    ADD D99 1 D99        ADD ONE TO THE COUNT
    SRET

REMOVE ERROR FROM STACK. THIS CAN BE CALLED FROM ANYWHERE MULITPLE TIMES PER SCAN.

Code:
    SER D100 D98 D90 D99  SEARCH FOR THE ERROR TO CLEAR IN THE STACK
    MOV D91 Z             THE SER FUNCTION PUTS THE INDEX WHERE THE ERROR WAS FOUND IN THE INDEX REGISTER
    SUB D99 D91 D97       CALCULATE THE NUMBER OF REGISTER TO SHIFT DOWN
    BMOV D101Z D100Z D97  SHIFT THE REMAINING ERROR OVER THE REMOVED ERROR
    SUB D99 1 D99         REDUCE THE STACK COUNT BY ONE
    SRET

CALCULATE BITS/ERROR THAT WILL FLASH
AND THE BITS THAT ARE ON STEADY. PLACE THIS CODE AT THE END OF THE SCAN.

Code:
    WOR D98Z D99Z D95     OR THE TOP TWO ERROR AND STORE THEM IN THE FLASHING ERRORS REGISTER D95
    MOV 0 D96             CLEAR ON STEADY ERRORS REGISTER D96
    MOV 0 Z               START A THE BEGINNING OR BOTTOM OF THE STACK
    SUB D99 2 D97         OR THE OLDEST 'STACK LENGTH -2 WORD
    FOR D97
       WOR D100Z D96 D96  OR THE WORDS ON THE STACK
       ADD Z 1 Z          INCREMENT THE INDEX
    NEXT                  D96 HAS THE ON STEADY ERRORS.

The Mitsubishi has a very powerful instruction set.
 
Mannnnnn, the explanations make me dizzy.

my two cents


Basically all I need to know is there a function in a fx or a series plc that will record the inputs in order of time they were set regardless of the order? The rest I can easily handle.


Copy all alarm bits into a contiguous array. Peform Not Equal to zero on the alarm words to see if a new alarm appeared. If so, run the "grab bit number logic" (I will describe this later). The grab bit number logic returns with the bit number of the alarm that triggered (if there was more than one , it runs again) and moves it into a FIFO and then resets the bit. Run your lights off of the FIFO bit numbers.
 
I can leave the comments out

Basically all I need to know is there a function in a fx or a series plc that will record the inputs in order of time they were set regardless of the order? The rest I can easily handle.

In that case the first push new error on stack subroutine would do the trick. However, errors must be removed and the bits 'OR'ed together to determine which lights to turn on steady or blink.

Copy all alarm bits into a contiguous array.

To where in the array? OR did you mean FIFO?

Peform Not Equal to zero on the alarm words to see if a new alarm appeared.

This is like my D98 register.

If so, run the "grab bit number logic" (I will describe this later). The grab bit number logic returns with the bit number of the alarm that triggered (if there was more than one , it runs again) and moves it into a FIFO and then resets the bit.

This is similar to what I did but I used a stack instead of a FIFO which tlvaun said he didn't have. A FIFO is not really the right data structure anyway UNLESS the alarms are going to be removed or clear oldest first. Storing the bit number instead of the bit is a good idea if there are more alarms that what can be represented by 16 bits or 32 bits if double words are used.

Run your lights off of the FIFO bit numbers

Now you have to covert all the bit numbers to bits in a loop like my FOR NEXT loop in the third subroutine. My routine provides bits for flashing alarms in D95 from the top two alarms on the stack. In addition it provides the the on bit for the older alarms in D96.

I also take care of the extra complexity of clearing the alarms in the second subroutine. My routine does not require the alarms be cleared in any order as it will find the alarm bit anywhere on the stack. You don't mention clearing alarms at all.
 

Similar Topics

Hello all, What I want to do is take a word of data and move the bits over 1 bit. So to keep it simple: 0001 0011 1100 0110 and move into...
Replies
2
Views
1,512
Hi, I need to bit-shift a block of words in an Omron PLC by a certain amount. Is SFTR the only way to do this? I've tried NSFR/NSFL but from...
Replies
11
Views
3,682
I am looking for an instruction similar to the RS Logix BTD instruction. I need to be able to strip bits in the middle of a 32 bit double word...
Replies
1
Views
1,892
Getting closer to understanding BSR/BSL but I still cannot understand the "CONTROL" address function. I am using R6:10 and I can see the 0's amd...
Replies
2
Views
1,936
hi there guys i know this will be easy for you as a newbie here could someone explain the operation of the (AB) bit shift left and bit shift...
Replies
7
Views
7,210
Back
Top Bottom