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.

problem in adc when simulation in proteous

Status
Not open for further replies.

sakender

Junior Member level 3
Joined
May 21, 2009
Messages
30
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
PAk
Activity points
1,507
hi
i am working on project on adc
my code is in mickroC
unsigned int i;
//////////////////// SENDING DATA TO MODEM//////////////////////
void SEND_MDM(unsigned char *cmd)
{
unsigned char cmd_len,loop,dat;
cmd_len=strlen(cmd);
for(loop=0;loop<cmd_len;)
{
dat=*(cmd+loop++);
usart_write(dat);
}
usart_write(0x0d);
}
//////////////END/////////////////////////////
void main()
{
unsigned char AT[]="AT";
unsigned char ATGF[]="AT+CMGF=1";
unsigned char SMS_MASTER[]="AT+CMGS=03159000279";
float press,p_lev=0,lt,adc_value,chk;
short take, buffer;
char inter, deci,i;
char lit[10],p_lit[10];
ADCON1 = 0x80; // Configure analog inputs and Vref
TRISA = 0xFF; // PORTA is input
TRISB = 0x3F; // Pins RB7, RB6 are outputs
TRISD = 0; // PORTD is output
usart_init(9600);
//Spi_Init();
SEND_MDM(AT);
delay_ms(200);
SEND_MDM(ATGF);
delay_ms(200);

while(1)
{


//take = Spi_Read(buffer);
SEND_MDM(take);
adc_value = Adc_Read(2); // Get results of AD conversion
press = adc_value*0.005;
lt=((press)/5)*8;
sprintf(lit, "%2.3f", lt);
SEND_MDM(lit);
chk=lt-p_lev ;
if(chk>=1)
{

SEND_MDM(SMS_MASTER);
delay_ms(200);
sprintf(p_lit, "%2.2f", p_lev);
SEND_MDM(p_lit);
SEND_MDM(0x1A);
SEND_MDM("Check1");
delay_ms(200);
delay_ms(500);
delay_ms(500);
adc_value = Adc_Read(2); // Get results of AD conversion
press = adc_value*0.005;
lt=((press)/5)*8;
sprintf(lit, "%2.3f", lt);
SEND_MDM("Check2");
SEND_MDM(SMS_MASTER);
delay_ms(200);
SEND_MDM(lit);
SEND_MDM(0x1A);
SEND_MDM("Check3");
}
else
{
delay_ms(200);
p_lev=lt;
}
//CONFIG WDT=OFF;
//CLRWDT();

}


}

when i simulation in proteous the there is two problem
1)ADC conversion clock period is below 1.6 u sec i used 8MHZ clock
2.) that controller is reset by Watchdog timer
as attached in figure
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top