Peter Nachtwey
Member
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.
REMOVE ERROR FROM STACK. THIS CAN BE CALLED FROM ANYWHERE MULITPLE TIMES PER SCAN.
CALCULATE BITS/ERROR THAT WILL FLASH
AND THE BITS THAT ARE ON STEADY. PLACE THIS CODE AT THE END OF THE SCAN.
The Mitsubishi has a very powerful instruction set.
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.