PLC Code Question

MobileMe

Active Member
I purchased a new board to replace my broken one and became aware of the new firmware(bitware) feature. I wrote out the code and it just doesn't look right to me. I do free up three rams, but it seems like using the bitware on more than one sensor is a bad idea. I use openremote with the board so nothing is in real order. I tried to explain it the best I could. If anyone has any questions, let me know. Thanks

View attachment Webcontrol Code New.txt
 
Hi, could you please elaborate on "using the bitware on more than one sensor is a bad idea". The key thing is to have the bitwise operation not impact other functions.
 
Hi, could you please elaborate on "using the bitware on more than one sensor is a bad idea". The key thing is to have the bitwise operation not impact other functions.

Sorry, I meant to say bitwise. Take a look at my code and let me know if I used the bitwise the right way.
 
I think that works. You may have to debug the code in the real running environment..
To make the code easier to read, you may combine code in certain way, for example, currently your code reads:
RESET1:
ANDB RAM1 1
BNZ SETH1ZERO
RET
RESET2:
ANDB RAM1 2
BNZ SETH2ZERO
RET
RESET3:
ANDB RAM1 4
BNZ SETC1ZERO
RET
RESET4:
ANDB RAM1 8
BNZ SETG1ZERO
RET
RESET5:
ANDB RAM1 16
BNZ SETC2ZERO
RET
RESET6:
ANDB RAM1 32
BNZ SETC3ZERO
RET
SETH1ZERO:
XORB RAM1 1 RAM1
RET
SETH2ZERO:
XORB RAM1 2 RAM1
RET
SETC1ZERO:
XORB RAM1 4 RAM1
RET
SETG1ZERO:
XORB RAM1 8 RAM1
RET
SETC2ZERO:
XORB RAM1 16 RAM1
RET
SETC3ZERO:
XORB RAM1 32 RAM1
RET

You could combine the code like:
RESET1:
ANDB RAM1 1
BNZ SETH1ZERO
RET
SETH1ZERO:
XORB RAM1 1 RAM1
RET

RESET2:
ANDB RAM1 2
BNZ SETH2ZERO
RET
SETH2ZERO:
XORB RAM1 2 RAM1
RET

RESET3:
ANDB RAM1 4
BNZ SETC1ZERO
RET
SETC1ZERO:
XORB RAM1 4 RAM1
RET

....etc
 
Back
Top