16F676 with LCD

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
I like to know if it is possible to use 16F676 internal 4MHz osc with a LCD.
I am asking this cause I tried the 16F88 internal 4MHz during the voltmeter code and the LCD and everything came to freakin halt. The display was like waaaay slow in changing the welcome screen to VA display mode.

I thought it was due to halving the osc frequency. I never tried this so I am asking for advice.

This project is to make a separate ADC read out display for the easypic as I would like to see the ADC value sometimes when the circuit is working and also during real testing times. And I have a salvaged 16 X 2 LCD from the junk which works

The circuit will have 4 A2D inputs and LCD will have the 4 ADC read outs in 10bit.
I know I can change the 16F88 code to suite the F676. But I need to use the osc pins as I/O to drive the LCD if I were to use 4 A2D. With 3 A2D I can use HS osc. But I want 4 A2D.

Is it possible to drive the LCD with internal osc.

The circuit won't do any thing else but read ADC and display.

This will be useful for testing purposes.
 

Attachments

Last edited:

fernan82

Joined Apr 19, 2014
26
I don't see why not. I guess it depends on the LCD timing specs., the type of bus used to drive it and most of all the efficiency of the code. If I undertand it right the most expensive part of your project is converting the ADC output to ASCII for the LCD. If that's done efficiently you should have no problem.
 

t06afre

Joined May 11, 2009
5,934
Both those chip as far as I can see, can provide an internal oscillator running on 4MHz. If it works "slow" with a an internal oscillator but works. I suspect your compiler assume you are working with 20MHz clock. So all delays etc. will be calculated with 20MHz as base. But then your clock is only 4MHz every delay will be stretched 5 times
 

fernan82

Joined Apr 19, 2014
26
Unless it's a 3rd party compiler microchip's compilers either don't have time based delay functions or it has them but should give you an error if you don't define the operating frequency manually so that's not likely.

Though if you're doing instruction based delays you need to take into account that every instruction executes over 4 clock cycles.
 

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
The VA meter works fine with 8MHz HS.
I thought I will check the internal RC at 4MHz so changed the project setting to 4MHz int osc.
The code works fine and I am using mikroC Pro.
At 4Mhz the timing is what you said slow at around 5 times I think.

I think I will see what happens.

By the way I took out the old LCD and I was wrong. It is a 20*2 LCD.
 

ErnieM

Joined Apr 24, 2011
8,377
Dumping A2D data to an LCD usually requires slowing things down. Even at 4MHz you should see a rush of unreadable constantly changing numbers (assuming your data changes).
 

t06afre

Joined May 11, 2009
5,934
So 4 MHz is enough to display 4 ch A2D data on a 2 row LCD ?
Yes you do not want to update your display more than say every 2 to 5 second. If you do it more often it will only look fuzzy
Edit: A LCD display is also a quite slow device. Writing to the display while it is bussy may cause it to fail I think
 
Last edited:

fernan82

Joined Apr 19, 2014
26
It is plenty. I would update it at least every second. How do you convert the data to display it. If you use fixed point math or some other inefficient way I can see how it'll get really slow.
 

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
Here is what I was talking about.

This one I tried to use the int 4MHz and it slowed down. With 8MHz HS it works well.
 

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
Sorry guys. This thread got to hold up cause I checked the LCD just now, the bottom row is kaput. One chip is getting overheated.

I will order some 20*4 LCD from aliexpress and after that I could start.
Since now I have done the LCD part the coding won't be much of a problem.

Since the LCD broke. And the new one is bigger, which I am going to buy (20 X 4) I can display all I want. Like 4 A2D 10 bit data and the ADC pin voltage together.

I just needed to know I could use the 4MHz (int osc) one. Don't want to use the more good PIC's for this. The 16F676 I think is well suited for this. with 14pin and and less peripherals.

Eg below ( what I had in mind)

X(A)=5.00V ADC=1023. => 19 character and 4 Rows.
Y(A)=5.00V ADC=1023.
X(B)=5.00V ADC=1023.
Y(B)=5.00V ADC=1023.

Total of 4 ADC.
If this does not work at 4MHz I will go for 16F88 with 8MHz HS
 
Last edited:

ErnieM

Joined Apr 24, 2011
8,377
Let me be perfectly clear, as several people have already stated this:

4 MHZ IS COMPLETELY FINE FOR RUNNING A SLOW AS DIRT LCD.

OK now? ;)
 

JohnInTX

Joined Jun 26, 2012
4,787
Let me be perfectly clear, as several people have already stated this:

4 MHZ IS COMPLETELY FINE FOR RUNNING A SLOW AS DIRT LCD.

OK now? ;)
Agreed! But as the OP has discovered, not if you bog things down with dumb delays, as he found out in his referenced thread. Even speeding up the clock won't help here since 50ms delay at 4MHz bogs things down just the same as 50ms at 40MHz. You just get from delay to delay faster.

One solution is to create a system of interrupt driven timers that can be assigned to functions, like send characters to an LCD slowly, in the main program and poll them in the main loop. When you want to delay, set a timer for some number of ticks and call the routine that sends characters. If the timer is not run out, it returns immediately. If not, its sends the next character, reloads the timer then returns. The rest of the CPU time can then be used for other things, even heavy math.


This post shows one way to do it. It implements a set of timers and uses them to flash two LEDs at different rates. Is uses very little of the CPU time since it never waits on a delay. No delay_ms() are used, ever. The rest of the CPU is available to do more things, just add them to the main loop.

There are many enhancements you can make to this simple implementation but it illustrates some first steps away from bogged-down I/O-bound programs and toward multitasking paradigms. I write everything using some variant of this approach and can count the times I've actually run out of CPU horsepower on a few fingers, even with the most basic PIC doing some real work.

Good luck.
 

THE_RB

Joined Feb 11, 2008
5,438
...
Is it possible to drive the LCD with internal osc.
...
That will be perfectly fine, I have done it on many projects using 16x1 and 16x2 text LCDs etc.

The reason your code is "bogging down" when you changed to from 8MHz to 4MHz internal osc is because you are using MikroC, and in MikroC you need to tell the compiler what speed your PIC is running at.

I suspect what you did was to leave "8MHz" still in the processor speed data entry box in the compiler window, after you changed the project settings to INTRC osc.

So the PIC started running at 4MHz but your compiler thinks it is still at 8MHz and is making delays for 8MHz. The result is all your delays; Delay_mS() etc will now take twice as long!
:D
 

t06afre

Joined May 11, 2009
5,934
Crap ! I am dumb.
RB found my mistake for sure.

Luv you guys for being so patient with me.
Hm I tried to tell you this in one of first postings in this thread but anyway glad you eventually sorted it out. I will not answer that questions, but it reminds me of a member that for some time was nicknamed the Raminator for some reasons. To bad I cant remember who that member was:rolleyes:
Edit: Oh by the way this little slip will entitle me to shameless leg pulling for some period. Let us be fair and say 12 weeks:p
 
Last edited:

Thread Starter

R!f@@

Joined Apr 2, 2009
9,918
Hm I tried to tell you this in one of first postings in this thread
Hmmm! quite so, you did.
Are you mad that I am slow. :D

Edit: Oh by the way this little slip will entitle me to shameless leg pulling for some period. Let us be fair and say 12 weeks:p
You luv that, I know, Been there. :rolleyes:

12 weeks will be gone like yesterday.

You know I completely forgot about you trying to look for mishaps from me.
It's good to know you did not forget.
Makes me think I am always on your mind. :)
 
Top