neeed help with ADC

Status
Not open for further replies.

sahu

Member
this code work fine As i want . this code read ADC form AN0 & display it 7 seg.here i indecte AN0 port display it 7 seg.
As I-P
but one confusion with me. how can display AN1 ,AN2
those Are need indicAtion O_P & Lod & reading ADC form AN1 & AN2 display it 7 seg.
PHP:
/*        16F7 Configuration    dual I|P
          O = Output, I = Input RIGHT NOW AS DEMO
                    _________
             MCLR   | 1  28 |  RB7 --> (O) ==  A
(I) ADC1 --> AN0   | 2  27 |  RB6 --> (O) ==  B
(I) ADC2 --> AN1   | 3  26 |  RB5 --> (O) ==  C
(I) ADC3 --> AN2   | 4  25 |  RB4 --> (O) ==  E =as D
(I) ADC4 --> AN3   | 5  24 |  RB3 --> (O) ==  D =as E
(I) SW   --> RA4   | 6  23 |  RB2 --> (O) ==  F
(I) ADC5 <-- AN4   | 7  22 |  RB1 --> (O) ==  G
              Vss   | 8  21 |  RB0 --> (O) ==  H
          --> OSC1  | 9  20 |  Vdd
          <-- OSC2  |10  19 |  Vss
RL == (O) <-- RC0   |11  18 |  RC7 --> (O) == display[3]
   == (O) <-- RC1   |12  17 |  RC6 --> (O) == display[2]
   == (O) <-- RC2   |13  16 |  RC5 --> (O) == display[1]
   == (O) <-- RC3   |14  15 |  RC4 --> (O) ==
                    ---------
WOW ITS OK ON MY PCB
*/

#include <16F72.h>

#device ADC=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES NOBROWNOUT               //No brownout reset
//#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES HS
 
Last edited:
set_adc_channel(0);
replace with
set_adc_channel(1);
or
set_adc_channel(2);
Is that what you want?
 
Because you asked for my help, I need further clarification.

what you are saying in pseudo code is

For x = 1 to 20
Read ADC1
Read ADC2
Read ADC3
Read ADC4
Next
 
Because you asked for my help, I need further clarification.

what you are saying in pseudo code is

For x = 1 to 20
Read ADC1
Read ADC2
Read ADC3
Read ADC4
Next
yes i can do this for only ADC0 to ADC4
but but confused how can display rest text ( "O_P" & "lod" )
now this code show only

1) Show text "I_P"
2) Show value for AN0

i want to display as,

1) Show text "I_P" for 1 second.
2) Show value for AN0 for 3 second.
3) Show text "O_P" for 1 second.
4) Show value for AN1 for 1 second.
5) Show text "lod" for 1 second.
6) Show value for AN2 for 1 second.
7) etc then loop back to (1).
 
What compiler are you using?
Can you put in delay code using the compiler's delay routine?



yes i can do this for only ADC0 to ADC4
but but confused how can display rest text ( "O_P" & "lod" )
now this code show only

1) Show text "I_P"
2) Show value for AN0


Can you write a display routine that has a parameter?
In the interrupt routine, depending on the number of ticks
call the proper display routine.

ie
Code:
if ticks == XXX
    Display(1);
else if ticks == YYY
    Display(2);
else
    Display(3);
 
What compiler are you using?
I'm using CCS C compiler .


pl give full example .in the short , cont understnd
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…