Log in

View Full Version : Lcd With 16f819



EliteGM
- 22nd September 2007, 19:18
EDIT: I solved the problem, the EBIT was on set to the wrong pin. Anyway, I will leave the post active if anyone wants to know how to interface a 16F819 with the LCDOUT command in PB. Setting on EPIC Programmer is XT.


I have tested my circuit on the 16F84A and the LCDOUT program works perfect.

I am now trying to get this working with 16F819 so I can use the ADC and I just cannot get anything to display on the LCD....any suggestions?
Also, I am not sure my config for the external osc is correct. I am using a 4Mhz crystal with two 18p caps and selecting XT in the EPIC oscillator Config setting....which worked fine for the 16F84A.





DEFINE OSC 4

DEFINE LCD_DREG PORTA ' uses Port A on Ports A 0,1,2,3
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTA
DEFINE LCD_RSBIT 4
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 3
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2


TRISA = %00000000 'make Port A outputs
TRISB = %00000000 'make Port B outptuts

ADCON1 = 7 ' turns off adc

Pause 1500 ' Wait for LCD to startup
BlinkyLED VAR PORTB.1 ' This LED will BLINK

Pause 1500 ' Wait for LCD to startup

loop:
High BlinkyLED
LCDOut $fe, 1 ' Clear LCD screen
Pause 500
LCDOut "Hello" ' Display Hello
Pause 1000 ' Wait 1 second

'LCDOut $fe, 1 ' Clear LCD screen
LCDOut $fe, $c0 ' Move to next line on LCD
LCDOut "How are you?"
Low BlinkyLED
Pause 1000 ' Wait 1 second

GoTo loop ' Do it forever

wilfrieds
- 23rd September 2007, 15:51
Hello GM

I like to use the 16F819 for the same reason.
It makes no sense to try and use a 4Mhz external osc as the 16F819 has it all build in

Have a look at my LCD Dash project
www.skidloaders.co.za/pic

I am answering your question as I am looking for help myself.
Nl. My ADC results displayed on the LCD are jumping around
Both the numerical values as well as the bargraph.
All this on the breadboard ( see LCDDASH2.JPG)

Looking forward to anyones assistance.
Wilfried

EliteGM
- 29th September 2007, 22:08
Hello GM

I like to use the 16F819 for the same reason.
It makes no sense to try and use a 4Mhz external osc as the 16F819 has it all build in

Have a look at my LCD Dash project
www.skidloaders.co.za/pic

I am answering your question as I am looking for help myself.
Nl. My ADC results displayed on the LCD are jumping around
Both the numerical values as well as the bargraph.
All this on the breadboard ( see LCDDASH2.JPG)

Looking forward to anyones assistance.
Wilfried

i made a loop that checks to see if the adc is greater than or less than x before changing the LCD display.

For example...if your ADC is 10 bit then you get 0 to 1024.

So if your ADC signal is lets say jumping around 345 +/- 3 to 4 then you could LCDOUT and then read the ADC signal into a new variable and compare it to the original...if it is within a few numbers, dont let it out of the loop (dont let it jump back to where your LCDOUT command is until the range is outside of your range interval). Also, use a Zener diode to stabalize the ADC voltage.

bbarney
- 30th September 2007, 14:18
some thing like this I think and your on the wrong forum

DC_Loops = 20

Main:

ADC_Channel = 1 ' ADC on first reference
GoSub ADC_Average ' Perform an averaging to enhance accuracy

Temp_Float = ADC_Result ' Store the result

ADC_Channel = 0 ' ADC on second reference
GoSub ADC_Average ' Perform an averaging to enhance accuracy

ADC_Result = ADC_Result * 5000 / 1023 ' Convert values into Volts (with a scale of 1000)
Temp_Float = Temp_Float * 5000 / 1023 ' to reduce decimal error
ADC_Result = ADC_Result - Temp_Float ' And calculate difference

ADC_Result = ADC_Result / 10 ' Scale back down remembering 10mV = 1 Deg C

If ADC_Result <> Last_Result1 Then ' Check if the data has changed
Print At 1,1, DEC1 ADC_Result, 0, "C " ' and only update display if it has
Last_Result1 = ADC_Result ' Store new data
EndIf

GoTo Main ' Loop for ever


ADC_Average: ' Perform an averaging on ADC conversions
' to reduce errors
ADC_Total = 0 ' Clear summing register
For Temp = 1 To ADC_Loops ' Loop for a pre-determined number of times
ADC_Result = ADIn ADC_Channel ' Grab a new ADC value
ADC_Total = ADC_Total + ADC_Result ' Sum it to the total register
DelayUS 1 ' Allow internal capacitors to discharge
Next Temp

ADC_Result = ADC_Total / ADC_Loops ' Determin the average of all the equations

Return

wilfrieds
- 3rd October 2007, 19:22
Hi guys

thanks for the tips.
The adc jumping was sorted out by putting the cap closer to the 7805 regulator.
A Tantalium cap also improved stability. so for good measure I ised both.

I also tried ceramic caps but they didn't make any difference.

The ADC range adjustments seem interesting, still working and experimenting with that one.
Math calc's don't always seem to be spot on.??? ( maybe it's back to school).

Regards
Wilfried

wilfrieds
- 3rd October 2007, 19:25
One more problem remaining.

How to display say 4.85V from a ADC result.
Problem being the dot off course.

Thanks
Wilfried

mister_e
- 3rd October 2007, 20:51
As your as your result = 485 or 4850, you just need to format it. Look for DIG and DEC modifier in the LCDOUT section.