ADCON0=0b00000001; //Left justified, Channel AN0 selected, ADON On
Delay_ms(100) ; //Allow 1ms for holding cap to charge
to inside of the loop, Oshon Soft is doing the A/D conversions without any problems. So that may be your issue. According to the Delay_ms(100), your delaying for 100ms instead of 1ms. Is that what you want?
ADCON0=0b00000001; //Left justified, Channel AN0 selected, ADON On
Delay_ms(100) ; //Allow 1ms for holding cap to charge
to inside of the loop, Oshon Soft is doing the A/D conversions without any problems. So that may be your issue. According to the Delay_ms(100), your delaying for 100ms instead of 1ms. Is that what you want?
my OSHON SOFT demo ver. it is work very sholo .so for OSHON SOFT testing i use 100ms instead of 1ms.
my problom in 3rd png file.
sorry my bad english...
Ok, I'll study your code tomorrow morning. At 4.26V or ch=4257 what should be happening? All relays off? Another thing you might want to do is make a function/subroutine that processes ch as with your two loops your code is getting a little long. I would try to rewrite the code so that you only have one while (1) loop. After I get your input tomorrow on what should be happening at 4.26V, I'll see if I can help more.
my mean when i\p volt suddenly up or down , mcu goes like hange .its o\p (rl1 to rl4) position show as lost i\p time .
for example... when i\o 2.125==== R1=ON ,R2=Off,R3=ON,R4=Off. if right now i\p immediate goes high\low relay position (R1=ON ,R2=Off,R3=ON,R4=Off ) no change as requited .
I think the sudden jump from 1.9V to 4.26V causes code is not to get executed, which is the reason for the hang. Your if((ch<=4000)&&(ch>=0675)) line only handles ch to 4000. Unfortunately I still don't know what should happen at 4.26V. I have if(ch > 2100) [high voltage protection] and if(ch <= 1300) [low voltage protection] commented out, should they be active at this point? Ok talk to you tomorrow.
I think the sudden jump from 1.9V to 4.26V causes code is not to get executed, which is the reason for the hang. Yourif((ch<=4000)&&(ch>=0675)) line only handles ch to 4000. Unfortunately I still don't know what should happen at 4.26V. I have if(ch > 2100) [high voltage protection] and if(ch <= 1300) [low voltage protection] commented out, should they be active at this point? Ok talk to you tomorrow.
Do you have the CCS C compiler? I have an evaluation version, which will run out in a couple of weeks. I'll probably buy the CCS C compiler at $149, but it's low on my priority list. I like MikroC because the demo version will allow you to try out code with no time limit up to 2K ROM size. I also like the bit variables in MikroC. I'll have to research how to do bit variables in the CCS C compiler. The CCS C compiler integrates with the MPLAB IDE, so you can debug directly from MPLAB which is a plus.
What version of the CCS C compiler are you using? I'm using 4.122d. The line compiles in my version. You might change int1 to int, and see if it works correctly. int1 is the bit version of MikroC's sbit. (At least in 4.122d!)