Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PORTB =0b00111111; vs port bit (RB1_bit=0;)

Status
Not open for further replies.
I also moved

C:
 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?
 

Attachments

  • test.c
    8.9 KB · Views: 140
Last edited:
I also moved

C:
 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...
 

Attachments

  • 1st.PNG
    1st.PNG
    47.8 KB · Views: 163
  • 2nd.PNG
    2nd.PNG
    124.2 KB · Views: 151
  • 3rd.PNG
    3rd.PNG
    124 KB · Views: 156
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.
 
Last edited:
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. 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.

oh ohooo may problem solve!
thank u my dear sir !!!!!!!
 
Re: thank u / test.c with blinking LEDs

See attachment.
 

Attachments

  • test.c
    10 KB · Views: 169
Here is a test_16F72.c file, the 676 was 100% ROM memory, the 72 is 51%. Hopefully it helps and gets you going in the right direction. Not tested.
 

Attachments

  • test_16F72.c
    10.8 KB · Views: 212
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.

TTYL
 
no sir , i have no the CCS C compiler.I have also an evaluation version.
 
Well, the results are in on the 676, 52% ROM usage in CCS C vs 100% in MikroC. Not tested.

EDIT: I forgot to insert delay_ms(ADC_DELAY); in ProcessMains(). So you'll need to do that. Still at 52% ROM memory usage.
 

Attachments

  • test_676_CCS.c
    7 KB · Views: 133
  • test_676_CCS.h
    369 bytes · Views: 172
Last edited:
Well, the results are in on the 676, 52% ROM usage in CCS C vs 100% in MikroC. Not tested.

EDIT: I forgot to insert delay_ms(ADC_DELAY); in ProcessMains(). So you'll need to do that. Still at 52% ROM memory usage.
r u compile with CCS C compiler !
when i compile with CCS C compiler ,found some error ...
>>> Warning 203 "main.c" Line 76(1,1): Condition always TRUE
*** Error 51 "main.c" Line 117(4,8): A numeric expression must appear here
*** Error 12 "main.c" Line 119(11,15): Undefined identifier done
*** Error 12 "main.c" Line 120(12,16): Undefined identifier done
3 Errors, 1 Warnings.
 
My version compiles just fine. What are the lines that have the error?
 
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!)
 
*** Error 51 "main.c" Line 117(4,8): A numeric expression must appear here

int1 done = adc_done();

try changing code to

C:
int1 done;
done = adc_done();
 
right now...
>>> Warning 203 "main.c" Line 76(1,1): Condition always TRUE
*** Error 51 "main.c" Line 117(4,8): A numeric expression must appear here
*** Error 12 "main.c" Line 120(12,16): Undefined identifier done
2 Errors, 1 Warnings.
 
Is

*** Error 51 "main.c" Line 117(4,8): A numeric expression must appear here

C:
int1 done;

?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top