I just found this lying around in My Documents of an old PC:
It's old and not cleaned up, but at least it's a start.Code:'--------------------------------------------------------------------' ' Author: Demon ' ' Date: April 7th, 2006 ' ' ' Language: PIC Basic Pro v2.46 ' ' MPU: PIC 16F877 20/P from MicroChip ' ' IDE: MicroCode Studio Plus from Mecanique v2.2.1.1 ' ' Programmer: MeLabs Serial Programmer v3.12 (firmware v3.4) ' ' LCD: LCM3202401 from QingYun-IT ' ' ' ' All rights reserved. ' ' ' ' Use of parts of code is permitted as long as credit is given ' ' to the author. Code may or may not be Year 3000 proof. Use ' ' at your own risk. ' '--------------------------------------------------------------------' 'define LOADER_USED 1 clear ADCON1 = 7 ASM @ DEVICE PIC16F877, HS_OSC, WDT_OFF, PWRT_ON, BOD_ON, LVP_OFF, CPD_OFF, WRT_OFF, DEBUG_OFF, PROTECT_OFF ENDASM DEFINE OSC 20 pinData var PORTD pinWR var PORTB.0 pinRD var PORTB.1 pinCS var PORTB.2 pinA0 var PORTB.4 pinRST var PORTB.5 pinLED VAR PORTB.3 pinSCL VAR PORTC.3 pinSDA VAR PORTC.4 TRISD = 0 TRISB.0 = 0 TRISB.1 = 0 TRISB.2 = 0 TRISB.4 = 0 TRISB.5 = 0 TRISB.3 = 0 conSet con $40 conScroll con $44 conCursorForm con $5d conCursorAddress con $46 conCursorRight con $4c conOverlay con $5b conWrite con $42 conDisplayON con $59 conDisplayOFF con $58 conCharPerLine con $28 ' 40 characters / line varCommand Var BYTE varCursor var BYTE varByte var BYTE varLoop1 var BYTE varLoop2 var BYTE varAddress var WORD pinRD = 1 pinWR = 1 pinCS = 0 pinRST = 0 pause 1 pinRST = 1 pause 100 goto main ' --------------------------- Subroutines -------------------------- 'INCLUDE "SED1335 subroutines.pbp" SendData: pinA0 = 0 pinData = varByte pinWR = 0 ' @ nop pinWR = 1 return SendCommand: pinA0 = 1 pinData = varCommand pinWR = 0 ' @ nop pinWR = 1 return ClearGraphic: varCommand = conCursorAddress gosub SendCommand varByte = $00 gosub SendData varByte = $10 gosub SendData varCommand = conCursorRight gosub SendCommand varCommand = conWrite gosub SendCommand varByte = %00000000 ' 1 byte = 8 bits = 8 pixels wide for varLoop1 = 1 to 240 ' 240 pixels high for varLoop2 = 1 to 40 ' 40 bytes = 320 bits = 320 pixels wide gosub SendData next varLoop2 next varLoop1 return ClearText: varCommand = conCursorAddress gosub SendCommand varByte = $00 gosub SendData varByte = $00 gosub SendData varCommand = conCursorRight gosub SendCommand varCommand = conWrite gosub SendCommand varByte = " " for varLoop1 = 1 to 30 for varLoop2 = 1 to 40 gosub SendData next varLoop2 next varLoop1 return InitDisplay: varCommand = conSet gosub SendCommand for varLoop1 = 0 to 7 lookup varLoop1,[$32,$87,$07,$27,$2B,$EF,$28,$00],varByte gosub SendData next varLoop1 varCommand = conScroll gosub SendCommand for varLoop1 = 0 to 5 lookup varLoop1,[$00,$00,$EF,$00,$10,$EF],varByte gosub SendData next varLoop1 varCommand = conOverlay gosub SendCommand varByte = %00000001 gosub SendData varCommand =conDisplayOFF gosub SendCommand varByte = %00000000 gosub SendData gosub ClearText gosub ClearGraphic varCommand = conDisplayON gosub SendCommand varByte = %00010100 gosub SendData varCommand = conCursorAddress gosub SendCommand varByte = $0 gosub SendData varByte = $0 gosub SendData varCommand =conCursorForm gosub SendCommand varByte = $04 gosub SendData varByte = $86 gosub SendData return SetAddress: varCommand = conCursorAddress gosub SendCommand varByte = varAddress.BYTE0 gosub SendData varByte = varAddress.BYTE1 gosub SendData varCommand = varCursor gosub SendCommand varCommand = conWrite gosub SendCommand return ' --------------------------- Main program -------------------------- Main: gosub InitDisplay pinLED = 1 varAddress = 0 varCursor = conCursorRight gosub SetAddress for varLoop1 = 0 to 39 lookup varLoop1,[".. QINGYUN IT LCM-3202401 GRAPHIC LCD .."],varByte gosub SendData NEXT varLoop1 varAddress = 29 * conCharPerLine varCursor = conCursorRight gosub SetAddress for varLoop1 = 0 to 39 lookup varLoop1,["Demon was here! "],varByte gosub SendData NEXT varLoop1 end
Robert
EDIT: LOL Look what I found while looking at my attachments:
http://www.picbasic.co.uk/forum/showthread.php?t=3811
Last edited by Demon; - 4th October 2016 at 16:28.
Robert, thanks for the code. It does look like a good starting point, clean, simple. I have a GLCD on the way from EgoChina which uses a S1D13700 controller. ($75) My first purchase of a GLCD, which means it looks like it has everything needed on the board. (I hope) I’m just figuring out the details of how to set it up. I’ll start with a code format following your example.
Thanks again,
Wayne
Do you know that uneasy felling in the pit of your stomach when you’re about to put voltage on an expensive piece of equipment and you’re NOT 100% sure "this is the right way to do it"? You realize that you may be moments away from filling the workshop with a cloud of green (the color of money) smoke! You also know that if you don’t do this you will never know if it works because, it’s not going to start by itself… OR, you can first consult the guys at MEL PICBASIC Forum and perhaps someone may be able to guide you through the mine fields. If you still go up in smoke you may be able to find one sympathetic soul somewhere on the face of the glob that will share your pain, NOT likely, BUT perhaps someone else will learn some small lesson from the experience of your smoldering carcass…
My new GLCD from china, of course has very little documentation. It is not clear how to handle the LED’s or Vo. Vee is at -23V. The data sheet says:
Vdd-Vss 4.75-5.25V
Vdd-Vo 4.5V to 30V
I am (almost) sure a 10K pot between Vee (-23V) and Vo should make it work. I am not sure about the LED’s. In fact I can’t find out the difference in function between the LEDA and LEDK or why the one page data sheet shows a resistor between a back light block and LEDA while there is no resistor for LEDK. ANY INPUT WILL BE APPRECIATED !
Using an 18F45K22 at 16Mhz internal, JHD639 320240 GLCD w/D1370002A1 controller , my code is almost done. I have followed Robert’s SED1335 example, thanks Robert, as the coding is very close for each controller though the 137000 seems to be a bit more involved.
Wayne
FINALLY! Something I know.
LEDA = led anode
LEDK = led cathode
About that Vo stuff, gonna have to go through your datasheet first.
It can't be worse than the single page of Chinese I once got. LOLMy new GLCD from china, of course has very little documentation.
Robert
Last edited by Demon; - 26th February 2012 at 07:44.
This is for the D13700F01, but it might help you. I got it here, tons of datasheets under S1D13700*
http://www.datasheetking.com
This is how I got somewhere with several of these poorly documented LCDs. When I had nothing I'd go through controllers with similar names and find one with similar specs.
When in doubt, don't go over 5 volts (and maybe 3 volts with these newer models). At worst, it won't work.
Usually, the variable voltage is for contrast or brightness. That's why I bought a selection of potentiometers; start high and work my way down until "something happens".
Robert
Page 14, 5.1 pinout:JHD639 320240 GLCD w/D1370002A1 controller
Look at what's engraved on the IC. I'm guessing D1370002A1 is a newer version of the exact same thing, or at least REALLY darn close to it in terms of features and operation.
Robert
![]()
Another thing I often do is google for the component with different keywords like: D13700 TUTORIAL/SCHEMATIC/DIAGRAM, etc.
Sometimes you get something from another technology and can't use much of the code, but you can check out the wiring for ideas:
http://www.cafelogic.com/download/s1...documentation/
And even then, you can sometimes get ideas about the initialization commands when the language is "readable" or the program is well commented.
I'd start with pots on R1 and R2.
Robert
![]()
Thanks Robert for your comments. Yep, I've looked at evey piece of document I can find and the microelektronika schematic is the only thing I can find to give me any idea of what to do with Vo, and of course they are not using the same GLCD so its just a roll of the dice and hope for the best.
The attatched datasheet shows the Negative Voltage Generator at the bottom right of the page. notice V0 is an input to the NVG. So, Robert, do you think V0 is a Ground reference for the NVG. If we look at the easypic_v7 data sheet, microelektronika takes Vo to a 10k pot to the NVG, which of course will bring Vo bellow Vss. I think I will start with the 10k pot to ground and if the contrast is not great enough I tie the pot to NVG. I will use your advise on how to handle the LED's. Are you using only a 15 ohm resistor on LEDA?
CN2 GLCD uses 20 pin FFC cable
Pin function description My Action
1. VSS GND GND
2. VDD Logic Power input +5V
3. VO LCD contrast control POT 4kohm
4. AO Command / Data Select U1.RA.7
5. /WR 8080: Data Write U1.RC.0
6. /RD 8080: Data Read U1.RC.1
7. DO Data buss line0 U1.RD.0
8. D1 Data buss line1 U1.RD.1
9. D2 Data buss line2 U1.RD.2
10. D3 Data buss ilne3 U1.RD.3
11. D4 Data buss line4 U1.RD.4
12. D5 Data buss line5 U1.RD.5
13. D6 Data buss line6 U1.RD.6
14. D7 Data buss line7 U1.RD.7
15. /CS LCD Controller function Reset U1.RC.3
17. VEE Negative voltage output (-23V) ???
18. SEL1 SEL1=L, 8080 interface; GND
19. FGND Front Panel Ground GND
20. NC
CN3 LED wiring
21. LEDA Power for led Backlight(A) POT_500 ohm to Vcc
22. LEDK Power for led Backlight(K) GND
Thanks Again Robert!
Wayne
Bookmarks