Re: Need help with PIC asm
I use a PIC16F628 with ADC0831.
Here is part of my code:
MOVFW Alarm1
ADDLW Hysteresis
SUBWF ADCresult,W
SKPNC
BSF A1_Out
MOVFW ADCresult
ADDLW Hysteresis
SUBWF Alarm1,W
SKPNC
BCF A1_Out
Hysteresis is a constant = 1
Alarm1 is a var
ADCResult is the last read ADC value.
The ADC input value will go from 0-255 or vv.
The output should be ON if ADCresult>Alarm1
It should be OFF if ADCresult<Alarm1
Problem starts if Alarm1 is 255 or ADCresult is 255.
How to handle this?
The full unit should work as following:
We have 4 outputs: OC, BB, A1, A2
We have 5 vars: vOC,vBB,vA1,vA2,vSC
If ADC < vOC then all is off: OC status
If ADC < vBB then BB&OC is ON, others off: BB status
If ADC > vOC and ADC<vSC then OC is ON, all other OFF: Normal status
If ADC > vA1 and ADC<vSC then OC & A1 is ON, others OFF: A1 status
If ADC > A2 and ADC<vSC then OC&A1&A2 is ON, BB is OFF: A2 status
If ADC > vSC then all is OFF: SC status, same as OC status
Hope this makes clear what I like to do with this system.
Thanks for your help.