Serial Controller for KS0108B GLCD

nick12ab

Senior Member
What are you trying to do/undertake that you wish to consider such alternatives to the FREE Revolution Education BASIC programming Editor environment?
Remember the main topic of the tread you're reading it in and remember the speed of text? A compiler would solve that problem and free up the space hogged by the PICAXE interpreter. it would probably also free me from the absolutely ridiculous idea of dividing program memory into slots (sorry, that's just how I feel about the slots). The obvious disadvantage of using a BASIC compiler is that the programmer needs to be present in order to program the chip unlike a PICAXE (or...)

Oh and another thing, the 'FREE' support you get in here is excellant.
Yes, 'excellant' support for PICAXE is free! Excellent support for the PICAXE is also free.
 

nick12ab

Senior Member
Character Set



This is the new character set. The change characters have either a yellow or red dot to indicate whether they apply to both character sets (yellow) or only the descenders character set (red). I'm showing it here before implementing it in case someone thinks that a true descender looks better with slight modification from the proposed ones.
 

nick12ab

Senior Member
Problem with true descenders

I've implemented the new descenders and whether they're used or not is controlled by bit 1 of the settings byte. The problem is that the descenders character set doesn't work properly. The following test program is loaded onto a 18M2:
Code:
#picaxe 18M2
#no_data
#no_end
#rem
        DESCENDERS TESTER
#endrem
main:
    output B.5
    pause 100
    setfreq m32
    hsersetup B19200_32,%010
    pause 10
    hserout 0,(192,%10,247,253,0,"TRUE DESCENDERS...",253,20,"gjpqygjpqygjpqygjpqy",192,0,"NO TRUE DESCENDERS",253,60,"gjpqygjpqygjpqygjpqy","TEST IS OVER")
    setfreq m4
    do : loop
but on the first line of letters which uses the true descenders, some letters are still their normal selves (j,q,y) despite that they've been replaced, the g is the only letter where the descender is used and the p is replaced by the descender q. For not using descenders, the correct letters are displayed.

The driver code is attached as that silly character limit has not been removed yet.
 

Attachments

hippy

Ex-Staff (retired)
Staff member
Have you tried simulating ( set required variables then jump to 'nextthing' ) or adding SERTXD in the code to check it's going where you expect, values are right and even that 'descenders=1' has been set correctly ?

Where I'd start is a SERTXD("Bingo!") or some other flag to indicate it did a lookup of the character set for descenders. If it doesn't hit that, the 'descenders' isn't set to 1 and you can work back to find why not. If it does, then you can work forward to see why what you are looking up isn't what's being output. That at least halves where the problem may be; not looking up the right data / looking up the right data but not putting right data out.
 

nick12ab

Senior Member
Have you tried simulating
'hsersetup cannot currently be simulated'

Where I'd start is a SERTXD("Bingo!") or some other flag to indicate it did a lookup of the character set for descenders. If it doesn't hit that, the 'descenders' isn't set to 1 and you can work back to find why not. If it does, then you can work forward to see why what you are looking up isn't what's being output. That at least halves where the problem may be; not looking up the right data / looking up the right data but not putting right data out.
I'll do a PC connection and use a terminal tomorrow.
 

hippy

Ex-Staff (retired)
Staff member
'hsersetup cannot currently be simulated'
The trick there is to put code in #IFDEF SIMULATED conditional compilation blocks and add #DEFINE SIMULATED when simulating. It's then easy to switch between actual code and simulated code and likewise include various test harnesses you may need to test various routines.

You can even use #IFDEF to include RETURN so you can make an otherwise inline section of code as a subroutine when testing.

Conditional compilation is extremely useful if you don't want to spend all your time editing code and commenting things out when testing parts of it, don't want to simulate the entire program just to test a small section of it.
 

nick12ab

Senior Member
I sent the whole alphabet in lowercase and it showed "abcdefghjjklmnpqqrstuvwyyz". This clearly shows that I've changed the character codes for the wrong character for every descender except 'g'.

I was also going to upload a piece of software I made to generate the character codes but apparently a .zip file is an invalid file despite the accepted file types list by the Manage Attachments button saying that it is. So I'll upload a screenshot for the time being.
 

Attachments

Last edited:

nick12ab

Senior Member


Ive fixed it now and the true descenders are on the correct letters. The test does show why on a LCD with no gap between lines the descenders should be optional. Also borrowing a descent camera.

As you can also see, I found another orange LED so it now has an orange backlight and the contrast characteristics are much better but it is dimmer than the white one so I might just revert back and use an orange sweet wrapper or similar to lower the blue content.

Also note that the new image resizing feature DOESN'T WORK as I resized it to 1/4 size but as you can see it is BIG and INTRUSIVE!


If you want to see my applet for generating the character codes, I've changed the extension to pdf in order to smuggle it in so you have to change the file extension back to exe in order to use it.
 

Attachments

westaust55

Moderator


This is the new character set. The change characters have either a yellow or red dot to indicate whether they apply to both character sets (yellow) or only the descenders character set (red). I'm showing it here before implementing it in case someone thinks that a true descender looks better with slight modification from the proposed ones.
Any particular reason why the last (bottom right) character uses the bottom row of pixels when other arrows and characters do not?
 

nick12ab

Senior Member
Decent Photos and Character Set

Now some decent well-lit photos of the GLCD module - click them to view higher-resolution versions.


[HR][/HR]These are the links to the character sets:
• With descenders
• Without descenders
[HR][/HR]westaust55, thanks for pointing that out. This is only in the drawings - the ones programmed on the PICAXE are correct. I've replaced them now so the links now link to the corrected ones.
 
Last edited:

nick12ab

Senior Member
The next thing I hope to do now is to add the bitmaps feature - I'll have it so that you can choose any 128-byte EEPROM block (not necessarily the same size as the actual blocks of the EEPROM) and put it onto one of eight lines so that, for example, a logo or graphic can be displayed on the top half and text on the bottom half.

2. The method I use from SD is to read/check and strip the header. Then rejiggle the bytes so that the byte you send is perpendicular. It is easier to do this in a group of 8x8 cells.
Here is something I've knocked up for you in BASIC.

Code:
//
Sub PlotPictureNeg() ' Plots the image inverse (ie negative)
 
XPos = 0
YPos = 7
GWord = 2
GCommand = DByte(1)
For I = 7 To 0 Step -1 ' 64 lines = 8 charcater lines
For X2 = 0 To 15 ' Loop to get 8x8 cell . 15 is a linesworth.
For X1 = 0 To 7 ' Generate cell byte (a vertical byte)
CellByte.7 = GByte(GWord) <<X1 >>7 ' Pick out bit 7,6,5,4,3,2,1,0
CellByte.6 = GByte(GWord+16) <<X1 >>7
CellByte.5 = GByte(GWord+32) <<X1 >>7
CellByte.4 = GByte(GWord+48) <<X1 >>7
CellByte.3 = GByte(GWord+64) <<X1 >>7
CellByte.2 = GByte(GWord+80) <<X1 >>7
CellByte.1 = GByte(GWord+96) <<X1 >>7
CellByte.0 = GByte(GWord+112) <<X1 >>7 
Pos.x = XPos // GLCD x pos 
Pos.y = YPos // GLCD y pos 
Inc(XPos)
Next 'Vertical byte
Inc(GWord) ' Next group of image bytes 
Next 'X2
Dec(YPos)
XPos = 0 ' Set X back to start of line
Inc(GWord,112) ' Next block up
Next 
End Sub
//
As you mention this code directly after option 2, I assume that this code is for mikroBASIC. To me, it looks like a cross between Visual Basic .NET and C. Can you confirm what variant of BASIC this is?

When doing it on a PICAXE, it would be code inefficient to have it change around the bits at runtime but instead do it when downloading the data onto the EEPROM (on the computer). You don't have to write the code for me (although my language of choice is Visual Basic .NET) but how do I strip the header from the bitmap?
 

nick12ab

Senior Member
EEPROm-to-Scren Display

I've added the function that displays an image from the EEPROM on the GLCD. Again, speed isn't fantastic but better than the text speed. The new code is attached.

the command number is 242 and syntax is 242,eeprom location msb,eeprom location lsb,screen position. There are 16 screen positions, each 64x8 pixels big, so a graphic could be displayed in either corner, either side or top/bottom. There are therefore 1024 graphics that can be used if a 24LC512 EEPROM is used.

But there's no way to put data on to the EEPROM. Dippy, can you tell me what variant of BASIC that code you gave me was as it doesn't look like PICAXE basic. Putting data on the EEPROM will probably be another command (241) with location bytes then 64 bytes sent afterwards to set the data in the EEPROM so all that needs to be done is the header stripping and rotation. For rotation, as each bitmap will be 64x8, it could simply be rotated in Paint then the only thing which needs to be done is the header stripping.
 

Attachments

westaust55

Moderator
But there's no way to put data on to the EEPROM.
Not sure that I understand that statement.
The usual method is to write a PICAXE program containing a lot of hi2cin statements to write the data to the external i2c EEPROM.
Yes it can be laborious but it does work.

EDIT: hi2cin should read hi2cout for writing to the EEPROM
 
Last edited:

nick12ab

Senior Member
Not sure that I understand that statement.
The usual method is to write a PICAXE program containing a lot of hi2cin statements to write the data to the external i2c EEPROM.
Yes it can be laborious but it does work.
What I meant was that there is no way of putting it on to the EEPROM efficiently (so the process really needs to start and end on the same day). I think you mean hi2cout not hi2cin.

It would be preferable to at least be able to get the pixel data in the same format as it is to put it on the EEPROM but, again, painstaking, I could use that character code generator I made recently (see a few posts ago for a download) to enter parts of the bitmap and that would give me the codes but I'd have to manually click everything as it cannot import a bitmap.


Now I've just added inversion capability to the image and it works fine. (the EEPROM I'm using had, I think, test text written to it as it shows garbage when read but only on the first few hundred bytes).
 
Last edited:

nick12ab

Senior Member
I've implemented the new descenders and whether they're used or not is controlled by bit 1 of the settings byte. The problem is that the descenders character set doesn't work properly. The following test program is loaded onto a 18M2:
Code:
#picaxe 18M2
#no_data
#no_end
#rem
        DESCENDERS TESTER
#endrem
main:
    output B.5
    pause 100
    setfreq m32
    hsersetup B19200_32,0
    pause 10
    hserout 0,(192,,247,253,0,"TRUE DESCENDERS...",253,20,"gjpqygjpqygjpqygjpqy",192,0,"NO TRUE DESCENDERS",253,60,"gjpqygjpqygjpqygjpqy","TEST IS OVER")
    setfreq m4
    do : loop
Quick note about this test code - a pause should be added before the last setfreq command as otherwise corrupted stuff is sent to the GLCD sometimes.

The trick there is to put code in #IFDEF SIMULATED conditional compilation blocks and add #DEFINE SIMULATED when simulating. It's then easy to switch between actual code and simulated code and likewise include various test harnesses you may need to test various routines.

You can even use #IFDEF to include RETURN so you can make an otherwise inline section of code as a subroutine when testing.

Conditional compilation is extremely useful if you don't want to spend all your time editing code and commenting things out when testing parts of it, don't want to simulate the entire program just to test a small section of it.
That is useful as long as there's sufficient program memory left to insert a replacement for the hserin but it doesn't matter (yet) as there is quite a bit of space left. The simplest would be to just use serin and put the serin'd byte in the scratchpad.

Not sure that I understand that statement.
The usual method is to write a PICAXE program containing a lot of hi2cin statements to write the data to the external i2c EEPROM.
Yes it can be laborious but it does work.

EDIT: hi2cin should read hi2coutfor writing to the EEPROM
I painstakingly converted a small graphic into hex values manually, for testing purposes and programmed the serial GLCD chip to write the values to EEPROM. Graphic used:



I used it with a 18M2 program for setting the contrast for the serial driver board's inverter. I only changed the EEPROM bytes used by the graphic but the garbled pixels help with contrast calibration.



I've gone back to the white backlight as the orange LEDs are dim.
 

nick12ab

Senior Member
I've added a new command that allows data to be written to the EEPROM through serial commands. It seems to work although I haven't tested it thoroughly yet. The datasheet describing the command is attached and this is the code segment for the new command
Code:
        elseif executebyte = 241 then
            eeprompointerAmsb = @ptrinc        'Get higher byte of EEPROM address
            eeprompointerAlsb = @ptrinc        'Get lower byte of EEPROM address
            progbarsize = @ptrinc            'Get number of bytes to be written
            dec progbarsize
            loopcounterex = loopcounterex + 3 + progbarsize    'Add necessary value to loopcounterex to prevent written bytes from being executed
            for loopcounter = 0 to progbarsize    'loop
                hi2cout eeprompointerA,(@ptrinc)    'Write to EEPROM
                pause 40
                inc eeprompointerA        'Increment EEPROM pointer
            next loopcounter
I can't upload the entire new code as it now exceeds the 19.5kb limit.
 

Attachments

nick12ab

Senior Member


For each character, which variant do you prefer?
Again, back to the characters. Since getting an OLED display, I've noticed that the '7' in the last font set is different again from both choices! So I would like opinions on which one you prefer.


  • The first one is the usual one on LCD modules
  • The second one is the one currently used on the GLCD module
  • The third one is the one on the OLED module
  • The others are off the internet
Also, I never got an opinion on the 'S'. See the quoted bit for the possible Ss.
 

hippy

Ex-Staff (retired)
Staff member
My preferences, but you'll never get any universal agreement and I wouldn't place any money on my saying the same tomorrow ...

A Bottom
S Bottom
W Top
p Top
q Neither, top p mirrored ( as on bottom but lower height )
7 Bottom / first in list
a I prefer an OI shape rather than O on a hook
 

nick12ab

Senior Member
you'll never get any universal agreement and I wouldn't place any money on my saying the same tomorrow
It's the sort of thing that really needs to be a poll (using the forum-provided feature) but that can only be done on new threads which would mean that a new thread would have to be created for each disputable character which would probably spam up the forum - if I'm missing the ability to put a poll in a post, please point that out. I might be able to find a website that allows people to do polls for free and then I can create a thread called "Polls: LCD Character Set Preferences" or similar and the most popular of each choice gets implemented. A quick search for 'free polls' comes up with pollcode.com at the top of the list and I don't even have to sign up to create them!

Font choices may be implementable if I port this to a normal PIC or an Arduino since I'd have a lot more programming memory in which to store the extra characters and then font sets can be chosen through 2 bits in the settings byte (for four character sets) although it still won't suit everyone because everyone would want a different combination of characters.

Changing minds can also be a reason to implement choices as the second 7 in the list was my original preference but now I'm thinking about changing to the third.
 

nick12ab

Senior Member
Serial GLCD Docking Station!!!

I've made a docking station for the serial GLCD module so that the LCD is at a more comfortable angle to view and the docking station also provides regulated power as well. (note corrupted test graphic from testing that the EEPROM write command works)

Behind the LCD, it has a bridge rectifier to allow AC output wall warts and DC output wall warts of any polarity to be used and a linear regulator with small heat sink attached. There's also two jumpers on the back which will be used for a 'regulator select' option when my back-ordered switching regulators finally arrive - one for power input to the regulator and the other for output from the regulator in case the output from one regulator interferes with the unpowered regulator. There's also a rear-mounted power switch but it's a bit hard to switch so I might move it to the side.

On the front, the pinout of the Serial GLCD Module is replicated with a female header. A 10-way jumper header connects the Serial GLCD Module to the docking station and a two-way jumper header is on the left for extra support. Both connect to female headers on the GLCD Module.
 

Attachments

nick12ab

Senior Member
Serial LCD Docking Station Switching Regulator!!!

I've received my switching regulators, set one up on the docking station according to page 8 of the datasheet available through the product page linked in an earlier post. The multimeter read 5v even at no load and it worked first time with no explosions! Photograph coming soon. it is still 5v with the GLCD with backlight on as well.

The only substitution I had to make was swapping the oscillator capacitor for one twice as big which would half the switching speed so I hope that doesn't affect efficiency too much (please point this out if it will).

-nick12ab celebrating 500 posts
 

nick12ab

Senior Member
Serial LCD Docking Station Photos

Annotated photograph:

P080911_19.24_[01]_annotated.jpg

According to a 50p car boot sale power meter, these are the 'electrical properties' when powered through a 12v wall wart and regulators... and both were too low to show anything on the meter.

Instead I just measure the 12v current consumed with a multimeter.

Linear Regulator: ~90mA
Switching Regulator: ~50mA
Unregulated voltage off-load: 13.34v

More precise current readings will come when I get a better meter. (Yes I do mean precise and not accurate)
 

nick12ab

Senior Member
@srnet

I already have a suitable analogue multimeter that goes up to 500mA, but I lost it. My digital multimeter has mA ranges but I can't figure out how to use them - I put the probes in the stated correct holes and turn it onto the correct range but no current flows through (it has a COM hole, a V/mA/Ohms hole and a 10A hole).
 

Buzby

Senior Member
correct range but no current flows through
Sounds like you've blown the protection fuse. I had the same problem after I accidentally put the probes across the supply instead of inline. Take the back off the meter and you'll probably see the fuse quite easily. ( Or read the manual, it might be in there. )
 

jtcurneal

Senior Member
I think that most of us have blown the protection fuse in multimeters when we tried to measure a voltage with the meter set to read milliamps.

Joel
 

Svejk

Senior Member
To check if you blown the fuse for your meter put it on continuity/low ohm range and then measure the continuity/resistance at "10A hole" with the [usualy] red probe. An open circuit indicates a blown fuse.
 

nick12ab

Senior Member
Thanks for that! The fuse is under the cover and soldered onto the board but I can still change it. Is the fuse used to measure the current itself as I don't have that exact value of fuse?
 

jtcurneal

Senior Member
The fuse is used to limit the amount of current passing thru the multimeter is safe for the multimeter components.

Joel
 

westaust55

Moderator
additionally, and particularly if the multimeter is a higher quality unit, the fuses will be ceramic body High Rupture Capacity (HRC) rather than glass body type.
You should use the correct rating - buy one if neceeary.

a lower current rating and you will b=not be able to measure up to 10 Amps.
A higher rating and in the event of a fault, greater energy is allowed to pass through the circuit.
The energy is = i^2 * t so increased current flow before the fuse "blows" allows much greater energy dissipation and the result may be (worst case) disintigration of the multimeter and maybe harm to yourself.
 

nick12ab

Senior Member
if the multimeter is a higher quality unit, the fuses will be ceramic body High Rupture Capacity (HRC) rather than glass body type.
It's a budget multimeter and the fuse is a glass body type. The fuse is 500mA and the 10A mode is unfused. Currently I only have 1A fuses.
 

Dippy

Moderator
For your own health Nick I would suggest binning it and getting a better one.
Having no fuse for higher capacity measurement (from what you say) really is a cheap'n'nasty CH design and could end in tears.

You don't have to pay a fortune for a reasonable meter, though some really cheapos I have used are so slow on autoranging that they drive you nuts.
Be safe, get something branded from a reliable source. It is worth the extra fiver knowing you can sue them next year :)
 

nick12ab

Senior Member
I decided to risk my own health on 12v and put a 1A fuse in the cheap multimeter and...
Switching regulator... 48.5mA (3.3mA off-load)
Linear Regulator... 93.3mA (4.8mA off-load)
I was quite surprised to see that the linear regulator consumed more power than the switching regulator for the off load readings since I heard that switching regulators 'can have problems' on low or off load.
 

Dippy

Moderator
There are a zillion types of regulator and there are good and bad ways to apply them.
What switcher? What linear? What circuit?

And I think that DMMs that offer 10A but sold unfused should be burnt at the stake.
Especially when retailer's customer base include a high percentage of novices and schoolkids.
Even a hundred year old AVO had a trip.
 
Last edited:

Svejk

Senior Member
I've seen low quality DMM disintegrating in the hands of "unfortunate" people. As a guide, choose a DMM with at least CAT III from a brand you can be sure the CAT III is a safety category, not just a marking. Always have 2 multimeters at hand.

Your risk now is that you'll forget that you fitted 1A fuse and try to check mains voltage after you made a 12v current measurement.
 

nick12ab

Senior Member
@Dippy

What circuit - the serial controller for KS0108B GLCD including GLCD and backlight
What switcher - the one on the link earlier in this thread- link here: switching regulators
What linear regulator - L7805

@Svejk

I better remove the fuse now then.
 

Dippy

Moderator
L7805 is a greedy old dinosaur, look around further.
Ah, I haven't seen link and I would imagine that I'm not alone in running out of puff searching 20 thread pages and 200 posts.
Suffice it to say, that I'm sure that with research and good design you could do better ... I know , in all humility, I could.


No, no, keep the 1Amp fuse in. Then when you break the DMM it'll force you to get something decent. ;)
 
Top