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.

pic16f877a adc mesure ac voltage

Status
Not open for further replies.

jouyorin

Junior Member level 1
Junior Member level 1
Joined
Mar 26, 2014
Messages
17
Helped
2
Reputation
4
Reaction score
2
Trophy points
3
Visit site
Activity points
118
hello
i'm using pic16f877a to mesure ac voltage this is my circuit: but it can read only values between 80v to 240 v..however im doing the same circuit with arduio and it works ! i guess the problem is in adc gonfiguration of pic16f877a, but i can't solve it cauz this pic don't hav ANSEL and ANSELH ..i already try to modifie ADCON1 but no result..please can someone help me! thnx in advance.
Sans titre.png
cofig I/O pic16f877a:
TRISA = 0xFF;
PORTA = 0x00;
TRISB = 0x00;
PORTB = 0x00;
TRISC = 0x80;
PORTC = 0x00;
ADCON1 = 0x80;
 

Hi,

You need to show your full adc and config program code, those few lines insufficient.
 

    V

    Points: 2
    Helpful Answer Positive Rating
this is my program i didn't understand what i have exactely to modifie:


Code C - [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 RC1_bit;
sbit LCD_EN at RC2_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_D3 at RB4_bit;
sbit LCD_D2 at RB5_bit;
sbit LCD_D1 at RB6_bit;
sbit LCD_D0 at RB7_bit;
 
sbit LCD_RS_Direction at TRISC1_bit;
sbit LCD_EN_Direction at TRISC2_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;
sbit LCD_D3_Direction at TRISB4_bit;
sbit LCD_D2_Direction at TRISB5_bit;
sbit LCD_D1_Direction at TRISB6_bit;
sbit LCD_D0_Direction at TRISB7_bit;
// End LCD module connections
char display[16]="";float U;
  unsigned int vs;
  unsigned char text0[4] ;
  char uart_rd;
 
int U0 = 0;
//Programme principal :
        Adc_Init() ;
 
void main() {
Uart1_Init (9600);
 {  char UART1_Read(U);
     {
       Delay_ms(100);
        TRISA = 0xFF;
      PORTA = 0x00;
      TRISB = 0x00;
      PORTB = 0x00;
      TRISC = 0x80;
      PORTC = 0x00;
      ADCON1 = 0x80;               // Configure all other AN pins as digital I/O               // Pins RC7 and RC6 are configured as outputs
 
                      // PORTB is configured as an output
       lcd_init();
       lcd_cmd(_lcd_clear);
       lcd_cmd(_LCD_CURSOR_OFF);
     }
 
 
{
         while(1)
         {
            U0 = Adc_Read(0);
            vs=U0*0.0048;    // Lu canal AN0 et enregistrez la valeur dans la variable temp0
            U =vs*80.0519;
            ByteToStr(U, text0);
            floattostr(U,display);
            lcd_out_cp(display);
            lcd_chr(1,14,223); //print at pos(row=1,col=13) "°" =223 =0xdf
            lcd_out_cp("Volt");
 
            UART1_Write_Text("La tension Mch1 est : ");
            UART1_Write_Text(text0); // Envoyé à l'uart
            UART1_Write_Text(" Volt");
 
            Uart1_Write('\r'); //
            delay_ms(500);
          }
          }
}
}

 
Last edited by a moderator:

i want to make a project to measure negative and positive dc voltage (-50v to 50v), you can give me a project suggest! thanks.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top