PIC with LCD in Oshonsoft basic

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Hi,

I am trying to get a PIC to connect to an LCD module. I'm using Oshonsoft basic.

I have attached a photo, showing my program, also one of the circuit. This works in the simulator, but not in circuit.

I have a LED in the LOOP, and if I start with the LCD parts commented out, the LED flashes. If I work down the code commenting back in each element. When the 'Lcdinit' is commented in, then the LED doesn't flash.

Are there any more ideas please.

Cheers, Camerart.
 

Attachments

ericgibbs

Joined Jan 29, 2010
18,849
hi E,
PORTA.4 pin#3 is Open Drain, add a 4k7 or 2k2 pull up to +5V.
The Enable pin will never be pulled high without the pull up resistor

Also remove that link on D0,1,2,3 and 0V link on the LCD.

Eric
 

Attachments

Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,730
hi E,
PORTA.4 pin#3 is Open Drain, add a 4k7 or 2k2 pull up to +5V.
The Enable pin will never be pulled high without the pull up resistor

Also remove that link on D0,1,2,3 and 0V link on the LCD.

Eric
Hi Eric, 'Good to hear from you'

I added the resistor and now the LED flashes in the Simulator and the circuit. I tried a logic probe on the 7 LCD pins, and they all seemed to be working as they should. Voltage at pin#3 when running 1.54V

I don't understand the timing, but my ill informed guess is that the screen doesn't have time to write?

Link on D0,1,2,3 and 0V removed

I'm hoping that the LCD is not broken!

Regards, 'Camerart'
 

ericgibbs

Joined Jan 29, 2010
18,849
hi E,
I would add a 10k contrast pot, one end to +5V the other end to 0V and the wiper to VO of the LCD.
Adjust until you can just see the all the character pixel blocks on the LCD


Also add a 10uF and 100nF cap from +5V to 0V on your project board, decoupling.
Eric
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
hi E,
I would add a 10k contrast pot, one end to +5V the other end to 0V and the wiper to VO of the LCD.
Adjust until you can just see the all the character pixel blocks on the LCD


Also add a 10uF and 100nF cap from +5V to 0V on your project board, decoupling.
Eric
Hi Eric,

I can now see a few lines of pixels on the second row, but no writing.

C.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
hi E,
Please post your complete Oshonsoft code and I will check it out.
E
Hi E,

Rich (BB code):
'16f684A xtl

Define CONF_WORD = 0x3f41  'XTL
Define CLOCK_FREQUENCY = 4  'Changed from 12
AllDigital

'Define SIMULATION_WAITMS_VALUE = 1  'SIMULATION ONLY

Define LCD_BITS = 4
Define LCD_DREG = PORTB
Define LCD_DBIT = 4
Define LCD_RSREG = PORTA
Define LCD_RSBIT = 2
Define LCD_RWREG = PORTA
Define LCD_RWBIT = 3
Define LCD_EREG = PORTA
Define LCD_EBIT = 4
Define LCD_READ_BUSY_FLAG = 0
Lcdinit

loop:
    Lcdcmdout LcdClear
    Lcdout "WORKING!?"
    Lcdcmdout LcdLine2Home
    Lcdout "TEST"
    Toggle RA1
        WaitMs 1000
Goto loop

Cheers, Camerart.
 
Last edited by a moderator:

ericgibbs

Joined Jan 29, 2010
18,849
Hi E,
It runs fine in simulation.
I see on your code list at the top it says,,, 16F684A......... its a 16F648A, I guess thats a typo.?

I will relook at your photo of the project board, see if there are anymore problems.

E

EDIT:
Top wiring on the PCB board checks out OK against the diagram and program.

Can you post a photo of the underside of the PCB, check for copper whiskers.??
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Hi E,
It runs fine in simulation.
I see on your code list at the top it says,,, 16F684A......... its a 16F648A, I guess thats a typo.?

I will relook at your photo of the project board, see if there are anymore problems.

E

EDIT:
Top wiring on the PCB board checks out OK against the diagram and program.

Can you post a photo of the underside of the PCB, check for copper whiskers.??
Hi E,

I changed from 16F819 to 16F648A as I won't need any analogue, so it not a typo.

I'll double check the board tomorrow for whiskers.

Cheers, C
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Hi E,
It runs fine in simulation.
I see on your code list at the top it says,,, 16F684A......... its a 16F648A, I guess thats a typo.?

I will relook at your photo of the project board, see if there are anymore problems.

E

EDIT:
Top wiring on the PCB board checks out OK against the diagram and program.

Can you post a photo of the underside of the PCB, check for copper whiskers.??
Hi Eric,

Today I did a continuity test between each pin and all the rest. I found PIN1 connected to +V.

The power connection at the bottom of the board, has a link across the board, making two +v lines of copper. I've cut the offending one, and now the board works:mad:

Thanks for all the help, Camerart.
 

THE_RB

Joined Feb 11, 2008
5,438
Is it not in #7
Yes it was;
Lcdinit

Sorry that was my fault, I missed it. :) Probably because it looked like part of your #defines.

Do the Basic inbuilt LCD functions check the busy flag? If not, there needs to be the correct sized delays in the code for certain commands and some compilers will not use the correct delays unless you have specced the xtal speed properly (I noticed you changed it from 12 to 4?).
 

jjw

Joined Dec 24, 2013
823
The program can either use the busy flag or the delays which can be set freely or use the default values.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Yes it was;
Lcdinit

Sorry that was my fault, I missed it. :) Probably because it looked like part of your #defines.

Do the Basic inbuilt LCD functions check the busy flag? If not, there needs to be the correct sized delays in the code for certain commands and some compilers will not use the correct delays unless you have specced the xtal speed properly (I noticed you changed it from 12 to 4?).
I don't know about LCD functions.

I changed the XTL to 4MHz because I have them. I'll change later.

Did you see the 19 April posting? The LCD is working! Now it's working, I will 'play' with it and look at timings etc.
 

ericgibbs

Joined Jan 29, 2010
18,849
Is it set in the best way now?
hi E,
Use the LCD Busy flag if you have the pin to spare, using delays will always mean that LCD subroutines will run slower.

Also in a 16F PIC you have only a 8 deep Stack, Oshonsoft LCD delays hog the Stack, so any other Gosubs your program uses could generate Stack overflow errors.

E
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
hi E,
Use the LCD Busy flag if you have the pin to spare, using delays will always mean that LCD subroutines will run slower.

Also in a 16F PIC you have only a 8 deep Stack, Oshonsoft LCD delays hog the Stack, so any other Gosubs your program uses could generate Stack overflow errors.

E
Hi E,

As I have the r/w pin connected, reading the 'HELP' as if it should be set to 1? I'll leave it like that for now. I have 1 pin spare!

As I'm at stage one, before I go to far down the track, do you think I have to make the giant leap to a larger PIC or step up to 18 series? I was hoping to stay as I am. If need be, I can connect two PICs together.

Using 16 PICs, to work on the program. I will be working with lists of data, where the program compares data with data. I will need some kind of way of seeing the results. Is the LCD module in Oshonsoft best for this?

Regards C.
 
Top