MezData-Logo Lösungen Button :ISP: Lösung Windrichtungsmesser

MODULE gray	
 "Codeumsetzer Graycode -> 8-4-2-1-Code -> 7-Segment-Code

DECLARATIONS "*************** Ein- und Ausg‰nge ***************************
  g3..g0     	PIN 29,30,31,32;                      "Eing‰nge Graycode
  d3..d0        Node ISTYPE 'COM';
  a,b,c,d,e,f,g PIN 4,3,6,7,8,9,10 ISTYPE'BUFFER,COM';"7-Segm-Anzeige
  r16..r1       PIN 16,18,20,22,43,41,39,37,38,40,42,
                    44,21,19,17,15 ISTYPE'BUFFER,COM';"LED - Rosette

"********************* SET Deklarationen ********************************
  graycode  =  [g3..g0];		"Richtungserfassung mit Graycode 
  dualzahl  =  [d3..d0];                "Dualzahl als Zwischencode
  segment7  =  [a,b,c,d,e,f,g];	        "7-Segment-Anzeige
  rosette   =  [r16..r1];               "Rosette = 16 LEDs f¸r Windrichtung

EQUATIONS "****************************************************************

TRUTH_TABLE "****** Funktionstabelle 8-4-2-1-Code -> 7-Segment-Code ******* 
 (dualzahl    -> [a ,b ,c ,d ,e ,f ,g ]) "Eing‰nge -> Ausg‰nge
     0        -> [1 ,1 ,1 ,1 ,1 ,1 ,0 ]; "   LEDs high-aktiv!
     1        -> [0 ,1 ,1 ,0 ,0 ,0 ,0 ]; "         a
     2        -> [1 ,1 ,0 ,1 ,1 ,0 ,1 ]; "        ---
     3        -> [1 ,1 ,1 ,1 ,0 ,0 ,1 ]; "     f | g | b
     4        -> [0 ,1 ,1 ,0 ,0 ,1 ,1 ]; "        ---
     5        -> [1 ,0 ,1 ,1 ,0 ,1 ,1 ]; "     e | d | c
     6        -> [1 ,0 ,1 ,1 ,1 ,1 ,1 ]; "        ---
     7        -> [1 ,1 ,1 ,0 ,0 ,0 ,0 ];
     8        -> [1 ,1 ,1 ,1 ,1 ,1 ,1 ];
     9        -> [1 ,1 ,1 ,1 ,0 ,1 ,1 ];
     10       -> [1 ,1 ,1 ,0 ,1 ,1 ,1 ]; "A
     11       -> [0 ,0 ,1 ,1 ,1 ,1 ,1 ]; "b
     12       -> [0 ,0 ,0 ,1 ,1 ,0 ,1 ]; "c
     13       -> [0 ,1 ,1 ,1 ,1 ,0 ,1 ]; "d
     14       -> [1 ,0 ,0 ,1 ,1 ,1 ,1 ]; "E
     15       -> [1 ,0 ,0 ,0 ,1 ,1 ,1 ]; "F

TRUTH_TABLE "****** Funktionstabelle Graycode -> 8-4-2-1-Code **************
  (graycode  -> dualzahl )
   [0,0,0,0] -> 0;
   [0,0,0,1] -> 1;
   [0,0,1,1] -> 2;
   [0,0,1,0] -> 3;
   [0,1,1,0] -> 4;
   [0,1,1,1] -> 5;
   [0,1,0,1] -> 6;
   [0,1,0,0] -> 7;
   [1,1,0,0] -> 8;
   [1,1,0,1] -> 9;
   [1,1,1,1] -> 10;
   [1,1,1,0] -> 11;
   [1,0,1,0] -> 12;
   [1,0,1,1] -> 13;
   [1,0,0,1] -> 14;
   [1,0,0,0] -> 15;

TRUTH_TABLE "****** Funktionstabelle 8-4-2-1-Code -> Windrichtungs-Rosette **
   (dualzahl -> rosette)
    0        -> [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1];
    1        -> [0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0];
    2        -> [0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0];
    3        -> [0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0];
    4        -> [0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0];
    5        -> [0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0];
    6        -> [0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0];
    7        -> [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0];
    8        -> [0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0];
    9        -> [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0];
    10       -> [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0];
    11       -> [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0];
    12       -> [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0];
    13       -> [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0];
    14       -> [0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
    15       -> [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
END