UK Vintage Radio Repair and Restoration Discussion Forum

UK Vintage Radio Repair and Restoration Discussion Forum (https://www.vintage-radio.net/forum/index.php)
-   Homebrew Equipment (https://www.vintage-radio.net/forum/forumdisplay.php?f=99)
-   -   16x2 LCD problem? (https://www.vintage-radio.net/forum/showthread.php?t=189984)

mole42uk 2nd Apr 2022 4:53 pm

16x2 LCD problem?
 
I am trying to implement an Elektor circuit based around a PIC16F1847 which seems to partially work, except that I don't get any information on the attached 16x2 LCD display. There's a 'pulse' LED in the circuit that does pulse at a rate that seems to indicate the propgram on the PIC is running.

The display is good, I've tried it on another device but it seems that the display isn't initialising into the correct mode so that the information sent to it from the PIC doesn't make sense, there's nothing displayed on the screen unless I turn the contrast fully one way, when a row of blocks appears.

Is there a secret to the ubiquitous 16x2 display? I'm a bit stumped because I don't know enough about PIC programming to work out whether the program or the device of the display is at fault.

Any help would be gratefully received!

RogerEvans 2nd Apr 2022 5:35 pm

Re: 16x2 LCD problem?
 
Do you know if the PIC is driving the LCD via the very common I2C adaptor (two data wires plus Vcc and Gnd) or does the PIC directly connect to the (several) pins of the LCD controller.

If it is via the I2C adaptor the only thing you can get wrong is the identification of the four wires (Vcc, Gnd, clock, data). Everything else is down to the PIC but the initialisation of the LCD controller does depend on time delays so using the wrong clock crystal on the PIC could foul it up.

If the PIC drives the LCD directly then there is the choice of using 8 bit or 4 bit data (4 bits obviously saves IO pins on the micro). In 4 bit mode you probably need to ground the 4 unused data pins since the 4/8 bit selection relies on the unused bits reading as zero. It is some time since I have used these LCDs so I am happy to be corrected if I have forgotten anything.

Regards,

Roger

Syrinx1 2nd Apr 2022 7:36 pm

Re: 16x2 LCD problem?
 
I'm not sure if this applies to PIC, but are you using the correct I2C address if using I2C ?

SiriusHardware 2nd Apr 2022 7:38 pm

Re: 16x2 LCD problem?
 
A single row of black blocks on the top row is a sure sign that the display is not being successfully initialised. If it had an onboard i2C interface then I think the I2C interface itself would do some initialisation of the display. If the code is yours, what programming language are you writing in, assembly or 'C' or...?

If the display is essentially being controlled by a Hitachi HD44780 chip or clone there are a few variations depending on whether:
-You are using the display in 4-bit parallel mode or 8-bit parallel mode
-You are or are not using the Read/Write pin of the display.

Be more specific, and then we can suggest some pseudocode or actual code tailored to the way in which you are trying to use it. Do you have a circuit diagram? Would you mind posting the display initialisation part of your code as it stands?

kellys_eye 2nd Apr 2022 8:32 pm

Re: 16x2 LCD problem?
 
It's unusual for the contrast control to be fully one way (or the other) - mid travel has always been the norm for my experiments. Maybe check the connections and voltages around the contrast control?

Another thing I've found is that some displays (and this is also a temperature sensitive thing) take a short time to respond to adjustment of the contrast control and, perhaps, you've 'tuned through' the critical position?

Is this the lead acid rejuvenation circuit?

SiriusHardware 2nd Apr 2022 8:51 pm

Re: 16x2 LCD problem?
 
We use a lot of these at work in various products and actually mid-travel would usually result in a blank display. We wire the contrast presets so that clockwise = more / darker, and they invariably have to be set to about 80% clockwise before anything appears on the display, and then the point of ideal contrast is quite a narrow zone.

If Mole is seeing black blocks then the contrast is not far off the correct setting.

mole42uk 3rd Apr 2022 7:50 am

Re: 16x2 LCD problem?
 
Good morning! I'm sorry to leave it hanging yesterday - I went out to an orchestral concert - the first for two years!

Yes, it is the Elektor lead acid rejuvenation circuit. I have seen a YouTube that shows it working. It is not my code, and I don't know enough about PIC code to do much, my coding days began with the 4040 and ended with the Z80.

I think the contrast control is irrelevant - it does what it is supposed to do. The row of blocks appearing on the top suggests that the display is not initialising properly. The designer has not used the I2C interface, the lower four data pins are connected to GND, and the upper four are connected to the PIC, so the display should initialise in 4-bit mode. The R/W pin is grounded. The PIC18F1847 has an internal clock without an external crystal or capacitor - the only indication that it is clocking at the correct speed I have so far is that there is a LED output pulsing at more-or-less the expected time interval.

mole42uk 3rd Apr 2022 8:00 am

Re: 16x2 LCD problem?
 
1 Attachment(s)
Here's part of the circuit (it's very simple):

SiriusHardware 3rd Apr 2022 9:45 am

Re: 16x2 LCD problem?
 
Was the code written specifically for that PIC chip and is the diagram exactly as per the original project with the same port pins used for the same purpose?

The first check is to see what activity there is on the E pin which is an active-high enable pin. Every time the PIC sends anything to the display that pin should be taken momentarily high and low again. Typically you will see a burst of E activity immediately after reset or power-up as the PIC sends the setup sequence to the display, then after that there may be relatively little activity or none until the PIC actively writes something new to the display.

When the read-write signal is used the PIC polls the display by reading the state of the display's 'busy' bit unit it is 'not busy' before sending anything new to the display. When the display is used in write-only mode as it is here, it is up to the PIC to allow enough elapsed time since sending the last command before sending any new command, so one possible cause for your problem is that the PIC is sending commands with too short an interval between them. This might happen if the timing in the code was originally calculated for the chip running with a 1MHz or 2MHz external clock, rather than the (typically) 4MHz internal clock.

Terry_VK5TM 3rd Apr 2022 10:26 am

Re: 16x2 LCD problem?
 
If Richard got the code from Elektor, all that is supplied is the HEX file (no source code).

There is a note in the zip archive re config words so possible these are not set in the HEX file which is stopping the PIC intialising properly.

Alternative is that the LCD is not wired properly.

SiriusHardware 3rd Apr 2022 10:34 am

Re: 16x2 LCD problem?
 
Is the hex file easily available, if not maybe mole could post it here in a .zip file so we can load it into MPLAB and see how the configuration bits are set. It may even be possible to diassemble some or all of it to get and idea of what is going on. The first thing it will do is initialise the PIC's ports and the second thing it will do is to intialise the display, so we wouldn't have to plough too far into the code to see what is going on.

If the circuit has been hand wired it would be quite easy to get the wiring tangled up, having looked at the pinout for the PIC in question the allocation of PIC port pins to display data lines for example is all over the place.

Edit: I see Terry suggests that the config bit settings may not be embedded in the hex file and may therefore need to be set manually at programming time.

mole42uk 3rd Apr 2022 11:00 am

Re: 16x2 LCD problem?
 
The code seems to have been written for the chip I'm using, the diagram I posted is part of the original circuit. I think the PIC is initialising itself properly - the LED pulse output appears to be timed correctly. I've checked the wiring, both on the original PCB layout (KiCAD), physically and electrically.

Tests this morning indicate that the D4-D7 pins seem to have proper signals. The E pin is normally low and has a very short high pulse about every second - I can't measure the pulse length, it's too short but the oscilloscope is set to 0.5S/div and the pulse appears as a very small dot at 5V every other division.

I also checked the output to the MosFET which appears to do what I'd expect.

mole42uk 3rd Apr 2022 11:05 am

Re: 16x2 LCD problem?
 
1 Attachment(s)
Lets see if this works:

SiriusHardware 3rd Apr 2022 11:46 am

Re: 16x2 LCD problem?
 
It sounds as though the project must have a real time clock or countdown timer on the display, ie, it is trying to update the display exactly once per second. I see that four people have already grabbed the code you posted so there is already a 'team' working on this. I have to go out now so I'll check in later to see how they are doing. ;)

Oh, one other thing, how about activity on the RS pin? Most of that will happen during the initialisation phase immediately after reset.

SiriusHardware 3rd Apr 2022 6:29 pm

Re: 16x2 LCD problem?
 
Next question for mole: How / which software (MPlab 8.xx? MPLAB X?) and which programmer (PicKit2? PicKit3? ICD2? ICD3?) are you using to program the device?

mole42uk 3rd Apr 2022 6:50 pm

Re: 16x2 LCD problem?
 
Answering the questions in order:

RS is pulsing at about the 1sec rate but longer pulse width than the E pin.

MPLAB X IPE, PICKIT3 - both of which have been successful in programming other devices.

SiriusHardware 3rd Apr 2022 7:27 pm

Re: 16x2 LCD problem?
 
1 Attachment(s)
Thanks for that.

I tried opening MPLAB IPE, selected the correct device and then opened the configuration bits window and manually scrambled all the configuration settings, then loaded the hex file in. Loading the hex file in sets the configuration as per the screen capture, attached.

Comparing this with the 'configuration bits' text file in the code archive, I don't see anything immediately wrong or different with these settings. Anyone else?

Code:

Fuses:
CONFIG WORD 1
Oscillator selection bits: 100 = INTOSC oscillator. I/O function on OSC1 pin
Watchdog Timer Enable bit: 00 = WDT disabled
Power-Up Timer Enable bit: 1 = PWRT disabled
MCLR Pin Function Select: 0 = MCLR/VPP pin function is digital input, MCLR internally disabled. Weak pull-up under control of WPUA register
Code Protection bit: 1 = Program memory code protection is disabled
Data code Protection bit: 1 = Data memory protection disabled
Brown-out Reset Enable bits: 00 = BOR disabled
Clock Out Enable bit: 1 = CLKOUT function is disabled. I/O or oscillator function on CLKOUT pin
Internal-External SwitchOver bit: 0 = Internal/External switcjover mode is disabled
Fail-Safe Clock Monitor Enable bit: 0 = Fail-Safe Clock Monitor is disabled

CONFIG WORD 2
Flash memory self-write protection bits: 11 = Write protection off
PLL enable bit: 0 = 4xPLL disabled
Stack overflow/underflow reset: 0 = under/overflow will not cause reset
Brown-out reset voltage selection: 1 = reset voltage set to 1.9V
Debugger mode bit: 1 = In-circuit debugger disabled, ICSPCLK and ICSDAT are GP I/O

Low-Voltage Programming Enable bit: 0 = HV on MCLR/VPP must be used for programming


Terry_VK5TM 3rd Apr 2022 11:31 pm

Re: 16x2 LCD problem?
 
Must be having finger trouble as I thought I posted yesterday.

Re config bits - same result, they are in the hex file.

The .fcfx file is the source code - it's Flowcode.

SiriusHardware 4th Apr 2022 8:01 am

Re: 16x2 LCD problem?
 
I think we are at the point where it may be necessary to rule out problems on the inter-wiring between the display and the PIC, particularly the order of the connections between the PIC pins and D4-D7 on the display - also a check to make sure that no two of the data lines are shorted to each other or to GND / supply. You haven't said how this is constructed mole, is it built on stripboard?

Also, consider the possibility that one of the I/O pins on the PIC may be dud. Do you have a spare chip to try?

If none of the above applies then it may be that this particular display needs the data sent to it a little bit more slowly than the one used in the original Elektor project. (You've mentioned that it works in something else but that other project / circuit may be using the Read/Write line and polling the display's BUSY bit so that it knows when it is OK to send more data).

Do you have another project or unit that you can 'borrow' a display from to try in this project?

Terry_VK5TM 4th Apr 2022 10:08 am

Re: 16x2 LCD problem?
 
One thing I did notice from the schematic is that the wiring from PIC to LCD is very non standard in that it uses both PORTA and PORTB for the data lines (I'm talking D4-D7).

If anybody has a collection of Elektor, the project is in the March/April 2017 edition.


All times are GMT +1. The time now is 2:35 am.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright ©2002 - 2023, Paul Stenning.