Hey Strecke aufgebaut, tut sich zwar auch was, aber irgendwie noch nicht das richtige. Irgendwie macht der DA-Wandler wieder Ärger und spukt nur 5V aus. Nun ja morgen ist auch noch ein Tag.
Anbei mal der Code, vielleicht hab ich da jetzt auf die Schnelle auch noch ein Bug reingebaut:
So morgen geht es weiter!Code:$regfile = "m8def.dat" $crystal = 8000000 $baud = 9600 Dim Y As Single Dim Y1 As Single Dim Yaus As Integer Dim Xj0 As Single Dim Xj1 As Single Dim Xj2 As Single Dim M0 As Single Dim M1 As Single Dim M2 As Single Dim Ist As Integer Dim Soll As Integer Dim A As Single Dim B As Integer Const Q0 = 13.01 Const Q1 = -25.5 Const Q2 = 12.5 Config Portb = Output Config Timer1 = Timer , Prescale = 8 Enable Interrupts On Timer1 Zeit Config Adc = Single , Prescaler = Auto , Reference = Off Config Pinc.0 = Input 'Istwert Config Pinc.1 = Input 'Sollwert Portc.0 = 1 Portc.0 = 1 Start Adc Xj0 = 0 Xj1 = 0 Xj2 = 0 Y = 0 Timer1 = 55536 Enable Timer1 Portb. = 0 Waitms 1000 Sound Portb.0 , 400 , 450 Do Ist = Getadc(0) Soll = Getadc(1) Loop Zeit: Timer1 = 55536 Xj0 = Ist - Soll Xj0 = Xj0 / 1023 M0 = Q0 * Xj0 M1 = Q1 * Xj1 M2 = Q2 * Xj2 Y = Y1 + M0 Y = Y + M1 Y = Y + M2 'Print Y Yaus = Y + 128 If Yaus < 1 Then Yaus = 0 Elseif Yaus > 254 Then Yaus = 255 End If Print Yaus Portb. = Yaus Xj2 = Xj1 Xj1 = Xj0 Y1 = Y Y = 0 Return
Gruß Johann!







Zitieren

Lesezeichen