PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Anschluss eines Displays am atmega



daywalker008
25.12.2008, 23:30
Hallo Leute ich hab hier ein Display von Pollin LCD-Modul TG12864B-03
Datenblatt: http://www.pollin.de/shop/downloads/D120424D.PDF

Dies wollte ich mit dem Beispielcode aus dem Bascom Studio ansteuern

'-----------------------------------------------------------------------------------------
'name : ks108.bas
'copyright : (c) 1995-2005, MCS Electronics
'purpose : demonstrates the KS108 based graphical display support
'micro : Mega323
'suited for demo : no
'commercial addon needed : no
'-----------------------------------------------------------------------------------------

$regfile = "m323def.dat" ' specify the used micro
$crystal = 8000000 ' used crystal frequency
$baud = 60000 ' use baud rate
$hwstack = 32 ' default use 32 for the hardware stack
$swstack = 10 ' default use 10 for the SW stack
$framesize = 40 ' default use 40 for the frame space


'some routines to control the display are in the glcdKS108.lib file
$lib "glcdKS108.lbX"


Wait 2

Print "Config" ' printing will still work as only the receiver pin is disabled


'First we define that we use a graphic LCD
Config Graphlcd = 128 * 64sed , Dataport = Porta , Controlport = Portc , Ce = 0 , Ce2 = 1 , Cd = 4 , Rd = 3 , Reset = 2 , Enable = 5

'The dataport is the portname that is connected to the data lines of the LCD
'The controlport is the portname which pins are used to control the lcd
'CE =CS1 Chip select
'CE2=CS2 Chip select second chip
'CD=Data/instruction
'RD=Read
'RESET = reset
'ENABLE= Chip Enable



'Dim variables (y not used)
Dim X As Byte , Y As Byte



Print "Cls"
Cls

Wait 1

'specify the font we want to use
Setfont Font8x8


'You can use locate but the columns have a range from 1-128
'When you want to show somthing on the LCD, use the LDAT command
'LCDAT Y , COL, value
Lcdat 1 , 1 , "123"

'lcdat accepts an additional param for inversing the text
Lcdat 2 , 1 , "123" , 1 ' will inverse the text

'Now use a different font
'Setfont Font8x8
'since the 16*16 font uses 2 rows, show on row 3
'Lcdat 1 , 1 , "2345"
'Lcdat 2 , 56 , "2345656"
Wait 1
Line(0 , 0) -(127 , 64) , 1 'make line
Wait 2
Line(0 , 0) -(127 , 64) , 0 'remove line

For Y = 1 To 20
Circle(30 , 30) , Y , 1
Waitms 100
Next

Wait 1
Glcdcmd &H3E , 1 : Glcdcmd &H3E , 2 ' both displays off
Wait 1
Glcdcmd &H3F , 1 : Glcdcmd &H3F , 2 'both on
'GLCDCMD accepts an additional param to select the chip
'With multiple, GLCDCMD statements, it is best to specify the chip only the first time


Showpic 0 , 0 , Plaatje 'show a comnpressed picture
End 'end program


'we need to include the font files
'Notice that this is a testfont with only numbers defined !
'$include "smallfont8x8.font"
$include "font8x8.font"
'$include "font16x16.font"


Plaatje:
'include the picture data
$bgf "ks108.bgf"

Nun meine FRage, wie muss ich das Display anschließen?

Mit Config Graphlcd = 128 * 64sed , Dataport = Porta , Controlport = Portc , Ce = 0 , Ce2 = 1 , Cd = 4 , Rd = 3 , Reset = 2 , Enable = 5

Komm ich nicht so richtig zurecht mit. Wo wird welcher Pin angeschlossen und brauch das Display nun 9V und/oder 5V und an welchen Pin. Hab das Diagramm nicht richtig verstanden und mit der Suche bin ich auch noch nicht zum Ziel gekommen.

Ich hab wie es in der Demo steht einen Atmega 32

Bitte helft mir.

linux_80
26.12.2008, 09:25
Moin,

suche anwerfen, und zB. das hier finden:
https://www.roboternetz.de/phpBB2/zeigebeitrag.php?t=32778&highlight=tg12864b

daywalker008
26.12.2008, 09:49
Da kommt gleich die nächste Frage auf.
Wo bitte ist Pin 0 und was ist RET ?

'KS0108 TG12864B
' Pin - LCD - Bascom
' 0 - CS1 - Ce
' 1 - nc
' 2 - D/I (A0) - Cd
' 3 - CS2 - Ce2
' 4 - Enable - Enable
' 5 - R/W - Rd
' 6 - RET - Reset

E wird enable sein
und welche Leitungen sind Dataports und welche Controlport?

Und bekommt das Display nun auf Vss 9V oder 5V?

Dirk
26.12.2008, 16:24
Hallo daywalker008,

also, ich kenne das Display nicht. Vorschlag zum Anschluß:
VSS -> GND (Minuspol, Pin 1)
VDD -> +5V
V0 -> Abgriff eines Potis zur Helligkeitsregelung (Datenblatt!)
D/I -> Cd
R/W -> Rd
E -> Enable
DB0..DB7 -> Datenport
CS1 -> Ce
CS2 -> Ce2
/RST -> Reset
VEE -> Poti zur Helligkeitsregelung (s.o. V0)
K -> Kathode der Hintergrundbeleuchtungs-LED (-)
A -> Anode der Hintergrundbeleuchtungs-LED (+)

Achtung: Hintergrundbeleuchtung nur über Vorwiderstand anschließen!

Gruß Dirk

daywalker008
26.12.2008, 16:28
also bis hier hin bin ich gekommen:

'KS0108 TG12864B
' Pin LCD - Pin Atmega
' 1 Vss 9V oder 5V
' 2 VDD 5V?
' 3 V0 GND
' 4 D/I
' 5 R/W Port C0
' 6 E Enable also 5V?
' 7 DB0 Port A0
' 8 DB1 Port A1
' 9 DB2 Port A2
'10 DB3 Port A3
'11 DB4 Port A4
'12 DB5 Port A5
'13 DB6 Port A6
'14 DB7 Port A7
'15 CS1
'16 CS2
'17 RST Reset?
'18 VEE Kontrast?
'19 K LED - also GND
'20 A LED + also 5V

Abgeschaut von hier : https://www.roboternetz.de/wissen/index.php/LCD-Modul_am_AVR

Aber es gibt noch ein paar Lücken , wo ich nicht weiß wie ich die verbleibenden Pins anschließen soll.

daywalker008
26.12.2008, 16:50
irgendwie steht im DB das Vss an GNd kommt?

daywalker008
26.12.2008, 18:27
Dirk war schneller

daywalker008
26.12.2008, 19:10
hm Also hab das Display jetzt so angeschlossen wie Dirk es gesagt hat, jetzt seh ich auch die Pixel im Display und die Beleuchtung funktioniert, es wird aber nichts gemacht, also es sollten ja eigentlich Linien gemacht werden und ein Bild gezeichnet aber das Display bleibt leer.
Ist da was am Code falsch?

Liegt es vielleicht an der Libfile "glcdKS108.lbX", da ich ja ne LBX draus gemacht hab, da ich keine lib habe

daywalker008
26.12.2008, 20:45
also bei Pollin steht, dass das Display 9V Kontrastspannung hat muss ich da nun an VDD 9V anlegen ???
Ich will das Display nicht kaputt machen.
Bis jetzt seh ich nur einen blauen Rand mit weißen Pixeln.

daywalker008
26.12.2008, 21:01
In nem anderen Thrad steht das das Display die 9V selbst erzeugt.
hm, vielleicht ist ja der Fehler am Poti???
Ist folgendermaßen angeschlossen: am linken Anschluss V0 am mittelanschluss VEE und noch ein 8,5 K Widerstand da ich nur ein 5K Poti habe
Stimmt das so?

AUnruh
26.12.2008, 21:27
In nem anderen Thrad steht das das Display die 9V selbst erzeugt.
hm, vielleicht ist ja der Fehler am Poti???
Ist folgendermaßen angeschlossen: am linken Anschluss V0 am mittelanschluss VEE und noch ein 8,5 K Widerstand da ich nur ein 5K Poti habe
Stimmt das so?

Hi.

Auf der ersten Seiten im Datenblatt unter Power supply steht wie das Poti anzuschließen ist. Wenn Du VEE an der Mitte, also am Schleifer, hast ist das definitiv falsch. Schau Dir das Datenblatt nochmal genauer an.

Viel Erfolg.

Gruß // André

daywalker008
26.12.2008, 21:38
also schließe ich am Mttelanschluss V0 und an den anderen beiden VDD und VEE???

daywalker008
27.12.2008, 00:30
So ich habe jetzt diesen Code mit dem es funktioniert:

$regfile = "M32def.dat" 'Atmega 32
$crystal = 6000000 ' 6 MHz
$baud = 9600 'Baudrate der RS232 Schnittstelle
$hwstack = 150
$swstack = 120
$framesize = 150

$lib "KS108.LBX"
$include "Font8x8.font"



' Disable JTAG interface
Dim Bz As Byte
Bz = Mcucsr 'READ VALUE OF &H34
Bz = Bz Or &H80












'SET UPPER BIT
Mcucsr = Bz 'WRITE TWICE TO DISABLE JTAG
Mcucsr = Bz
'for Glcd Ks108
Config Graphlcd = 128 * 64sed , Dataport = Portb , Controlport = Portc , Ce = 3 , Ce2 = 2 , Reset = 4 , Rd = 5 , Cd = 6 , Enable = 7 ', Mode = 6


'The dataport is the portname that is connected to the data lines of the LCD
'The controlport is the portname which pins are used to control the lcd
'CE = CS1 Chip select
'CE2 = CS2 Chip select second chip
'CD = DI Data/instruction
'RD = R/W Read/Write
'RESET = RST reset
'ENABLE = E Chip Enable
do
Cls
Wait 2
Setfont Font8x8
Lcdat 1 , 3 , "SETUP MENU "
Lcdat 3 , 3 , "Wait ....."
Wait 5

loop
End
Allerdings gibt es noch ein paar Probleme wie man auf dem Display erkennen kann wird der Text nicht richtig angezeigt und die Fehler wandern langsam pber das Display woran kann das liegen?



http://www.pretty-kunze.de/html/display2.JPG

AUnruh
27.12.2008, 01:02
Moin.

Also mit dem Wandern - keine Ahnung. Die Pixelfehler könnten evtl. ein schlechter Kontakt zwischen der Platine und dem Displayglas sein. Evtl. sind Deine Anschlusskabel zu lang - meine Erfahrungen max. 15cm.

Aber probier mal:



$regfile = "M32def.dat" 'Atmega 32
$crystal = 6000000 ' 6 MHz
$baud = 9600 'Baudrate der RS232 Schnittstelle
$hwstack = 150
$swstack = 120
$framesize = 150

$lib "glcdKS108.lib"

Wait 2

'for Glcd Ks108
Config Graphlcd = 128 * 64sed , Dataport = Portb , Controlport = Portc , _
Ce = 3 , Ce2 = 2 , Reset = 4 , Rd = 5 , Cd = 6 , Enable = 7


' Disable JTAG interface
Dim Bz As Byte
Bz = Mcucsr 'READ VALUE OF &H34
Bz = Bz Or &H80

'SET UPPER BIT
Mcucsr = Bz 'WRITE TWICE TO DISABLE JTAG
Mcucsr = Bz


'The dataport is the portname that is connected to the data lines of the LCD
'The controlport is the portname which pins are used to control the lcd
'CE = CS1 Chip select
'CE2 = CS2 Chip select second chip
'CD = DI Data/instruction
'RD = R/W Read/Write
'RESET = RST reset
'ENABLE = E Chip Enable

Cls
Setfont Font8x8

do
Wait 2
Lcdat 1 , 3 , "SETUP MENU "
Lcdat 3 , 3 , "Wait ....."
Wait 5
Cls
Loop

End

$include "Font8x8.font"


Zum Compilieren der LBX einfach STRG+I dann die glcdKS108 auswählen und compile drücken.

Gruss // André

daywalker008
27.12.2008, 10:12
Also hab Ce und CE2 getauscht, jetzt stehen die Wörter auch links wie es sein soll.
Die Pixelfehler werden ein timingproblem sein.
Welche Fuses aktivieren den internen Taktgeber???
Ich hab zwar einen externen Quarz mit Namen YICI6000I7 (also 6Mhz??) glaub ich .
Aber weis nicht ob er aktiviert ist weil ich nicht weis wie ichs genau einstelle mit den Fuses. (Weis nicht obs ein Quarz oder ein Oszilator ist).