Das Open-Control-Projekt - Die Alternative zur C-Control-I


Das Forum zur C-Control-1
Welche C-Control-Varianten existieren?
Übersicht - Suchen - Neueste 50 Beiträge - Neuer Beitrag - Login - Registrieren
INFO - FAQ - CC2-Forum - CCPro-Forum 

 Re: Vergleich/Gleichsetzung von Variablen Kategorie: Programmierung Basic (von ManfredW, Homepage - 28.12.2005 21:38)
 Als Antwort auf Re: Vergleich/Gleichsetzung von Variablen von Butcher - 28.12.2005 15:26
>
> solla = winkelangabe*85         'Berechnung der Toleranz
> sollb = solla -200
> sollc = solla -400
>
> sollz = winkelangabe*85
> solly = sollz + 200
> sollx = sollz + 400
>
>
> #loop                                         ' Schleife
>
> if sollz > PotiWert*100 THEN K2 = off
> if sollx > PotiWert*100 THEN K2 = off
> if solly > PotiWert*100 THEN K2 = off
> if sollz > PotiWert*100 then K1 = on
> if solly > PotiWert*100 then K1 = on
> if sollx > PotiWert*100 then K1 = on
>
> if solla < PotiWert*100 then K1 = off  ' folgende 6 Zeilen: Winkel kleiner als Poti
> if sollb < PotiWert*100 then K1 = off
> if sollc < PotiWert*100 then K1 = off
> if solla < PotiWert*100 then K2 = on
> if sollb < PotiWert*100 then K2 = on
> if sollc < PotiWert*100 then K2 = on
>
> if sollc = PotiWert*100 then K2 = off  'Annäherung von unten
> if sollb = PotiWert*100 then K2 = off
> if solla = PotiWert*100 then K2 = off
> if sollc = PotiWert*100 then K1 = off  'Annäherung von unten
> if sollb = PotiWert*100 then K1 = off
> if solla = PotiWert*100 then K1 = off
>
>
> if sollz = PotiWert*100 then K1 = off  'Annäherung von oben
> if solly = PotiWert*100 then K1 = off
> if sollx = PotiWert*100 then K1 = off
> if sollz = PotiWert*100 then K2 = off  'Annäherung von oben
> if solly = PotiWert*100 then K2 = off
> if sollx = PotiWert*100 then K2 = off
>
> if winkelangabe*85 = PotiWert*100 then K1 = off
> if winkelangabe*85 = PotiWert*100 then end
>
> goto loop

Hallo,
die if-Abfragen kannst Du einfacher und übersichtlicher machen.

if soll.. > Potiwert... then goto RichtungLinks
if soll.. < Potiwert... then goto RichtungRechts

' nun bleibt nur noch gleich übrig, also ohne if-Abfrage Drehen aus
K1 = OFF : K2 = OFF : goto Ende
#RichtungLinks
K1 = ON : K2 = OFF : goto Ende
#RichtungRechts
K1 = OFF : K2 = ON : goto Ende

Das Prinzip dieser Struktur besteht darin, dass das Relais nur an einer Stelle eingeschaltet wird.
So vermeidet man wesentlich "Relais klappern" bei Programmfehlern.
Interessant wird für Dich mein Programm Ventil AUF-Halt-ZU auf meiner homepage sein.
MfG ManfredW

Meine Homepage: http://manfred.wilzeck.de

 Antwort schreiben

Bisherige Antworten:

Re: Vergleich/Gleichsetzung von Variablen (von Butcher - 30.12.2005 10:58)
    Tote Zone als Toleranz (von ManfredW - 30.12.2005 16:38)
        Re: Tote Zone als Toleranz (von Butcher - 2.01.2006 20:39)
Re: Vergleich/Gleichsetzung von Variablen (von Butcher - 29.12.2005 17:57)