lcd how to do

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

foppa
Posts: 45
Joined: Sat Dec 20, 2008 1:55 pm
Has thanked: 3 times
Been thanked: 1 time
Contact:

lcd how to do

Post by foppa »

Hello again to you all.
New problems are equal to new issues.
I have made a program which measures
temperature and displays it on a LCD display.

Everything works well in simulation.
When I connect all things.
lcd display shows nothing.
It shows some filled squares.
Run with 16F690, using the internal clock and clockan is set to 4,000,000.

I have read that you should have the same frequency on the chip as the LCD display.

The display is a wintek 2 * 16

Foppa


attach photos
Attachments
3.JPG
(69.45 KiB) Downloaded 9155 times
2.JPG
(71.64 KiB) Downloaded 9155 times
1.JPG
(67.83 KiB) Downloaded 9150 times

foppa
Posts: 45
Joined: Sat Dec 20, 2008 1:55 pm
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: lcd how to do

Post by foppa »

help me

foppa :P
Attachments
7.JPG
(66.73 KiB) Downloaded 9145 times
6.JPG
(59.79 KiB) Downloaded 9138 times
4.JPG
(64.63 KiB) Downloaded 9147 times

User avatar
Steve
Matrix Staff
Posts: 3426
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: lcd how to do

Post by Steve »

What are your configuration settings? And what value crystal (etc) is attached to the chip?

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: lcd how to do

Post by Benj »

Hello

It could be due to the fact you are using PortA. One of the PortA pins is normally an open collector type so it is unable to source any current. For your particular chip RA3 is an input only so connecting via PortA will not work. Maybe try using PortB instead.

Taken from the device datasheet
The exception is RA3, which is input only and its TRIS bit will always read as ‘1’.
Also are you sure your internal clock is running at 4MHz. You can edit the speed by using a C code block to write a value to the OSCCON register. There may also be an OSCTUNE register depending on your chip. You can stick this C code icon right at the start of your program.

Code: Select all

osccon = 0x61;     //Sets the internal clock to 4MHz
Other then this the main problem I can spot is that your LCD Start macro is inside the main loop. Move this to the start of your program eg out of the loop and use an LCD clear inside the loop instead to reset the display.

foppa
Posts: 45
Joined: Sat Dec 20, 2008 1:55 pm
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: lcd how to do

Post by foppa »

I use pickit 2.
There are built-in clock in 16F690.
But if you look in PPPv3 so there is no

16F690 in cofig list.
Is it possible to set the config for
16F690 in other places in the program.

I changed to the port c now and there was no difference.
which is the easiest, external clock on the chip or to change clock of chip

can you give me an example / explain how to download OSCCON to chip

"Other then this the main problem I can spot is that your LCD Start macro is inside the main loop. Move this to the start of your program eg out of the loop and use an LCD clear inside the loop instead to reset the display"

No difference


:lol: foppa
Attachments
config.jpg
(38.37 KiB) Downloaded 9114 times
clock.jpg
(42.64 KiB) Downloaded 9107 times

User avatar
Steve
Matrix Staff
Posts: 3426
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: lcd how to do

Post by Steve »

The configuration word for the internal oscillator needs to be 0x3FF4. You also need that C instruction to set the clock speed of the chip itself appropriately (just put that C code into a C icon at the beginning of your program).

If you are still having difficulty, you should create a very simple LED-flasher program to make sure the hardware configuration of the chip matches the clock settings you are using.

foppa
Posts: 45
Joined: Sat Dec 20, 2008 1:55 pm
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: lcd how to do

Post by foppa »

Ok steve I will try it tonight.
I will return to how it goes
Thanks
Foppa :P

foppa
Posts: 45
Joined: Sat Dec 20, 2008 1:55 pm
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: lcd how to do

Post by foppa »

Ok I have done as you said.
No difference.
Tried to make LED flash, but it does not work
the LED lights up all the time, no wink.
I tried to make a program to test whether an input can light a LED.
And it went well.

Could it be something with the config settings.
Must we tell the chip that uses the internal clock.

Foppa
Attachments
test.fcf - Main.JPG
test.fcf - Main.JPG (11.28 KiB) Viewed 14830 times
temp.fcf - Main.JPG
temp.fcf - Main.JPG (20.38 KiB) Viewed 14834 times
c.jpg
(45.43 KiB) Downloaded 9048 times

User avatar
Steve
Matrix Staff
Posts: 3426
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: lcd how to do

Post by Steve »

I've just recreated your simple LED flasher program and it works find both on our dev board and Microchip's low-pin count demo board.

My program and HEX file are attached.

To reiterate, you need to do the following three things:

1) set the configuration word within the "configure..." screen
2) set the osccon register appropriately
3) set the clock speed within Flowcode

I can only think that you have not done (1) correctly, or that your programmer is not doing its job right.

If you are using our PPP software, then setting the configuration word is simple. If not, you need to enter "0x2007,0x3ff4" into the "configure..." window.

If this is not the problem, then please describe your hardware / programmer setup and we'll try to help further.
Attachments
690.fcf
(3 KiB) Downloaded 419 times
690.hex
(623 Bytes) Downloaded 314 times

foppa
Posts: 45
Joined: Sat Dec 20, 2008 1:55 pm
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: lcd how to do

Post by foppa »

Ok I'll try this again tonight.

I use pickit 2.
And when I download hex file, I use flow code "complie to chip"

Must say that you are completely amazing that turn up and help me.

I get the feeling that this may be possible to resolve.

Has placed on the 6-month with different programs and none have been something caught my attention and was too difficult to learn / + 3 kids at home that disrupt
But Flow Code, I can understand and learn

Foppa :P

foppa
Posts: 45
Joined: Sat Dec 20, 2008 1:55 pm
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: lcd how to do

Post by foppa »

Hello.

Progamet "LED flash" works.
the question of why it works now.
I have not compared my program LED Flasher with what I got from you
Question would you want / time to throw together
a program that I try to get together.
Temperature on the LCD display.
And see how it goes.

Or have you any idea of what can be wrong.
I sat last night and check out the connection and I can not see any errors.

Foppa

User avatar
Steve
Matrix Staff
Posts: 3426
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: lcd how to do

Post by Steve »

Post your LED flasher program here and I'll have a look.

foppa
Posts: 45
Joined: Sat Dec 20, 2008 1:55 pm
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: lcd how to do

Post by foppa »

Ok I vill do that to night.
One more questions:does it matter what type lcd display you use.
foppa :shock:

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: lcd how to do

Post by Benj »

Hello

The LCD type certainly does matter :mrgreen: For example a computer LCD screen is not going to work.

For compatibility with the LCD component in Flowcode you will need a standard alphanumeric display using a controller chip that is compatible with the Hitachi HD44780 controller.

If your LCD has the following pins then it is most likely compatible.

1. GND
2. 5V
3. LCD Contrast
4. RS
5. R/W
6. E
7-14. DB0 - DB7
15-16. Optional Backlight

foppa
Posts: 45
Joined: Sat Dec 20, 2008 1:55 pm
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: lcd how to do

Post by foppa »

1. GND
2. 5V
3. LCD Contrast
4. RS
5. R/W
6. E
7-14. DB0 - DB7
15-16. Optional Backlight

Yes this what I have.
Shall lcd connected like this
DB0 - 11
DB1 - 12
DB2 - 13
DB3 - 14

have tested all the different variants

:P

foppa
Posts: 45
Joined: Sat Dec 20, 2008 1:55 pm
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: lcd how to do

Post by foppa »

Hello again.
Here you have the file and I had to make a new file. Because of that I am sitting at work and have only demo program on the job and then became the chip 16f628a.
Perhaps it is better to switch to a chip which is included in the PPV list and could set the config on the chip.
I have also crystal home on 4mhz, it is better to have such a place of using the internal located on the chip.

Foppa
Attachments
testtemp.fcf
(4 KiB) Downloaded 266 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: lcd how to do

Post by Benj »

Hello Foppa

I have attached an updated version of your program.

Your code was telling the LCD to print out the word temp and was then immediatly clearing the display again. I have now included a small delay after the LCD print to allow the text to be seen.

To get this program working on the hardware then you must go to the Chip -> Configure menu and select XTAL to assign the oscillator, Then as long as the external crystal has a speed of 4MHz then your program should run without problems.
Attachments
testtemp.fcf
(4 KiB) Downloaded 285 times

foppa
Posts: 45
Joined: Sat Dec 20, 2008 1:55 pm
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: lcd how to do

Post by foppa »

Hello everyone.
John here, has been working evening for a week now.
Working days again.
I download the new file.
But I can not it work, I have tried to create LED Flasher for 16F628A.
Can not make it work.
I have bought a 16F628A just to be sure it is ok.
I checked my connections and they are ok.
I will not give up to get the LCD display to work.

But I suspect that few 16F628A may be something with the configuration.
And at I program it with icsp pickit2.
Pickit2 says program to chip ok.
I have crystal at 4MHz to 16f628A.
Can anybody tell how configuration should be for 16F628A with crystal.
I know that it is set to XTAL in PPV.
Is there anything I have missed.

I am stupid or what :cry:

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: lcd how to do

Post by Benj »

Hello

Information on obtaining the correct configuration settings when using PICkit or the Microchip bootloader are detailed here in the attached guide.
Attachments
1. Flowcode with Microchip Dev Tools.ppt
(939.98 KiB) Downloaded 332 times

foppa
Posts: 45
Joined: Sat Dec 20, 2008 1:55 pm
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: lcd how to do

Post by foppa »

Hello Benj

I read this with pickit2.
I found nothing that I have done wrong.
Maybe we should take on everything from the beginning.
LED Flasher operates chip 16F690 but not on 16F628A.
Of course, I have 2 equal program a 16F690
and another for 16F628A.
Can I make a mistake with the link with the crystal on 16F628A RA6, RA7.
How would you have done to achieve this I am trying to do.
And when I download to chip all goes well.
Program success.
Code 0.
Grateful for any assistance

Foppa :|
Attachments
dwg.JPG
dwg.JPG (30.05 KiB) Viewed 14601 times

User avatar
Steve
Matrix Staff
Posts: 3426
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: lcd how to do

Post by Steve »

Try a config of 0x3F09.

foppa
Posts: 45
Joined: Sat Dec 20, 2008 1:55 pm
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: lcd how to do

Post by foppa »

This does not work either.
I give up.
What I can imagine that is proplemet is icsp
for 16F628A.
or will try to have text on the LCD with 16F690.

foppa
Attachments
pickit2.JPG
pickit2.JPG (35.63 KiB) Viewed 14586 times

User avatar
Steve
Matrix Staff
Posts: 3426
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: lcd how to do

Post by Steve »

If PICkit says the program has gone into the chip ok, then it has. The problem will be either electrical (problems with power or oscillator, or the chip itself) or a problem with the configuration data (LVP, oscillator, MCLR).

foppa
Posts: 45
Joined: Sat Dec 20, 2008 1:55 pm
Has thanked: 3 times
Been thanked: 1 time
Contact:

Re: lcd how to do

Post by foppa »

OK.
But if I want chips 16F690
the text on the LCD display.
So it does not work.
And I understand it thoroughly with time / cycle between the chip and LCD.

How to set the value of this.

LCD shows black boxes.
And when I put light on the RS or the other on port c then flashing light.
Which means that the chip is ok.
I have put in a light flashes in the program to ensure that the chip is ok.

Excuse all the questions but I am new in this.
Thanks for all the help

Foppa :shock:

User avatar
Steve
Matrix Staff
Posts: 3426
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: lcd how to do

Post by Steve »

Here's what I would suggest:

First write a simple output-flasher program so you can see that the i/o lines are going on and off with the appropriate timing, and that the i/o lines are all behaving as i/o lines:

Code: Select all

loop while (1)
    output 0xFF -> portb
    delay 250ms
    output 0x00 -> portb
    delay 250ms
end loop
Then, when you know that the timing of the i/o is correct, modify the program so it uses the LCD. Don't forget to include the "LCD::Start" macro at the beginning of your program:

Code: Select all

call macro LCD::Start
call macro LCD::PrintString "Hello World"
delay 2s
loop while (1)
    output 0xFF -> portb
    delay 250ms
    output 0x00 -> portb
    delay 250ms
end loop

Post Reply