'-------------------------------------------------------------------------------' $regfile = "m16def.dat" $crystal = 8000000 $baud = 19200 $hwstack = 32 $swstack = 8 $framesize = 24 '-------------------------------------------------------------------------------' Dim Index As Byte Dim Value(4) As Byte Dim Average As Word Dim Count As Byte Dim Phi_v_sum As Word Dim Phi_v_current As Word Dim Phi_v_mean As Word Dim Adc_wert As Word Dim Mittelwert_adc As Word Config Adc = Free , Prescaler = Auto , Reference = Aref Start Adc Index = 1 Average = 0 Do Phi_v_sum = 0 For A = 1 To 1 Phi_v_current = Getadc(0) Phi_v_sum = Phi_v_sum + Phi_v_current Next '-------------------------------------------------------------------------------' 'Bandpassfilter: ADC '-------------------------------------------------------------------------------' Phi_v_mean = Phi_v_sum / 1 If Phi_v_mean < 527 And Phi_v_mean > 517 Then Phi_v_mean = 520 Else Phi_v_mean = Phi_v_mean End If '-------------------------------------------------------------------------------' 'Glaettungsfilter: ADC-Wert [] '-------------------------------------------------------------------------------' Value(index) = Phi_v_mean Incr Index If Index = 5 Then Index = 1 End If For Count = 1 To 4 Average = Average + Value(count) Next Shift Average , Right , 2 '-------------------------------------------------------------------------------' 'Printbefehle: '-------------------------------------------------------------------------------' Adc_wert = Phi_v_mean Mittelwert_adc = Average Print "adc" ; Adc_wert Print "adc^" ; Mittelwert_adc Waitms 100 Loop End