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.

ADC problem for PIC16F877A.. how to define ADC values having decimal point

Status
Not open for further replies.

Thunderhorse312

Member level 1
Joined
May 7, 2012
Messages
32
Helped
0
Reputation
0
Reaction score
1
Trophy points
1,286
Activity points
1,526
Hi! I'm trying to design a digital weighing scale that would open a certain port when a certain weight is present as input. However, the weight ranges are too close to each other and gives an equivalent ADC output of like 10.111 and 10.555.. how do i consider the numbers after the decimal point to be read by the analog to digital converter. Please help! thanks!
 
Last edited:

Give a little more details about the sensor like its output parameters...... any datasheet available?
 

Just refer the data sheet of the given sensor. then try to adjust the values as per the output.. then convert the 10 bit ADC value to floating point by the method i used in following code

Code:
int test_final=0 ,shift=0;

void delay(unsigned int msec ) // Time delay function
{
int i ,j ;
for(i=0;i<msec;i++)
  for(j=0; j<1275; j++);
}

void lcd_cmd(unsigned char item) // Function to send command to LCD
{
dataport = item;
rs= 0;
rw=0;
e=1;
delay(1);
e=0;
return;
}

void lcd_data(unsigned char item)  // Function to send data to LCD
{
dataport = item;
rs= 1;
rw=0;
e=1;
delay(1);
e=0;
return;
}

void lcd_data_string(unsigned char *str) // Function to send string to LCD
{
int i=0;
while(str[i]!='\0')
{
  lcd_data(str[i]);
  i++;
  delay(1);
}
return;
}

void convert()
{
float s;
lcd_cmd(0x81);
delay(2);
lcd_data_string("TEMP:");
s=test_final/50;
lcd_cmd(0x8a);
lcd_data(s+48);
if(shift>16)
{
lcd_cmd(0xc0+(shift+1));
lcd_data_string("       ");
shift=0; 
}
lcd_cmd(0xc0+(shift-1));
lcd_data(' ');
lcd_cmd(0xc0+shift);
lcd_data_string("round up value");
delay(30);
}

void main()
{
adc_input=0xff;
lcd_cmd(0x38);  //2 Line, 5X7 Matrix
lcd_cmd(0x0c);  //Display On, Cursor Blink
delay(2);
lcd_cmd(0x01);  // Clear Screen
delay(2);
lcd_cmd(0x81);  // Setting cursor to first position of first line
delay(2);
while(1)
{
  shift++;
  delay(1);
  rd=1;
  wr=0;
  delay(1);
  wr=1;
  while(intr==1);
  rd=0;
  test_final=adc_input;
  delay(1);
  intr=1;
  convert();
}
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top