|
|
View previous topic :: View next topic |
Author |
Message |
Aryamas
Joined: 13 Apr 2014 Posts: 2
|
how to show a float number on a 16x2 LCD in 4bit mode? |
Posted: Sun Apr 13, 2014 5:29 am |
|
|
hi
how can I show a floating number(ADC output) on a 16x2 LCD in 4-bit mode using a pic18f452?
I have used printf(lcd_putc,'' " ") command and its OK on the Proteus. But it's not working on a real board. Only lcd_putc (" ") command works in real board and it can only shows characters and I dont know what to do.
tnx for helping me! |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Sun Apr 13, 2014 7:04 am |
|
|
Hi,
That doesn't make a lot of sense. Post your program that shows the problem, and tell us your compiler version.
John |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9293 Location: Greensville,Ontario
|
|
Posted: Sun Apr 13, 2014 8:43 am |
|
|
also... post your schematic as well..
It is WELL KNOWN that just because it 'worked' in Proteus it probably won't work in the real world!
Jay |
|
|
Aryamas
Joined: 13 Apr 2014 Posts: 2
|
|
Posted: Sun Apr 13, 2014 11:12 pm |
|
|
CCS c version is 5.007.
Code, which is working on Proteus and is not working in the real world is like this:
adc = .01234*read_adc();
printf(lcd_putc, "n=%3.2f",adc);
Code, which is working in the real world:
lcd_putc("hello!");
And circuit connection is like this
http://www.extremeelectronics.co.in/pictutorials/images/pic_lcd_interface_schematic.gif
my problem is that I want to show a voltage which i have read by ADC and show it on lcd every 1 second. I cannot use any of the above mentioned functions for this. is there any other function or way for this or I am not doing it correctly?
Thanks. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19619
|
|
Posted: Mon Apr 14, 2014 12:43 am |
|
|
The first thing to check is that your chip is actually running at the speed you expect. The old 'flash an LED' test. Proteus will assume that the CPU does run at the clock rate you say. The real processor won't.
Then, though "hello" message works, you show no decoupling close to the chip. Real chips need good HF decoupling right by the chip pins.
Then, you don't show where the analog voltage is connecting to the chip, or the code to setup the ADC.
What you show, should work, with a lot of 'provisos':
1) ADC clock set correctly (Proteus will accept wrong values).
2) Chip is running, and staying running. It could fail for instance, if 'watchdog' was enabled, since the 'hello' would only take a few uSec, but the ADC reading and multiplication will take a lot more time.
3) Physical problems caused by the voltage coming in. Your scale factor would give a value up to about 12, for a full scale reading from the ADC. What is the source voltage, and how is it connected?. Real chips will go wrong, where simulations keep working....
4) The code as written, does not show the LCD being cleared, or the write position reset, so after just a couple of readings the data will disappear off the 'end' of the LCD.
5) You don't show the declaration of 'adc'. Code won't work if this is not a float.
6) How are you timing?. Using an interrupt?. If so, your compiler is old enough to have a problem. CCS were disabling the GIE bit when printf was called, and not re-enabling it properly.
There could be dozens more such problems. Unfortunately, Proteus/Isis, won't help you to actually get the chip working. |
|
|
|
|
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
|