Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC 16f628A -LCD Control

Status
Not open for further replies.
Eric - I feel I should tell you what it is im up to. I had a stroke recently and have been off work for a few weeks with at least another 6 weeks in the future. I can't do daytime TV so I decided to build a robot. A project that I started many years ago when I worked for Unimation robotics in telford. I have a blog which I have setup - you can read all about my pains here. Insectabot's Blog | An amateur robotics blog

Regards - Paul
 
Last edited:
Hello again all. I now have my LCD menu program - I have now added hand shaking for the busy lines from the LCD along with code for 3 buttons. At present when any button is pressed it should just clear the display.
Its not runing properly and as usual its a timing issue. I have posted the code and could do with any pointers on what the loops for 'tAS', 'tDA', and 'tEL' should be.

Eric - How do I set this up on the simulator towork properly. It appears to be waiting for the handshake? - I have attached a pic of the settings.

Regards - Paul
 

Attachments

  • LCD_Parameters.jpg
    LCD_Parameters.jpg
    110.8 KB · Views: 189
  • Paul_LCDMenu_V1.asm
    7.7 KB · Views: 159
hi,
Ref the LCD set up,when you have set the PORT pins [left image] click the APPLY button.
For the LCD delays, I use 400, 40 and 40
Remember to set the microcontroller type to 16F628A and the Clock to 4mHz using the OPTIONS menu.

Simulators do run much slower than real life programs.

I will test your V1.asm program.
 
hi Paul,
Ref your program what are those txx delays for.??
I see that you are now using the BUSY bit for the LCD.?

Would you like me to post a simple LCD template program.?
 
Hi Eric. The tXX delays are described in the literature of the LCD that I have been reading. These are timers that are recommended for use with the busy flag. Apparently you must wait certain imes for things to happen. I commented this in the code. I too have run the code through the simulator and its loops waiting for the carry flag to be zero. This occours from rotating the D7 bit (Busy flag) and storing it in the Status Register (I think). This bit is never being set low though. Is this because the LCD is still busy? Do I need to do something in the simulator to say ok im ready (Function key maybe)?

The code you have would be very useful. Especially the handshake busy routines.

Regards - Paul
 
Hi Eric. The tXX delays are described in the literature of the LCD that I have been reading. These are timers that are recommended for use with the busy flag. Apparently you must wait certain imes for things to happen. I commented this in the code. I too have run the code through the simulator and its loops waiting for the carry flag to be zero. This occours from rotating the D7 bit (Busy flag) and storing it in the Status Register (I think). This bit is never being set low though. Is this because the LCD is still busy? Do I need to do something in the simulator to say ok im ready (Function key maybe)?

The code you have would be very useful. Especially the handshake busy routines.

Regards - Paul

hi,
You dont any additional code in the program to make in run in simulation.
I tidy up a simple program and post it.
 
Hi all, Ive been playing around with the code again this evening. I now have the handshaking (LCD - Busy) working. The problems now seem to be

There are 'extra' spaces added at the end of the message. The loop seems to ignore that 0x00 is set and continues. This then causes and endless loop at the 'addwf 02,f' line of code. It never gets to jump to the check_switches bit. Is this the XORLW?

New code v2 attached.

Regards - Paul
 

Attachments

  • Paul_LCDMenu_V2.asm
    6.9 KB · Views: 176
Hi all, Ive been playing around with the code again this evening. I now have the handshaking (LCD - Busy) working. The problems now seem to be

There are 'extra' spaces added at the end of the message. The loop seems to ignore that 0x00 is set and continues. This then causes and endless loop at the 'addwf 02,f' line of code. It never gets to jump to the check_switches bit. Is this the XORLW?

New code v2 attached.

Regards - Paul

hi Paul,
Look at this option.
Uses internal 4mHz clock, only 4 LCD data wires from B.7,6,5,4 and the /MCLR is ON, this gives you 5 PIC pins free for other jobs.

Its been tested OK in a 628A PIC.
 

Attachments

  • PaulLcdDemoV1.asm
    5.5 KB · Views: 167
Last edited:
Hi thanks for that Eric. I have been looking at the 4bit idea and think i'll do that further down the line if only to free up a few data lines. The marcos look interesting. I haven't done any yet but I get the idea. Infact my new code which I have attached could very much do with macros now. I have to do it this way first though to get a firm understanding of what im doing. Hopefully my step by step approach will help others too. I am now at the point where I can start branching to other sub menus from the switches. At present all switches just call a clear screen routine. I think I probably need a delay on reading the switches as sometimes switch 1 clears and then goes back to program (weird debounce maybe?). Anyway thanks for all your help im slowly getting there.

Paul.
 

Attachments

  • lcd.jpg
    lcd.jpg
    55.1 KB · Views: 178
  • Paul_LCDMenu_V2.asm
    9.7 KB · Views: 154
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top