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 support@ccsinfo.com

lcd voltmeter

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







lcd voltmeter
PostPosted: Wed Dec 23, 2009 10:41 pm     Reply with quote

Hi all,
I'm new in this forum. I want to build the lcd voltmeter capable to display the 0-5v by using the LCD. I have already run the program as below and simulate using Proteus, but it not run well because my lcd only show 1.24 to 0 as I vary the potentiometer 2.5k. Plz help me.

Compiler 4.084
20MHz
LCD CONFIGURATION: refer LCD.C program
Code:

#include <LCD.C>

void main()
{
int16 adc_value;
float volts;
 
lcd_init();

setup_adc (ADC_CLOCK_DIV_32);
setup_adc_ports(AN0);
set_adc_channel(0);
delay_us(10);

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



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Dec 23, 2009 10:58 pm     Reply with quote

Quote:

I want to build the lcd voltmeter capable to display the 0-5v.
But my lcd only show 1.24 to 0.


That's because you left out part of the program that you got from here:
http://www.ccsinfo.com/forum/viewtopic.php?t=32168&start=1

You left out all these lines:
Code:

#include <16F877.H>
#device adc=10
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)

Which line do you think is the cause of your problem ? Your ADC
result is only 1/4 of the expected range. If the ADC can be in 8 or 10
bit mode, what mode do you think you are running in ? Which line
as shown above is the important one to fix the problem ?

Basically, don't leave out lines of a program. Everything is important.
thinkpositivex
Guest







lcd voltmeter
PostPosted: Thu Dec 24, 2009 1:28 am     Reply with quote

[quote]: PCM programmer

thanks PCM programmer ...but for your information but i have alreadY compile the coding...but error happen

Program Files\PICC\devices\16F877.H appear

This is a program i compile,its true??Its true if i select the lcd driver before i open project wizard?means i import the lcd driver lcdd.c before i continued to do program

Code:

#include "C:\Documents and Settings\matz\My Documents\CCS\LCD VOLT 16F877\main.h"

#include <16F877.H>
#device adc=10
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000

#include <LCD.C>

void main()
{
int16 adc_value;
float volts;
 
lcd_init();

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(lcd_putc, "\f%3.2f", volts);
   delay_ms(500);
  }
}



[/quote]
Rohit de Sa



Joined: 09 Nov 2007
Posts: 282
Location: India

View user's profile Send private message Visit poster's website

PostPosted: Thu Dec 24, 2009 2:53 am     Reply with quote

I quote Ttelmah from a different thread:
Ttelmah wrote:
Layout should be:

First the processor include.
Then it's defines
Then fuses
Then clock
RS232 setup if being used.
Only now, other includes.
Follow this general program structure to avoid errors.

I think your problem lies in the program's first line:
Code:
#include "C:\Documents and Settings\matz\My Documents\CCS\LCD VOLT 16F877\main.h"
What does this line do? What is the code in "main.h" ? You already have all the necessary includes and defines.

Rohit
thinkpositivex
Guest







lcd voltmeter
PostPosted: Thu Dec 24, 2009 3:48 am     Reply with quote

thank you very much2 Rohit..it work..but i hava a lot of question:-

1) why my lcd only measure 0.00 - 4.99.why it not up to 5.00..is it because in my program hava a divide by 1023.0

2) why my lcd not display a word VOLT: 0-5V when i added at the second last of my program
printf(lcd_putc, "VOLT: \f%3.2f", volts);

3)i have done a lot of research about the lcd voltmeter,i find that this lcd capable to measure the voltage higher than 5V by using the ratio..i'm not understand the ratio method can you explain to me.

4) can i develop the lcd current meter by using PIC ?
Rohit de Sa



Joined: 09 Nov 2007
Posts: 282
Location: India

View user's profile Send private message Visit poster's website

PostPosted: Thu Dec 24, 2009 4:07 am     Reply with quote

Quote:
why my lcd only measure 0.00 - 4.99.why it not up to 5.00
Actually it should....but I'm really not too sure about this. I'll better let someone more competent answer this.

Quote:
why my lcd not display a word VOLT: 0-5V when i added at the second last of my program
printf(lcd_putc, "VOLT: \f%3.2f", volts);
Look at the code. There is a "[b]\f[\b]". This [i]clears[\i] the LCD and then displays the float variable, 'volts'. Remove the "\f", and you should be able to see everything.

Quote:
i'm not understand the ratio method can you explain to me
use a potential divider arrangement. This is also called a 'voltage divider'. http://en.wikipedia.org/wiki/Voltage_divider

Quote:
can i develop the lcd current meter by using PIC ?
There are several methods to measure DC current. You could use a 'sense resistor'. This is a very low value resistance put in series with the main circuit. Use an opamp to buffer the voltage drop across the sense resistor. This voltage can be correlated to current. For higher currents you can use a hall effect sensor.

Rohit
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