UK Vintage Radio Repair and Restoration Powered By Google Custom Search Vintage Radio and TV Service Data

Go Back   UK Vintage Radio Repair and Restoration Discussion Forum > Other Discussions > Homebrew Equipment

Notices

Homebrew Equipment A place to show, design and discuss the weird and wonderful electronic creations from the hands of individual members.

Reply
 
Thread Tools
Old 2nd Apr 2022, 3:53 pm   #1
mole42uk
Nonode
 
mole42uk's Avatar
 
Join Date: Aug 2010
Location: Bristol, UK
Posts: 2,451
Default 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!
__________________
Richard

Index:
recursive loop: see recursive loop
mole42uk is offline   Reply With Quote
Old 2nd Apr 2022, 4:35 pm   #2
RogerEvans
Hexode
 
Join Date: Oct 2014
Location: Wiltshire, UK.
Posts: 314
Default 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
RogerEvans is offline   Reply With Quote
Old 2nd Apr 2022, 6:36 pm   #3
Syrinx1
Pentode
 
Join Date: Feb 2018
Location: Nottingham, Nottinghamshire, UK.
Posts: 141
Default Re: 16x2 LCD problem?

I'm not sure if this applies to PIC, but are you using the correct I2C address if using I2C ?
Syrinx1 is offline   Reply With Quote
Old 2nd Apr 2022, 6:38 pm   #4
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 8,628
Default 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?
SiriusHardware is online now   Reply With Quote
Old 2nd Apr 2022, 7:32 pm   #5
kellys_eye
Heptode
 
Join Date: Jan 2014
Location: Oban, Scotland, UK.
Posts: 990
Default 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?
kellys_eye is offline   Reply With Quote
Old 2nd Apr 2022, 7:51 pm   #6
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 8,628
Default 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.
SiriusHardware is online now   Reply With Quote
Old 3rd Apr 2022, 6:50 am   #7
mole42uk
Nonode
 
mole42uk's Avatar
 
Join Date: Aug 2010
Location: Bristol, UK
Posts: 2,451
Default 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.
__________________
Richard

Index:
recursive loop: see recursive loop

Last edited by mole42uk; 3rd Apr 2022 at 6:55 am.
mole42uk is offline   Reply With Quote
Old 3rd Apr 2022, 7:00 am   #8
mole42uk
Nonode
 
mole42uk's Avatar
 
Join Date: Aug 2010
Location: Bristol, UK
Posts: 2,451
Default Re: 16x2 LCD problem?

Here's part of the circuit (it's very simple):
Attached Thumbnails
Click image for larger version

Name:	Battery Activator part circuit.jpg
Views:	121
Size:	44.1 KB
ID:	254541  
__________________
Richard

Index:
recursive loop: see recursive loop
mole42uk is offline   Reply With Quote
Old 3rd Apr 2022, 8:45 am   #9
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 8,628
Default 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.

Last edited by SiriusHardware; 3rd Apr 2022 at 8:52 am.
SiriusHardware is online now   Reply With Quote
Old 3rd Apr 2022, 9:26 am   #10
Terry_VK5TM
Octode
 
Terry_VK5TM's Avatar
 
Join Date: Oct 2010
Location: Tintinara, South Australia, Australia
Posts: 1,978
Default 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.
__________________
Terry VK5TM
https://www.vk5tm.com/
Terry_VK5TM is offline   Reply With Quote
Old 3rd Apr 2022, 9:34 am   #11
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 8,628
Default 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.
SiriusHardware is online now   Reply With Quote
Old 3rd Apr 2022, 10:00 am   #12
mole42uk
Nonode
 
mole42uk's Avatar
 
Join Date: Aug 2010
Location: Bristol, UK
Posts: 2,451
Default 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.
__________________
Richard

Index:
recursive loop: see recursive loop
mole42uk is offline   Reply With Quote
Old 3rd Apr 2022, 10:05 am   #13
mole42uk
Nonode
 
mole42uk's Avatar
 
Join Date: Aug 2010
Location: Bristol, UK
Posts: 2,451
Default Re: 16x2 LCD problem?

Lets see if this works:
Attached Files
File Type: zip software.zip (39.5 KB, 29 views)
__________________
Richard

Index:
recursive loop: see recursive loop
mole42uk is offline   Reply With Quote
Old 3rd Apr 2022, 10:46 am   #14
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 8,628
Default 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 is online now   Reply With Quote
Old 3rd Apr 2022, 5:29 pm   #15
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 8,628
Default 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?
SiriusHardware is online now   Reply With Quote
Old 3rd Apr 2022, 5:50 pm   #16
mole42uk
Nonode
 
mole42uk's Avatar
 
Join Date: Aug 2010
Location: Bristol, UK
Posts: 2,451
Default 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.
__________________
Richard

Index:
recursive loop: see recursive loop
mole42uk is offline   Reply With Quote
Old 3rd Apr 2022, 6:27 pm   #17
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 8,628
Default Re: 16x2 LCD problem?

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
Attached Thumbnails
Click image for larger version

Name:	PIC18F1847_Config.jpg
Views:	20
Size:	62.7 KB
ID:	254589  
SiriusHardware is online now   Reply With Quote
Old 3rd Apr 2022, 10:31 pm   #18
Terry_VK5TM
Octode
 
Terry_VK5TM's Avatar
 
Join Date: Oct 2010
Location: Tintinara, South Australia, Australia
Posts: 1,978
Default 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.
__________________
Terry VK5TM
https://www.vk5tm.com/
Terry_VK5TM is offline   Reply With Quote
Old 4th Apr 2022, 7:01 am   #19
SiriusHardware
Dekatron
 
Join Date: Aug 2011
Location: Newcastle, Tyne and Wear, UK.
Posts: 8,628
Default 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?
SiriusHardware is online now   Reply With Quote
Old 4th Apr 2022, 9:08 am   #20
Terry_VK5TM
Octode
 
Terry_VK5TM's Avatar
 
Join Date: Oct 2010
Location: Tintinara, South Australia, Australia
Posts: 1,978
Default 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.
__________________
Terry VK5TM
https://www.vk5tm.com/
Terry_VK5TM is offline   Reply With Quote
Reply

Thread Tools



All times are GMT. The time now is 11:39 pm.


All information and advice on this forum is subject to the WARNING AND DISCLAIMER located at https://www.vintage-radio.net/rules.html.
Failure to heed this warning may result in death or serious injury to yourself and/or others.


Powered by vBulletin®
Copyright ©2000 - 2022, vBulletin Solutions, Inc.
Copyright ©2002 - 2021, Paul Stenning.