Code:$regfile = "m16def.dat" $crystal = 7372800 Dim A As Byte Dim B As Byte Dim C As Byte Dim Comfeld(12) As Byte Dim X As Double Dim Y As Integer Dim Z As Integer Dim W As Byte Dim K As Byte Dim M As Double Dim N As Double Dim Auflosung As Integer Dim Xstart As Integer Dim Ystart As Integer Dim Zstart As Integer Dim Xziel As Integer Dim Yziel As Integer Dim Zziel As Integer Dim Zwischenwert1 As Double Dim Zwischenwert2 As Double Dim Zwischenwert3 As Double Dim Zwischenwert4 As Double Dim Zwischenwert5 As Double Dim Zwischenwert6 As Double Dim Aa As Single Dim Bb As Single Dim Xzwischenziel As Integer Dim Yzwischenziel As Integer Dim Zzwischenziel As Integer Dim Realposx As Integer Dim Realposy As Integer Dim Realposz As Integer Dim Stposx As Integer Dim Stposy As Integer Dim Stposz As Integer Dim Motoraus As Long Dim Absx As Integer Dim Absy As Integer Dim Absz As Integer Dim Pc1alt As Byte Dim Pc0alt As Byte Dim F0 As Bit Dim F1 As Bit : Dim F2 As Bit : Dim F3 As Bit : Dim F4 As Bit Dim F5 As Bit : Dim F6 As Bit : Dim F7 As Bit : Dim F8 As Bit Auflosung = 2 Config Porta = Output Config Portd = Input 'Config Portd.6 = Output Config Portc = Input Config Portb.1 = Input Config Portb.0 = Output Realposx = 1 Realposy = 1 Realposz = 1 'Enable Xziel = 500 Yziel = 50 Porta = 255 Portc = 255 Stposx = 1 'Realposx Stposy = 1 'Realposy Stposz = 1 'Realposz For Aa = 0 To 1 Step 0.2 Bb = Aa - 2 Zwischenwert1 = Stposx * Bb Zwischenwert2 = Xziel * Aa Zwischenwert3 = Stposy * Bb Zwischenwert4 = Yziel * Aa Zwischenwert5 = Zwischenwert2 - Zwischenwert1 'zwischen punkt erechnungs zeug Zwischenwert6 = zwischenwert4 - Zwischenwert3 X = Zwischenwert5 / 2 'realpos damit ich immer vom wirklichen wert ausgehe und der fehler nicht größer wird Y = Zwischenwert6 / 2 ' x= realpos-x 'X = 50.5 Motoraus = 0 If X = 0 Then : Porta.0 = 0 : Else : Porta.0 = 1 : End If Do If Pinc.0 = 0 Then Pc0alt = 1 If Pinc.0 = 1 And Pc0alt = 1 Then : Pc0alt = 0 : X = X + 1 : Realposx = Realposx + 1 : End If 'pos holen If Pinc.1 = 0 Then Pc1alt = 1 If Pinc.1 = 1 And Pc1alt = 1 Then : Pc1alt = 0 : X = X - 1 : Realposx = Realposx -1 : End If 'pos holen If X = 0 Then : Porta.1 = 0 : Else : Porta.1 = 1 : End If Absx = Abs(x) If X > 0 Then : Porta.4 = 0 : Porta.5 = 1 : Waitus 50 : End If 'Pos anfahren If X < 0 Then : Porta.4 = 1 : Porta.5 = 0 : Waitus 50 : End If 'pos anfahre If Absx < 15 Then : Porta.4 = 0 : Porta.5 = 0 : End If If X = 0 Then Motoraus = Motoraus + 1 Loop 'Until Motoraus = 9000 Next Aa Do Loop
If X = 0 Then : Porta.0 = 0 : Else : Porta.0 = 1 : End If
Daran sehe ich das x=0 ist nagut noch bissel zur funktion es wird mal ne steuerung für ne fräsmaschiene die xzielund yziel .. wird über RS232 gesendet und dann soll die pos angefahren es werden normale lego motoren verwendet und die zwischen punkt erechnung funktioniert halt nich nur in vb
Lesezeichen