'#################################################################### ' Einfaches Osziloskop ' by (c) Dirk Milewski ' 20.08.2006 ' www.comwebnet.de '#################################################################### ' Display T6369 128x128px ' Verbesserungen oder melden von Fehlern dm@comwebnet.de '#################################################################### ' Problem: ' 1. Messungen >0,7ms (Timebase) Messung von 0,1ms bis 0,7ms-OK ' 2. Schaltung zur Wechselspgmessung ' '#################################################################### ' ToDo: '1. Automatischer Grafischer Spannungbereich Darstellung '2. Wechselspgmessung '3. Einfacher Logikanalyserer '#################################################################### 'Co Author: 'Making: 'Date : '#################################################################### 'Version: 0.1 - 20.08.2006 '#################################################################### ' Hardware: GLCD: Toschbiba TLX-1391 128 x 128 pixel ' Mega32 - 16MHz ' Stromversorung: +5V und Display -21V für Kontrast '#################################################################### $crystal = 16000000 $regfile = "m32def.dat" ' 1Kanal Oszi 'First we define that we use a graphic LCD ' Only 240*64 supported yet 'The dataport is the portname that is connected to the data lines of the LCD Config Graphlcd = 128 * 128 , Dataport = Portc , Controlport = Portd , Ce = 4 , Cd = 5 , Wr = 2 , Rd = 3 , Reset = 6 , Fs = 7 , Mode = 6 'The controlport is the portname which pins are used to control the lcd 'CE, CD etc. are the pin number of the CONTROLPORT. ' For example CE =2 because it is connected to PORTC.2 'mode 8 gives 240 / 8 = 30 columns , mode=6 gives 240 / 6 = 40 columns 'Dim variables (y not used) Dim X1 As Byte , Y1 As Byte , Z As Integer Dim X2 As Byte , Y2 As Byte Dim D As Byte , E As Integer , F As Integer Dim W As String * 2 Dim V(770) As Word Dim U As Word Dim Umess As Single Dim Tmp As String * 10 Dim Ypx As Byte Dim Timeb As Byte Dim Menu_a(7) As String * 10 Dim Menu_b(20) As String * 10 Const Aref = 5 Const N = Aref / 1024 Config Pina.2 = Input Porta.2 = 1 Kup Alias Pina.2 Config Pina.3 = Input Porta.3 = 1 Kdown Alias Pina.3 Config Pina.4 = Input Porta.4 = 1 Kright Alias Pina.4 Config Pina.5 = Input Porta.5 = 1 Kleft Alias Pina.5 Config Pina.6 = Input Porta.6 = 1 Kenter Alias Pina.6 Config Pina.7 = Input Porta.7 = 1 Kstart Alias Pina.7 Config Adc = Single , Prescaler = Auto , Reference = Internal ' Erstellen eines Menu Menu_b(1) = " 0,1ms" Menu_b(2) = " 0,2ms" Menu_b(3) = " 0,3ms" Menu_b(4) = " 0,4ms" Menu_b(5) = " 0,5ms" Menu_b(6) = " 0,6ms" Menu_b(7) = " 0,7ms" Cursor Off Cls Timeb = 1 Locate 4 , 3 Lcd "Osziloskop" Locate 6 , 3 Lcd "by Dirk Milewski" Locate 8 , 5 Lcd "20.08.2006" Locate 14 , 2 Lcd "www.comwebnet.de" Wait 2 Cls Do Gosub Gleichspg Start Adc For Z = 1 To 660 U = Getadc(0) V(z) = U Next Stop Adc X1 = 20 U = V(1) Umess = U * N Umess = Umess / Aref Umess = Umess * 100 E = Int(umess) Y1 = 100 - E 'Ausgabe der Messung For Z = 2 To 110 If Kup = 0 Then Waitms 200 Timeb = Timeb + 1 End If If Timeb > 7 Then Timeb = 1 F = Z * Timeb U = V(f) Umess = U * N Umess = Umess / Aref Umess = Umess * 100 E = Int(umess) Umess = U * N Y2 = 100 - E X2 = Z + 16 If X2 > 127 Then X2 = 128 Locate 14 , 1 Lcd "D/V:0,5 " Locate 14 , 10 Lcd " D/T:" ; Menu_b(timeb) D = X1 + 1 Line(d , 0 ) -(d , 99) , 0 Line(x1 , Y1) -(x2 , Y2) , 255 X1 = X2 Y1 = Y2 Locate 16 , 2 Tmp = Fusing(umess , "#.##") Lcd Tmp Next Loop End 'der Messrahmen Gleichspg: Line(18 , 1) -(18 , 100) , 255 Line(16 , 100) -(120 , 100) , 255 For Z = 1 To 100 Step 10 Line(16 , Z) -(20 , Z) , 255 Next For Z = 18 To 120 Step 10 Line(z , 98) -(z , 102) , 255 Next Locate 1 , 1 Lcd "+5V" Locate 13 , 1 Lcd " 0V" Return