Beispielformeln für die Checksummenberechnung

<< Click to Display Table of Contents >>

Navigation:  Plug-ins > Mitgelieferte User-Plug-ins > Formel > Beispiel: Checksummenberechnung >

Beispielformeln für die Checksummenberechnung

 

Die nachfolgenden Formeln dienen als Kopiervorlage und können aus der Hilfe heraus in den Formel-Editor per Copy&Paste kopiert werden:

 

 

Formel 1 (Simulationsstart, Initialisierung)

 

Sig("//CAN-DB/CAN0/CanEasy/Datenpaket/Signal1") = 23500;

Sig("//CAN-DB/CAN0/CanEasy/Datenpaket/Signal2") = 125;

Sig("//CAN-DB/CAN0/CanEasy/Datenpaket/Signal3") = 1550;

Sig("//CAN-DB/CAN0/CanEasy/Datenpaket/Signal4") = 2000;

Sig("//CAN-DB/CAN0/CanEasy/Datenpaket/Signal5") = 230;

 

 

Formel 2 (Vor den Senden, Zyklische Wertänderung)

 

Sig("//CAN-DB/CAN0/CanEasy/Datenpaket/Signal1") =

  Sig("//CAN-DB/CAN0/CanEasy/Datenpaket/Signal1") + 1 +

  Sig("//CAN-DB/CAN0/CanEasy/Datenpaket/Signal1") / 2;

 

Sig("//CAN-DB/CAN0/CanEasy/Datenpaket/Signal2") =

  Sig("//CAN-DB/CAN0/CanEasy/Datenpaket/Signal1") - 1;

 

Sig("//CAN-DB/CAN0/CanEasy/Datenpaket/Signal3") =

  Sig("//CAN-DB/CAN0/CanEasy/Datenpaket/Signal3") +

  Sig("//CAN-DB/CAN0/CanEasy/Datenpaket/Signal1");

 

Sig("//CAN-DB/CAN0/CanEasy/Datenpaket/Signal4") =

  4095 - Sig("//CAN-DB/CAN0/CanEasy/Datenpaket/Signal3");

 

Sig("//CAN-DB/CAN0/CanEasy/Datenpaket/Signal5") =

  Sig("//CAN-DB/CAN0/CanEasy/Datenpaket/Signal1") /

  Sig("//CAN-DB/CAN0/CanEasy/Datenpaket/Signal2");

 

 

Formel 3 (Nach Formel 2, Checksumme berechnen)

 

Checksum =   MsgByte("//CAN-DB/CAN0/CanEasy/Datenpaket",0)

          ^ MsgByte("//CAN-DB/CAN0/CanEasy/Datenpaket",1)

          ^ MsgByte("//CAN-DB/CAN0/CanEasy/Datenpaket",2)

          ^ MsgByte("//CAN-DB/CAN0/CanEasy/Datenpaket",3)

          ^ MsgByte("//CAN-DB/CAN0/CanEasy/Datenpaket",4)

          ^ MsgByte("//CAN-DB/CAN0/CanEasy/Datenpaket",5)

          ^ MsgByte("//CAN-DB/CAN0/CanEasy/Datenpaket",6);

 

Sig("//CAN-DB/CAN0/CanEasy/Datenpaket/Checksumme") = Checksum;

 

 

Formel 4 (Nach Formel 3, Manipulation eines Signals)

 

Sig("//CAN-DB/CAN0/CanEasy/Datenpaket/Signal1") =

  Sig("//CAN-DB/CAN0/CanEasy/Datenpaket/Signal1") - 1;

 

 

Formel 5 (Nach dem Senden, Checksumme prüfen)

 

Checksum =   MsgByte("//CAN-DB/CAN0/CanEasy/Datenpaket",0)

          ^ MsgByte("//CAN-DB/CAN0/CanEasy/Datenpaket",1)

          ^ MsgByte("//CAN-DB/CAN0/CanEasy/Datenpaket",2)

          ^ MsgByte("//CAN-DB/CAN0/CanEasy/Datenpaket",3)

          ^ MsgByte("//CAN-DB/CAN0/CanEasy/Datenpaket",4)

          ^ MsgByte("//CAN-DB/CAN0/CanEasy/Datenpaket",5)

          ^ MsgByte("//CAN-DB/CAN0/CanEasy/Datenpaket",6);

 

Sig("//CAN-DB/CAN0/CanEasy/Anzeige/ChecksummenFehler") =

  Checksum != Sig("//CAN-DB/CAN0/CanEasy/Datenpaket/Checksumme");