LCD-EA dogm 163V5

ATMega-Controller in BASIC programmieren

Postby julimodell » Sat May 05, 2012 12:00 am

Hallo Leute, ichhabe den Kompass aus September 11 nachgebaut. Da ein Kompass normalerweise outdoors benutzt wird ist das mit dem ATM18-Board etwas umstaendlich, abgesehen davon hatdas dor verwendete Display einen eisernen Metallrahmen , der zu ganz erheblichen Fehlern fuehrt. umgestellt auf eine eigene Platine zunaechst mit, spaeter ohne 4094. Der AT Mega 88 hat ja genug
Ports fuer dieses Projekt. LCD-Typ EA Dogm 163V5 voellig ohne eisenhaltige Metalle. Das Problem ist im Fall ohne 4094 die Kontrast einstellung. Die von MCS Electronic angezeigte Methode ueber
Contrast = &H702 aus der Hilfedatei hat nicht geholfen(fuer eine Bytevariable wohl zu gross, Druckfehler ?). Wer kann mir helfen den Kontrast beim EA Dogm zu veraendern? Schon mal besten Dank
Jensulrich Lummerzheim(Julimodell)
julimodell
 
Posts: 46
Joined: Fri Jan 03, 2014 1:49 pm

Postby thomas scherer » Sat Jul 07, 2012 12:00 am

Angeblich soll dieser Code funktionieren, kannst Du ja mal ausprobieren.

$regfile = "m8def.dat"$crystal = 1000000 ' 1MHz (You can use any clock).$hwstack = 32$swstack = 16$framesize = 40Declare Sub SetContrast5V4bit(Byval Contrast_value As Byte)Dim Lcd_contrast As ByteConfig Lcdpin = Pin , Db4 = PortC.0 , Db5 = PortC.1 , Db6 = PortC.2 , Db7 = PortC.3 , E = PortC.4 , Rs = PortC.5Config Lcd = 16 * 2 , Chipset = Dogm162v5Cursor Off NoblinkClsLCD "Contrast 0-63"Waitms 2000For Lcd_contrast = 0 to 63   Call SetContrast5V4bit(Lcd_contrast)   ' You can also use a constant, example, Call SetContrast5V4bit(10)   Cls   LCD "Contrast: " ; Lcd_contrast   Waitms 2000Next Lcd_contrastDo   !nopLoopEnd' =============================================Sub SetContrast5V4bit(Byval Contrast_value As Byte)   ' This subroutine will set the contrast of an LCD module EA DOGM162.   ' The LCD module MUST be connected to 5V and use the 4-bit mode.   ' This code works with the pins specified in "Config Lcdpin". If you   ' change the pins in "Config Lcdpin", this code will still work because   ' we use the Bascom internal routine to send the command to the LCD.   ' The LCD contrast is a value between 0 and 63. The value passed to   ' this subroutine is a byte. If the passed value is greater than 63,   ' the passed value will be limited to 63. Note also that it is very   ' likely that only a limited range of the 64 possible values will   ' produce a valid contrast setting on the LCD, so your main program   ' will have to limit the used minimum and maximum values.   '   ' Do not use this subroutine if the LCD is connected to 3.3V!   ' This code disables the internal voltage booster which must be used   ' when the LCD is connected to 3.3V.   Local Ins_P_I_Contr_set As Byte   Local Ins_Contr_Set As Byte   If Contrast_value > 63 Then      Contrast_value = 63       ' We limit the value to 63   Endif   ' The 6 bits of the contrast value are sent to the Sitronix   ' ST7036 controller chip with two distinct instructions.   ' First the passed contrast value will be mapped into two bytes.   ' The upper nibble of the byte is used to define the instruction.   ' The lower nibble of the byte is used for the parameters of the   ' instruction. The contrast value will be mapped into the lower   ' nibble of these two bytes.   '==========================================   ' Map C3, C2, C1, C0 into the instruction "Contrast Set".   Ins_Contr_Set = Contrast_value   ' Clear the upper nibble, keep C3, C2, C1 and C0 into the lower nibble.   Ins_Contr_Set = Ins_Contr_Set AND &B00001111 'Clear upper nibble   ' Add the value C3, C2, C1 and C0 to the instruction value.   Ins_Contr_Set = Ins_Contr_Set + &B01110000   '==========================================   ' Map C5 and C4 into the instruction "Power/ICON control/Contrast Set".   Ins_P_I_Contr_set = Contrast_value   'Shift Right four times, so that C5 C4 will go in position Bit1 and Bit0.   'Bit7, Bit6, Bit5, Bit4, Bit3, Bit2 will be 0 after the shift operations.   Shift Ins_P_I_Contr_set , Right , 4   ' Add the value C5 and C4 to the instruction value.   Ins_P_I_Contr_set = Ins_P_I_Contr_set + &B01010000   '                                             ^---- 0=ICON Off   '                                              ^--- 0=Booster Off (5V)!   '==========================================   ' Now we send 4 instructions to the LCD   '==========================================   _temp1 = &B00101001 'Instruction "Function Set" select instruction table 1   '-------------^------------ = DL (Interface 8/4 bits). 0=4-bit interface.   '--------------^----------- = N (Number of lines). 1=two lines. Must be 1   '---------------^---------- = DH (Double height font). 1=DH. Must be 0   '----------------^--------- = IS2 (Instruction table select). Must be 0   '-----------------^-------- = IS1 (Instruction table select). Must be 1   !rCall _Lcd_control ' Send the instruction to the LCD   '==========================================   _temp1 = Ins_Contr_Set  ' Instruction "Contrast Set"   !rCall _Lcd_control ' Send the instruction to the LCD   '==========================================   _temp1 = Ins_P_I_Contr_set ' Instruction "Power/ICON/Contrast Set"   !rCall _Lcd_control ' Send the instruction to the LCD   '==========================================   _temp1 = &B00101000 'Instruction "Function Set" select instruction table 0   '-------------^------------ = DL (Interface 8/4 bits). 0=4-bit interface.   '--------------^----------- = N (Number of lines). 1=two lines. Must be 1   '---------------^---------- = DH (Double height font). 1=DH. Must be 0   '----------------^--------- = IS2 (Instruction table select). Must be 0   '-----------------^-------- = IS1 (Instruction table select). Must be 0   !rCall _Lcd_control ' Send the instruction to the LCD   '==========================================End Sub' -------
thomas scherer
 
Posts: 1128
Joined: Thu Jan 02, 2014 10:38 am


Return to BASCOM-AVR-Kurs

Who is online

Users browsing this forum: No registered users and 1 guest