CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

ADC Pic18f452

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Abidi



Joined: 12 May 2014
Posts: 6

View user's profile Send private message Send e-mail

ADC Pic18f452
PostPosted: Mon May 12, 2014 3:04 am     Reply with quote

Hello everybody
I need a program (PIC C) to display on LCD a current value got from a card of measurement, using pic 18f452.
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Mon May 12, 2014 6:44 am     Reply with quote

Hi,

Here is a program for a different PIC, but it will give you the idea. This program will print the A/D results to your PC.

Code:

#include <16F877.H>
#device adc=10
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
//#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

//============================
void main()
{
int16 adc_value;
float volts;
 
setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_DIV_8);
set_adc_channel(0);
delay_us(20);

while(1)
  {
   adc_value = read_adc();
   volts = (float)(adc_value * 5)/1023.0;   
   printf("%3.2f", volts);
   delay_ms(500);
  }
}



This should be good Wink !

John
Abidi



Joined: 12 May 2014
Posts: 6

View user's profile Send private message Send e-mail

PostPosted: Mon May 12, 2014 2:08 pm     Reply with quote

I want to display the value appeared at Voltmetre on LCD after every modification of resistance value. the probleme is that value displayed is incorrect.
Thank you for your help
Ttelmah



Joined: 11 Mar 2010
Posts: 19587

View user's profile Send private message

PostPosted: Mon May 12, 2014 2:19 pm     Reply with quote

What sort of resistance?.
The PIC requires quite a low impedance drive. More than a very few KR, and you won't get reasonable voltages.
Remember also the accuracy of your readings is dependent on the accuracy of your reference (commonly the supply rail). Unless this is accurate and stable, the readings will be in error.
Are you remembering to use an int16?.
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Mon May 12, 2014 2:22 pm     Reply with quote

Abidi wrote:
I want to display the value appeared at Voltmetre on LCD after every modification of resistance value. the probleme is that value displayed is incorrect.
Thank you for your help

Please explain.

1) What you expect to see.
2) What you actually see.

Mike
Abidi



Joined: 12 May 2014
Posts: 6

View user's profile Send private message Send e-mail

PostPosted: Mon May 12, 2014 3:04 pm     Reply with quote

I can not find how I can join code and isis to understand my problem Sad
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Mon May 12, 2014 3:07 pm     Reply with quote

Abidi wrote:
I can not find how I can join code and isis to understand my problem Sad

Throw ISIS/Proteus away.

When you have a real hardware question, ask again.

Mike
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Mon May 12, 2014 3:30 pm     Reply with quote

Hi All,

Hehe, I told you all this was going to be good!



John
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group