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] ds33FJ16GS402 - Ploblems ADC

Status
Not open for further replies.

Ygon

Newbie level 3
Joined
Dec 22, 2014
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
91
Hello.

I am wondering about my code, and I'm varying the voltage on AN1 pin and above 1.5V, activate the RB15 output.
I noticed that this model does not have records that are used in bilbiotecas and C30 programming examples.
Please can someone help me with my code?
Note: I am new to this compiler and 33F Family.

Thank you.

Code:


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
#include<p33FJ16GS402.h> //Biblioteca para o Pic a ser trabalhado.
 
 
 
//Variáveis globais para o adc:
 
float volts; 
 
void initAdc1(void) 
{
  
 
  //Registros I/O
  TRISAbits.TRISA1=1;  //Registro, pino A1 no modo entrada.
  TRISBbits.TRISB15=0; //Registro, pino RB15 no modo saída. 
  ADPCFGbits.PCFG1=0;  //configurar RA1/AN1 pino 3 como porta analógica.
  
//Configurações ADC
 
  ADCONbits.SLOWCLK = 1;   /* Ativar o clock divisor lento. 1 = ADC é cronometrado pelo auxiliar PLL (ACLK) */
  ADCONbits.FORM=0;       // Formato de saída de dados: 0 inteiro.
  ADCONbits.EIE = 0;      /* Disable Early Interrupt */ 
  ADCONbits.ORDER = 0;    /* Ordem de conversão de bit. 0 =  é convertido os numerados em primeiro lugar, 
                             seguido por conversão de entrada com número ímpar*/
 
  ADCONbits.SEQSAMP = 0; /* Amostra sequencial de ativação de bit. 0 = Amostra partilhados e (S & H) circuito é amostrado no início da segunda conversão se
                            ORDEM = 0. Se ORDEM = 1, então o partilhada S & H é amostrado no início da primeira conversão. */
 
  ADCONbits.ADCS=5;      //Seleção do Clock conversor de bit. 5(101b)FADC/6
  
  ADCONbits.ADON=1;     // ADON Modo de operação dos bits. 1 = Módulo de conversor A / D está operando.
  ADSTAT = 0;           /* Status do registro A/D. 0 = bit é cancelado. */
 
  
   //volts = (volts *(3,3/1023));
   timer_100us(2);
   ADCBUF1 = volts; // obter a medição de tensão.
   
 
   
    if (volts>=465)         // 465/1023 = 0,45 (fração do fornecimento de energia 3.3volt do PIC)
    {                      // 0,45 * 3.3volts = 1.5volts (realmente lêem no pino ADC)
  
        LATBbits.LATB15 = 1;
    }
 
    else
 
        LATBbits.LATB15 = 0;
   
}

 
Last edited by a moderator:

what is the problem that you are facing here ?
were you not able to vary ADC accordingly ?
 

what is the problem that you are facing here ?
were you not able to vary ADC accordingly ?

I am not able to configure the program this microcontroller to use the strain rate and thereby connect a digital output.

Can you help me?

Thanks.
 

Code:
ADCBUF1 = volts;
Apart from other possible problems, you don't actually read the ADC.

- - - Updated - - -

Why don't you try the peripheral_33F ADC examples provided with C30 or XC16?
 

Li yes. It turns out that this microcontroller has two distinct forms of conversion. One by interruption and other manual.

I'm trying to do manual way, that is, directly.

The part of the manual is confusing to show registers nonexistent this pic model.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top