PDA

View Full Version : lost in lcd land



jcleaver
- 17th May 2006, 15:59
new to picpro trying to get a lcd display using lcdout tried all examples and info i can find hookup seems ok using either f628a or f627 no nothing changed porta to digital nothing any help would be greatly appreicated if i cant get this far
in trouble

ErnieM
- 17th May 2006, 17:05
Well, if you post a schematic or some code we may be more helpful.

Re-check the examples shown in the book. Make sure all your define lines are 100%. Buzz out the breadboard again. All wires!

And lastly, as it catches me near every time I start a new PIC, make sure the pins you connect to are not used for some analog function (PICs default to those). You can try something like setting all the LCD drive pins high and low in a loop, make sure they all do that. Fast loop if you have a scope, slow loop if you use a DVM.

The LCD stuff works.

mister_e
- 18th May 2006, 03:20
also there's some i/o that can't be used as OUTPUT, there's also some with open-drain... just post your code here and say if you're using the internal oscillator or an external crystal... if so wich speed.

jcleaver
- 19th May 2006, 00:20
the code is the example in pbp book lcdout pg 94
wiring checks ok using internal osc on 628a

mister_e
- 19th May 2006, 02:25
Did you add CMCON=7 ?
Is any pull-up resistor on RA.4?
Did you add a start-up delay for the LCD between 500mSec and 2 Second before using the first LCDOUT?
Are you sure of your Config Fuse setting for the MCLR pin and Internal OSC?
...
...
...
Are you sure your LCD controller is compatible with the Hitachi one?

jcleaver
- 19th May 2006, 14:24
problem seems to be activating the internal osc on the f628a
define osc 4 does not work any help would be appreicated dont see anything in pbp manual

jcleaver
- 19th May 2006, 14:26
yes to the first ones ???? how do you set config fuse never seen this one in the manual?? does anyone else think the manual is very weak and not for the newbe

ErnieM
- 19th May 2006, 16:04
The config isn't the easiest thing to set. Here's how I do it:

First, I set my assembler to MPASM. You'll find a tab for this in MCS under View | Compile & Program Options.

Then, find the .inc file under the PBP folder that PBP used for your specific device, such as 16F628A.INC for the 628A you mentioned you might use.

Open this file in any text editor (notepad works!) and find the __config fine, and comment it with a semicolon (that's the comment character in assembly)

MPLAB makes a nice platform to set your config bits. Select the device you're using and find the config bits panel. You can see all the config choices, select them, and it gives you the proper names and valuses for the config settings.

In your .bas file, add the config settings. Here's how that looked for a recent F88 project of mine:

asm
__config _CONFIG1, 2f50h
__config _CONFIG2, 3ffch
endasm

2cents: When I'm trying to get a new PIC project up, I do the smallest steps first, things like set the osc frequency and have it come out on a pin so I can make sure I at keast have the clock I need.

The OSC statement does not set the oscillator, it just tells the compiler what freq you think you're running the osc at.

jcleaver
- 19th May 2006, 19:38
thanks for your help. did not find the line in my include file to rem out
tried adding your line got several errors about symble not defined did assemble
however it did not solve the problem any help would be appreicated

mister_e
- 19th May 2006, 21:06
Using MPASM


'
' PIC Configuration
' =================
@ __CONFIG _INTRC_OSC_NOCLKOUT & _MCLRE_OFF & _LVP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_ON

'
' Hardware configuration
' ======================
CMCON=7 ' disable internal comparator
TRISA=0 ' Set all PORTA capable i/o to output
TRISB=0 ' Set all PORTB i/o to output

'
' Hardware initialisation
' =======================
Pause 1000 ' 1 second for LCD initialisation

'
' Main loop
' =========
Start:
LCDOUT $FE,1,"Should Work now!"
Here:
Goto here

Using PM


'
' PIC Configuration
' =================
@ DEVICE PIC16F628, INTRC_OSC_NOCLKOUT, WDT_OFF, PWRT_ON, MCLR_OFF, LVP_OFF, PROTECT_OFF

'
' Hardware configuration
' ======================
CMCON=7 ' disable internal comparator
TRISA=0 ' Set all PORTA capable i/o to output
TRISB=0 ' Set all PORTB i/o to output

'
' Hardware initialisation
' =======================
Pause 1000 ' 1 second for LCD initialisation

'
' Main loop
' =========
Start:
LCDOUT $FE,1,"Should Work now!"
Here:
Goto here

jcleaver
- 20th May 2006, 02:02
problem seems to be the microstudio does not like the inc files that came with the pbp and this is the one i seem to need but get many errors works much better with the include files that came with mplab still doesnot give what i want but no errors. tried to unstall everthing and reinstall but no use
could reall use some help here??/

mister_e
- 20th May 2006, 09:51
what are the error you get?
What is your PicBasic Pro version?
What is your LCD model?

jcleaver
- 20th May 2006, 16:05
error message error[118] some file overwriteing previous address contents (2007)
using a hitachi 44780
thanks for staying with me

jcleaver
- 20th May 2006, 16:06
picbasic pro 2.46

mister_e
- 20th May 2006, 16:20
Ahhhh, read the long story there
http://www.picbasic.co.uk/forum/showthread.php?t=543
Pay attention to post #5

As far as i remind, it should work anyway but it's still unpleasant to see some error message :D

I don't know why Melabs define them anyways... i always comment out all of them for all PIC i use.

jcleaver
- 21st May 2006, 02:58
we come a long way in the past couple of days however it still does not work even with known operating programs its tough to get the int osc functioning
dont know whats left

side thought pbp creates 6 files for a program hex-asm-bas-cod-lst-mac
know what the first three function be see no informaion on the last 3

still think the manuals need upgradeing to deal with beginers unless they dont want any

mister_e
- 21st May 2006, 08:52
is a simple LED blink work with the same config fuse as posted before?

jcleaver
- 21st May 2006, 15:42
no | none of my working programs with external osc will work with int osc
and the described settings.
thats why i wanted info on files to see if it was really getting changed

Melanie
- 21st May 2006, 17:38
1. Save the following code as MyTest.BAS into your PBP directory...



'
' Device Programming Options
' --------------------------
@ DEVICE pic16F628, INTRC_OSC_NOCLKOUT
' System Clock Options
@ DEVICE pic16F628, WDT_ON
' Watchdog Timer
@ DEVICE pic16F628, PWRT_ON
' Power-On Timer
@ DEVICE pic16F628, BOD_ON
' Brown-Out Detect
@ DEVICE pic16F628, MCLR_OFF
' Master Clear Options (Internal)
@ DEVICE pic16F628, LVP_OFF
' Low-Voltage Programming
@ DEVICE pic16F628, CPD_OFF
' Data Memory Code Protect
@ DEVICE pic16F628, PROTECT_OFF
' Program Code Protection

'
' Hardware Assignments
' --------------------
LEDA var PortA.0
LEDB var PortB.0

'
' Initialise PIC
' --------------
TRISA=%00000000 ' PortA all OUTPUT
TRISB=%00000000 ' PortB all OUTPUT
CMCON=%00000111 ' Comparators OFF

'
' Main Program
' ------------
Loop:
Toggle LEDA
Pause 500
Toggle LEDB
Pause 500
Goto Loop

'
End

2. Compile (approx 67 words) by opening up a DOS box, logging into the PBP directory and from it use the command line...

PBP -p16F628 MyTest -v

3. Program your PIC...

Results...

1. If it fails to Compile you have a bum PBP installation
2. If it fails to compile you may not have logged into your PBP directory
3. If it compiles but doesn't program you have a bum programmer/software
4. If the PIC does not run, your programmer may have changed the CONFIG Fuse Settings - check this before you hit the BURN Button...
5. If the PIC does not run you have a Bad PIC or have forgotten to pay your electric company.
6. I'm making assumptions you can wire Vss and Vdd to your PIC (MCLR or xtal/resonator not required), and that you can hang an couple of LEDs with a Series Resistors (any value between 180R-390R) between the approprate PIC pin and Vss (or Vdd), and you can figure which way around to nail it.

A program compiled for a 16F628 will happilly burn into an 'A' version without needing recompilation.

jcleaver
- 21st May 2006, 21:51
your a sweetheart. it works fine using this method
now for the million dollar question why??/

dont know what to do to get it to function out of microstudio

any help?//\



thanks

jcleaver
- 21st May 2006, 22:10
when i tried using my old method microstudio on this program
got many errors illegal opcode found label after colum one
error 122 warning 207 so dont know whats going on
have tried to reinstall the software many many many times??/

hate to have to learn how to do this in dos

jcleaver
- 21st May 2006, 22:13
tried doing this not using mpasm and worke fine but dont know how i got here
but it did work

Melanie
- 21st May 2006, 23:24
>your a sweetheart.

I know.

>it works fine using this method now for the million dollar question why??/

Because I programmed it.

>dont know what to do to get it to function out of microstudio

Neither do I - I don't use those things...

>any help?//\

Not with Microcode studio

>thanks

You're welcome

Now let's move on and get your LCD working... connect it as per Page 96 of the manual, copy and save the below code, and compile as before... Remove the LED from PortA.0 but keep the one on PortB.0 - the blinking LED is there to tell you it's all working...



'
' Device Programming Options
' --------------------------
@ DEVICE pic16F628, INTRC_OSC_NOCLKOUT
' System Clock Options
@ DEVICE pic16F628, WDT_ON
' Watchdog Timer
@ DEVICE pic16F628, PWRT_ON
' Power-On Timer
@ DEVICE pic16F628, BOD_ON
' Brown-Out Detect
@ DEVICE pic16F628, MCLR_OFF
' Master Clear Options (Internal)
@ DEVICE pic16F628, LVP_OFF
' Low-Voltage Programming
@ DEVICE pic16F628, CPD_OFF
' Data Memory Code Protect
@ DEVICE pic16F628, PROTECT_OFF
' Program Code Protection

'
' Hardware Assignments
' --------------------
LEDB var PortB.0
'
' LCD Display
' -----------
Define LCD_DREG PORTA ' Port for LCD Data
Define LCD_DBIT 0 ' Use upper 4 bits of Port
Define LCD_RSREG PORTA ' Port for RegisterSelect (RS) bit
Define LCD_RSBIT 4 ' Port Pin for RS bit
Define LCD_EREG PORTB ' Port for Enable (E) bit
Define LCD_EBIT 3 ' Port Pin for E bit
Define LCB_BITS 4 ' Using 4-bit bus
Define LCD_LINES 2 ' Using 2 line Display
Define LCD_COMMANDUS 2000 ' Command Delay (uS)
Define LCD_DATAUS 50 ' Data Delay (uS)

'
' Initialise PIC
' --------------
TRISA=%00000000 ' PortA all OUTPUT
TRISB=%00000000 ' PortB all OUTPUT
CMCON=%00000111 ' Comparators OFF
Pause 2000 ' wait for LCD to wake-up
'
' Main Program
' ------------
Loop:
LCDOut $FE,1,"Hello"
Pause 500
LCDOut $FE,1
Toggle LEDB
Pause 500
Goto Loop

'
End

jcleaver
- 21st May 2006, 23:59
Still Having Lcd Problems But At Least The Chip Is Now Functioning
Led Flashing Will Trace Out And Maybe Find Whats Hapeing With It
Again Thanks
Will Advise On Progress

jcleaver
- 22nd May 2006, 00:43
Wow Beauty And Brains
Got It Working Thanks Thanks

Now The 2 Million Dollar Question (no Not That One)

Where Do You Get Manuals For What Your Doing Does Not Seem To Be Whats Happeing With What I Purchased

Melanie
- 22nd May 2006, 07:09
Well tell me what you purchased...

On my part I'm using PBP2.46 with the latest patches taken from the MeLabs website. The manuals are what comes with the product or again downloaded from the MeLabs website. The DATASHEETS for the PICs come from the Microchip Website. I do not use Microcode studio. All code in my examples comes from the Manual or the Datasheet. You should have EXACTLY the same as I have - except you additionally have MCS which dosen't turn me on.

I also look at what the installation disks have put on my PC. There's stuff to be learnt from that... Readme files and documentation and examples... look and learn...

jcleaver
- 22nd May 2006, 12:33
i have the same thing pbp 2.4 just let in install itself it set up microstudio as the windows interface will searc the cd for more info

thanks again lady