PDA

View Full Version : LCDOut Woes



LetTheSmokeOut
- 7th June 2008, 04:24
Hi guys,

Ok, I am at my wits end. I've come back to Pic and Picbasic pro from AVR so I can rapidly develop some basic circuits I need for the homestead. I spent two days working on two simple (well should be) circuits and cannot seem to get anything working except PWM on 16F628.

I wanted to make a turns counter using a hall effect and LCD connected to a 16F628. I have an old LCD backpack but it just sends garbage to the lcd as if the controller on it has been zapped by static or something.

So I fired up one of the many new LCD's I have and using LCDOUT I still cannot get anything working. I set up the 16F628 and made sure three or four of them were working on the test board and all were fine and could output PWM on CCP1 etc, but no LCD even after hours of checking and rechecking connections and filtering power etc. It's got to be coding issues. Don't laugh too hard, I have not written in basic in years now

Here is the circuit I am using and code:

@ DEVICE PIC16F628, INTRC_OSC_NOCLKOUT, WDT_ON, MCLR_OFF,BOD_ON, LVP_OFF, CPD_OFF, PROTECT_OFF

DEFINE OSC 4


TRISA = %00011111
TRISB = %00001000
CMCON = 7 ' PortA = digital I/O


begin:
pause 1000
LCDOUT $FE,1,"Testing...."
pause 1000
LCDOUT $FE,1
goto begin

skimask
- 7th June 2008, 04:30
Blocks on the LCD, yes/no?
Contrast dialed both one way (to Vdd) and back (to Vss), any changes in the screen?
Put a 'heartbeat' LED on the board, make sure the thing is actually running...

mackrackit
- 7th June 2008, 05:57
I may not be looking at it correctly and I think LCDOUT over rides it???
The TRISA posted has your LCD pins set for input?

skimask
- 7th June 2008, 06:02
The TRISA posted has your LCD pins set for input?
I'm fairly sure LCDOUT does override it. (otherwise there'd probably be another million threads on the forums about why this or that doesn't work right here or there)

Melanie
- 7th June 2008, 06:44
I see no LCD defines in your code... please put them in.

They are in the PICBASIC manual and tons of examples on this forum. Set them up for the way you've got your LCD wired.

LetTheSmokeOut
- 7th June 2008, 07:15
I see no LCD defines in your code... please put them in.

They are in the PICBASIC manual and tons of examples on this forum. Set them up for the way you've got your LCD wired.


Yes, contrast works on three different (brand new) LCD's. All LCD defines are now at default which is:

PORTA.0 =Data bit 4
PORTA.1=Data bit 5
PORTA.2=Data bit 6
PORTA.3=Data bit 7
PORTA.4=R/S
PORTB.3=Enable
R/W is grounded

I Disabled MCLR to eliminate the need for pull-up and hassle. I also tried TRISA=%00000000 and TRISB=%00000000. I will post anything you need. Pictures, or anything else. I can even switch to a breadboard and eliminate possibility of circuit board issues (proto board) although I have spent literally 20 hours soldering and de-soldering an looking at every little solder joint, then using PWM and other commands to make sure the chips are good and working properly.

Thanks for your help on this. Very, very much appreciated...

mackrackit
- 7th June 2008, 07:21
Melanie is asking to see the part of your code that looks something like this;


DEFINE LCD_DREG PORTB
define LCD_DBIT 4
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 1
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 0
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50

LetTheSmokeOut
- 7th June 2008, 16:42
Melanie is asking to see the part of your code that looks something like this;


DEFINE LCD_DREG PORTB
define LCD_DBIT 4
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 1
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 0
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50


Yes indeed. I am using the defaults explained in the PicBasicPro manual. It states that you don't need any defines if you are going to accept the defaults which are what I stated above. Is this not the case? I've used the program with LCD defines and without, but I can put them back into the program just to make sure. I have also used defines for a different pin setup that allowed PORTB.3 to be used as PWM output while the other pins ran the LCD.

LetTheSmokeOut
- 7th June 2008, 16:49
This should be what I have setup at the moment:

(CODE)
DEFINE LCD_DREG PORTA
define LCD_DBIT 4
DEFINE LCD_RSREG PORTA
DEFINE LCD_RSBIT 4
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 3
DEFINE LCD_BITS 4
DEFINE LCD_LINES 1
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50
(/CODE)

abidr
- 9th June 2008, 09:08
try using with the configuration bits as watchdog timer off and brown out detect off, power up timer on and oscillator as XT

LetTheSmokeOut
- 10th June 2008, 04:35
try using with the configuration bits as watchdog timer off and brown out detect off, power up timer on and oscillator as XT

Ok thanks I will try that. I am still working on it. I wound one coil by keeping track of counts in memory and I already have problems, I missed about 30 turns out of 900 lol! My backpack LCD (Seetron) was purchased back in 1999 and I found it works but the 16C54 it uses is bad (sends out garbage on the 3rd character placement and further) so I will have to get back on the LCDout unit using 16F628.

I will try this tomorrow and get back to you. Thanks very much for the input it is very much appreciated.

g-hoot
- 10th June 2008, 21:25
Hey LetTheSmokeOut,
I'm still pretty newbie to this stuff, but I had 2 issues that drove me nuts for a while that you never kbnow, could be one of your problems. One was that, for some reason, no matter how many times I read the PBP manual for the LCDOUT command, my mind never saw the "Flags = 0" part. Some one here pointed that out to me and that fixed one issue. The other issue was that I was getting garbage displayed sometimes and I could not display a number ending in "0" or "P". It turns out that the voltage rating fro the LCD was a minimum of 4.7 V and with the resistor I was using, it was about 4.62 or so. I changed that resistor to get the voltage up in range and that solve my bizarre problems.
Gary

LetTheSmokeOut
- 11th June 2008, 01:45
Thanks guys. It's working now. Looks like the fuse settings as Abidr mentioned was one problem and the flags=0 like G-hoot mentioned was another. Thanks for all your help!

Now I have to figure out interrupts so I can use a Hall effect to send RB0 high on my coil winder so I can increment W0 based on a pulse from the hall and output the word to LCD = )