Page 1 of 1

Sampling of AN0 and displaying on LCD

Posted: Sat Mar 02, 2013 5:28 am
by CRAIG CHAMBERLAIN
Hello, I am trying to just sample a 16f877A AN0, and display it on a 2 x 16 LCD.
I have done that, but now I am trying to show the digits behind the decimal point.

I cannot seem to use float to string to accomplish this, Can someone show me a sample of this?
There is something basic I am missing. I cant even get the code written without errors.
Always wrong type of variable errors,

code as is attached
Thanks in advance

Re: Sampling of AN0 and displaying on LCD

Posted: Sat Mar 02, 2013 11:52 am
by medelec35
Hi Craig,
I have moved LCD from port A to port B since AN0 uses port A0 so both LCD and pot will be sharing same pin.
I have also modified your flowchart to work with the least amount of icons to display a voltage from 0.00 to 5.00 volts using the Float variable.

Hope it helps

Martin

Re: Sampling of AN0 and displaying on LCD

Posted: Sun Mar 03, 2013 4:50 am
by CRAIG CHAMBERLAIN
Martin,
Thank you,
That was a sticking point to a much larger program.
Is it not recommended, or just not possible to use the same port for
the A/D and display?
-Craig

Re: Sampling of AN0 and displaying on LCD

Posted: Sun Mar 03, 2013 7:35 am
by Enamul
Hi,
As adc uses analog whereas Lcd uses digital it's not possible for normal uses to switch between that in an same bit of code. Also not advisable.

Re: Sampling of AN0 and displaying on LCD

Posted: Sun Mar 03, 2013 1:40 pm
by medelec35
Hi
as I has suggested and Enamul said its not recommended.

If you really want to do that, then I have tried it and it does work.

One good reason it's not recommend is if a data output that's connected to the pot input goes high, and the pot is set for a low value e.g. 1V then the PIC WILL get destroyed!
(or the other way round. Pot is set to high and data o/p is low)

To prevent this you must have a resistor (E.g 10K) connected in series with the wiper of the that pot and the port pin. (DO NOT TRY THIS UNTIL RESISTOR OF CORRECT VALUE IS IN PLACE, OTHERWISE A NEW MICROCONTROLLER WILL BE REQUIRED!).
LCD is connected directly to port pin.
If your measuring high impedance then LCD will affect this since I believe it has pull up resistors connected to the data lines?

You do this at your own risk since we have recommend not to do it.
Just because it works for me, if you do something wrong it may not work for you.