interfacing 16x2 lcd doubts

Forum for problems or queries regarding Flowcode Comms Components. Eg LIN, I2C, SPI, RS232, CAN, IrDA etc

Moderators: Benj, Mods

Post Reply
geetansh
Posts: 29
Joined: Tue Jun 21, 2011 4:23 pm
Has thanked: 3 times
Been thanked: 3 times
Contact:

interfacing 16x2 lcd doubts

Post by geetansh »

hey friends i have some doubts- i m new to microcontrollers and i m making a simple temperature controller using lm35 pic16f877a a 16x2 display.
now the problem is that i m confused about interfacing lcd,u can see data 1,2,3,4 in flowcode->lcd->connections so the data 1 line should be connected to 14th pin of lcd or 11th pin? and pins 7,8,9,10 of lcd should be grounded?

(data1-pin 14,data2-pin 13,data3-pin 12,data4-pin 11) OR (data1-pin 11,data2-pin12,data3-pin13,data4-pin 14)

n the next problem is tht i m using 4MHz crystal but it is not really running at 4MHz,it is running slow so lcd will work or not with this slow crystal?
thank you.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: interfacing 16x2 lcd doubts

Post by Benj »

Hello,

The LCD should be connected up like this.

(data1-pin 11,data2-pin12,data3-pin13,data4-pin 14)

The LCD will work with a 4MHz crystal but you will need to ensure that Flowcode's clock is also set to 4000000 to match your crystal. You can change this via the View -> Project options window in v4 or via the Chip -> Clock speed menu in v3.

geetansh
Posts: 29
Joined: Tue Jun 21, 2011 4:23 pm
Has thanked: 3 times
Been thanked: 3 times
Contact:

Re: interfacing 16x2 lcd doubts

Post by geetansh »

yaa i can use it with 4MHz crystal but the problem is the crystal is not actually running at 4MHz,it is running slow.
i tried blinking a led and when i gave the delay 500ms the led took much more time than 500ms so my crystal is slow.

so in code if 4000000hz freq is specified and crystal is not actually giving 4000000hz then lcd will work or not?

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: interfacing 16x2 lcd doubts

Post by medelec35 »

Would you like to post your flowchart, we can then check your settings for you.


Martin.
Martin

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: interfacing 16x2 lcd doubts

Post by Benj »

Hello,

I agree with Medelec can you please attach your program, crystals by their very nature should not run slow.

geetansh
Posts: 29
Joined: Tue Jun 21, 2011 4:23 pm
Has thanked: 3 times
Been thanked: 3 times
Contact:

Re: interfacing 16x2 lcd doubts

Post by geetansh »

i have attached 2 programs.
in first one i m using lm35 at AN0 and Vdd as Vref when the temp>30 led gets on.
i used this program but it didnt work so i decided to go back n blink leds.
i gave the delay=250ms between on and off but it took too much time so i decided to reduce the time,i used 100ms that also took too much time to blink n then i used 10ms n using stopwatch i noticed that the leds took 10ms delay as 10seconds.

i thought there might be some problem in flowcode so i made a simple program in ccs compiler to blink leds n there for 10ms delay the leds took 2.3seconds.
i dont know whats happening,is there some problem with my crystal or capacitors or compiler?
please help i m new to microcontrollers n from last 10 days i m trapped in this timing problem n i m getting frustrated.
Attachments
crystal_led.fcf
blinking leds
(5 KiB) Downloaded 495 times
temp_new.fcf
temp. control flowchart.
(7.5 KiB) Downloaded 556 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: interfacing 16x2 lcd doubts

Post by Benj »

Hello,

I've had a look through both of your programs and both your clock settings and configuration settings are correct for your clock speed.

Therefore I think the problem must be related to hardware.

The crystal should be connected as close to the uC as possible and connected between pins OSC1 and OSC2, pins 13 and 14 on the 877A.

The OSC pins should also be connected to 18-22pF ceramic capacitors that go to ground. I have had problems with capacitors before where some types worked well but others did not seem to work at all. Generic 50V ceramic caps should be ok for the job. I have also had a batch of capacitors that simply did not work as there was some kind of problem during the manufacture.

If the capacitors are not the source of the problem then I have also had similar problems with very cheap crystals though only on the ARM hardware to date. This seemed to be due to a large shunt capacitance on that specific crystal. I think the device datasheet should detail what this value should be to allow the device to work correctly.

geetansh
Posts: 29
Joined: Tue Jun 21, 2011 4:23 pm
Has thanked: 3 times
Been thanked: 3 times
Contact:

Re: interfacing 16x2 lcd doubts

Post by geetansh »

i have some ideas to figure out whats wrong
first is i have a spare 16f628a chip n i should try blinking leds n interfacing lcd with that n if all works fine then the compilers are fine and the problem is with crystal and i have a demo board(pickit 2 debug express 44pin demo board) so i can blink its leds with simple flowcode program using its 10MHz oscillator as that oscillator will be of good quality so delay timing will be correct.
please advice me if i m wrong somewhere or if i can do something extra with this.
thank you.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: interfacing 16x2 lcd doubts

Post by Benj »

Hello,

Yes those tests sounds like a good starting point.

From your comments before though I am 99% sure it is a hardware issue regarding either the crystal, the crystal capacitors or the crystal PCB tracking.

geetansh
Posts: 29
Joined: Tue Jun 21, 2011 4:23 pm
Has thanked: 3 times
Been thanked: 3 times
Contact:

Re: interfacing 16x2 lcd doubts

Post by geetansh »

thanks a lot sir,i will try those tests n will come back to you with the results.

geetansh
Posts: 29
Joined: Tue Jun 21, 2011 4:23 pm
Has thanked: 3 times
Been thanked: 3 times
Contact:

Re: interfacing 16x2 lcd doubts

Post by geetansh »

there was some problem in the capacitors thats y the delay time was not working correctly now evrythng is working fine.

i want to know how capacitance of solder joints affects the total capacitance????
for example if i m using 4MHz crystal with 27pF capacitors then after soldering it on univelsal board(not printed circuit,circuit is made using wires) the total capacitance for the crystal oscillator will become more than 27pF or less than 27pF??

if after soldering total capacitance(27+ joint capacitance) increases then i should use 15pF capacitors???

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: interfacing 16x2 lcd doubts

Post by medelec35 »

Are you sure it's the solder joints?
If you use wires, strip board, matrix board etc. then tracks or wires (or even both if used) alter the capacitance.
Since wires next to each other or two adjacent tracks of strip-board is like two conducting plates separated by an insulator i.e a capacitor.
So stray capacitances have an overall effect of the circuit.
I have not seen the circuit you are using, but from experience it's a good idea to use decoupling capacitors (e.g 100nf and 100uF) on the 5V supply rail, as near to pins of chip as possible. Otherwise chip could keep resetting.

Martin
Martin

edindia
Posts: 2
Joined: Thu Jan 05, 2012 9:49 am
Contact:

Re: interfacing 16x2 lcd doubts

Post by edindia »

Hai... LCD interface in flowcode is very easy.
Make sure:
1. You have connected the data to the lower nibble(ie D4 to D7)
2. Gnd all other data pins
3. Gnd the R/W pin
4. Give 5v to the LED and the Vcc
5. Give 10K preset to adjust the contrast

Software side
1. Make sure your clock matches the board
2. In Configure-> Make sure the oscillator is HS

I have tried many times. It is working superb
Further details visit
www.edindia.co.in

geetansh
Posts: 29
Joined: Tue Jun 21, 2011 4:23 pm
Has thanked: 3 times
Been thanked: 3 times
Contact:

Re: interfacing 16x2 lcd doubts

Post by geetansh »

see pic projects using flowcode on my website
http://www.funwithmicros.in

Post Reply