Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] Problem working with ADC on DSPIC30F4013 in mikroc

Status
Not open for further replies.

NIRMAL SAM

Newbie level 1
Newbie level 1
Joined
Oct 27, 2014
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
18
I am facing too much problem while working with DSPIC30F4013. When i am sensing a dc voltage of 15mV from a circuit ADC value gives zero. At 23 mV dc ADC value only 2 or 3. I am giving my program here. please give me a solution.




Code dot - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// LCD module connections
sbit LCD_RS at LATD0_bit;
sbit LCD_EN at LATD1_bit;
sbit LCD_D4 at LATB0_bit;
sbit LCD_D5 at LATB1_bit;
sbit LCD_D6 at LATB2_bit;
sbit LCD_D7 at LATB3_bit;
 
sbit LCD_RS_Direction at TRISD0_bit;
sbit LCD_EN_Direction at TRISD1_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
int i,cnt=0,indx,j,k,rot,cnt1=0,cnt3=0;
char ch;
unsigned char txtt[20];
long efg[100];
int ncl,npr;
int gr1=0,fgr=0;
long adc_rd;
double abc_rd1=0;
char txt1[] = "SENSOR TEST";
char txt2[] = "Taking Samples";
char txt3[] = " Sample Values";
void main() {
ADPCFG = 0x00ff;
  ADC1_Init();
 //ADC1_Init_Advanced(_ADC_INTERNAL_REF);
   Lcd_Init();
   LCD_Cmd(_LCD_CURSOR_OFF);
   LCD_Cmd(_LCD_CLEAR);
   LCD_out(1,3,txt1);
   delay_ms(3000);
  while(1)
   {
         
         for(cnt=0; cnt<100; cnt++)
               {
                 efg[cnt] =0 ;
               }
               LCD_out(1,2,txt2);
                delay_ms(3000);
         for(cnt=0; cnt<100; cnt++)
              {
                        adc_rd = ADC1_Get_Sample(4) ;
                                                     efg[cnt]= adc_rd;
                              
                                adc_rd= 0;
 
 
 
                                  }
                  for (cnt=0; cnt<100; cnt++)
                                   {              LCD_Cmd(_LCD_CLEAR);
                                                  LCD_out(1,2,txt3);
                                                  ch = efg[cnt]/1000;
                                                  LCD_Chr(2,6,ch+48);
                                                  LCD_Chr_CP('.');
                                                  ch = (efg[cnt]/100)%10;
                                                  LCD_Chr_CP(48+ch);
                                                  //LCD_Chr(1,5,ch+48);
                                                  ch = (efg[cnt]/10)%10;
                                                  LCD_Chr_CP(48+ch);
                                                  ch = efg[cnt]%10;
                                                  LCD_Chr_CP(48+ch);
                                                  LCD_Chr_CP('m');
                                                  LCD_Chr_CP('V');
                                                   delay_ms(2000);
                                                 
                                   }
     }
}

 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top