ProjectInfo (PRG)¶
PROGRAM ProjectInfo
Note
Die Beschreibung ist Beispielhaft und an das Projekt TPC Modbus Server angelehnt.
- Initalisierung -> Typische vorgehensweise:
ELA_COMM : HostComm.ModbusFb();DeviceIP : STRING(19):= '192.168.5.58';SetDeviceIP(DeviceIP);ELA_COMM.Server[0].SetDeviceIP(DeviceIP);PortNo : WORD := 502;SetPortNo(PortNo);SetCSVFileName('ModbusMapping.csv');SetCSVFilePath('/home/plc_v3/'); // (* CoDeSys- Stammverzeichnis unter Linux *)SetCSVFilePath('/Flashdisk/PLC_V3/'); // (* CoDeSys- Stammverzeichnis unter Windows *)'/home/plc_v3/ModbusMapping.csv'SetDeviceNo(DeviceNo);| 0 | Kommunikation ist ausgeschalten |
| 1..255 | Kommunikation ist eingeschalten |
ELA_COMM();- Weitere, optionale Methoden
ELA_COMM.Server[0].SetByteOrder(MotorolaByteOrder:= FALSE);ELA_COMM.Server[0].GetClientIP(ClientNo);CloseSocketFromExtern();- Direktzugriff in Bausteinvariablen
GetDebugRecvString(); ( Client –> Server )GetDebugSendString(); ( Server –> Client )| Element: | Bedeutung: |
|---|---|
| ANS: | Answer- (Antwort-) Telegramm |
| 07140: | Sendecounter (0..9999) |
| L011 | Telegrammlänge = 11 Byte |
| –> | Es folgt der Telegramminhalt |
| 1A | Transaktionsnummer (Highbyte) |
| 09 | Transaktionsnummer (Lowbyte) |
| 00 | Protokollkennzeichen (immer 0x00) |
| 00 | Protokollkennzeichen (immer 0x00) |
| 00 | Bytecount (Highbyte) |
| 05 | Bytecount (des nun folgenden Modbus-Telegramm) |
| 01 | DeviceNo |
| 03 | FunctionCode |
| 02 | Bytecount (Der nun folgenden Registerinhalte |
| 00 | RegisterInhalt (Highbyte) |
| 14 | RegisterInhalt (Lowbyte) =20 |
GetLastClientRequest(ClientNo);PROGRAM ModbusTestVARC_SPC : UINT := 40;C_STC : UINT := 41;C_TOC : UINT := 42;C_OFL : UINT := 43;C_ONL : UINT := 44;C_CFF : UINT := 45;C_TAR : UINT := 46;C_ALC : UINT := 47;C_VOM : UINT := 48;C_MAM : UINT := 49;C_RFD : UINT := 50;C_RFE : UINT := 51;C_RFL : UINT := 52;IFS : REAL := 21.73;BGN : REAL := 1.11;FSS : REAL := 2.22;MFP : REAL := 3.33;MFS : REAL := 4.44;ELM : REAL := 5.55;CDC : REAL := 6.66;RHS : REAL := 7.77;RLS : REAL := 8.88;SPS : REAL := 9.99;ADS : UDINT := 10;MPS : UDINT := 11;RQS : UDINT := 12;RDT : UDINT := 13;SS1 : UDINT := 14;DH1 : UDINT := 15;DL1 : UDINT := 16;RS1 : UDINT := 17;DHS : UDINT := 18;DLS : UDINT := 19;RSR : STRING(4) :='Text';PS4 : UDINT := 200;ASR : UDINT := 201;CFF : REAL := 22.3;MSD : REAL := 23.4;MFA : REAL := 24.5;NWA : REAL := 25.6;DC1 : REAL := 26.7;DCA : REAL := 27.8;TOA : REAL := 28.9;SGW : UINT := 10;SPA : UINT := 20;SP1 : UINT := 30;END_VAR| Adresse | Name | DataType | Access | Register | BitNr | Bezeichnung |
|---|---|---|---|---|---|---|
| 40100 | Application.ModbusTest.C_SPC | unsigned16 | w | 1 | -99 | Bit 1 Dosierer Stop |
| 40101 | Application.ModbusTest.C_SPC | unsigned16 | w | 1 | -99 | Bit 2 Dosierer Start |
| 40102 | Application.ModbusTest.C_TOC | unsigned16 | w | 1 | -99 | Bit 3 Dosierer Totalisator löschen |
| 40103 | Application.ModbusTest.C_OFL | unsigned16 | w | 1 | -99 | Bit 4 Dosierer Lokal |
| 40104 | Application.ModbusTest.C_ONL | unsigned16 | w | 1 | -99 | Bit 5 Dosierer Verhältnis |
| 40105 | Application.ModbusTest.C_CFF | unsigned16 | w | 1 | -99 | Bit 8 Kalibrieren |
| 40106 | Application.ModbusTest.C_TAR | unsigned16 | w | 1 | -99 | Bit 9 Tarieren |
| 40107 | Application.ModbusTest.C_ALC | unsigned16 | w | 1 | -99 | Bit 12 Alarm löschen |
| 40108 | Application.ModbusTest.C_VOM | unsigned16 | w | 1 | -99 | Bit 16 Betriebsart Volumetrisch |
| 40109 | Application.ModbusTest.C_MAM | unsigned16 | w | 1 | -99 | Bit 17 Betriebsart Gravimetrisch |
| 40110 | Application.ModbusTest.C_RFD | unsigned16 | w | 1 | -99 | Bit 20 Nachfüllen Stop |
| 40111 | Application.ModbusTest.C_RFE | unsigned16 | w | 1 | -99 | Bit 21 Nachfüllen Start |
| 40112 | Application.ModbusTest.C_RFL | unsigned16 | w | 1 | -99 | Bit 22 Nachfüllen Freigabe |
| 40120 | Application.ModbusTest.IFS | float | rw | 2 | -99 | Dosierfaktor Start Sollwert |
| 40122 | Application.ModbusTest.BGN | float | rw | 2 | -99 | Durchsatz Filter Sollwert |
| 40124 | Application.ModbusTest.FSS | float | rw | 2 | -99 | Durchsatz Nominal Sollwert |
| 40126 | Application.ModbusTest.MFP | float | rw | 2 | -99 | Durchsatz Prozent Sollwert |
| 40128 | Application.ModbusTest.MFS | float | rw | 2 | -99 | Durchsatz Sollwert |
| 40130 | Application.ModbusTest.ELM | float | rw | 2 | -99 | Gewicht Alarmlimit leer Sollwert |
| 40132 | Application.ModbusTest.CDC | float | rw | 2 | -99 | Kalibration Stellbefehl Sollwert |
| 40134 | Application.ModbusTest.RHS | float | rw | 2 | -99 | Nachfüllpegel Max Sollwert |
| 40136 | Application.ModbusTest.RLS | float | rw | 2 | -99 | Nachfüllpegel Min Sollwert |
| 40138 | Application.ModbusTest.SPS | float | rw | 1 | Steilheit Sollwert | |
| 40140 | Application.ModbusTest.ADS | unsigned32 | rw | 1 | Alarmverzögerung Sollwert | |
| 40142 | Application.ModbusTest.MPS | unsigned32 | rw | 1 | Durchsatz Alarmlimit Max Sollwert | |
| 40144 | Application.ModbusTest.RQS | unsigned32 | rw | 1 | Nachfüllmenge Sollwert | |
| 40146 | Application.ModbusTest.RDT | unsigned32 | rw | 1 | Nachfüllumschaltungszeit Sollwert | |
| 40148 | Application.ModbusTest.SS1 | unsigned32 | rw | 1 | Paddel fester Sollwert | |
| 40150 | Application.ModbusTest.DH1 | unsigned32 | rw | 1 | Paddel Stellbefehl Alarmlimit Max Sollwert | |
| 40152 | Application.ModbusTest.DL1 | unsigned32 | rw | 1 | Paddel Stellbefehl Alarmlimit Min Sollwert | |
| 40154 | Application.ModbusTest.RS1 | unsigned32 | rw | 1 | Verhältnis Sollwert | |
| 40156 | Application.ModbusTest.DHS | unsigned32 | rw | 1 | Stellbefehl Alarmlimit Max Sollwert | |
| 40158 | Application.ModbusTest.DLS | unsigned32 | rw | 1 | Stellbefehl Alarmlimit Min Sollwert | |
| 40160 | Application.ModbusTest.RSR | string | rw | 7 | Materialname Rezept | |
| 40160 | Application.ModbusTest.RSR | string | rw | 7 | Materialname Rezept | |
| 40162 | Application.ModbusTest.PS4 | unsigned32 | r | 1 | 0 | Bit 0 Dosierer Freigegeben |
| 40162 | Application.ModbusTest.PS4 | unsigned32 | r | 1 | 1 | BIT 1 Dosierer in Betrieb |
| 40162 | Application.ModbusTest.PS4 | unsigned32 | r | 1 | 4 | Bit 4 Dosierer im Lokalbetrieb |
| 40162 | Application.ModbusTest.PS4 | unsigned32 | r | 1 | 5 | Bit 5 Dosierer im Verhältnisbetrieb |
| 40162 | Application.ModbusTest.PS4 | unsigned32 | r | 1 | 8 | Bit 8 Kalibrieren läuft |
| 40162 | Application.ModbusTest.PS4 | unsigned32 | r | 1 | 13 | Bit 13 Alarm Abschaltung aktiv |
| 40162 | Application.ModbusTest.PS4 | unsigned32 | r | 1 | 16 | Bit 16 Betriebsart Volumetrisch |
| 40162 | Application.ModbusTest.PS4 | unsigned32 | r | 1 | 17 | Bit 17 Betriebsart Gravimetrisch |
| 40162 | Application.ModbusTest.PS4 | unsigned32 | r | 1 | 22 | Bit 22 Nachfüllen Freigegeben |
| 40162 | Application.ModbusTest.PS4 | unsigned32 | r | 1 | 14 | Bit 24 Gewicht über Nachfüllpegel Min |
| 40164 | Application.ModbusTest.ASR | unsigned32 | r | 1 | 0 | Bit 0 Motor Alarm |
| 40164 | Application.ModbusTest.ASR | unsigned32 | r | 1 | 4 | Bit 4 Stellbefehl > Max |
| 40164 | Application.ModbusTest.ASR | unsigned32 | r | 1 | 5 | Bit 5 Stellbefehl < Min |
| 40164 | Application.ModbusTest.ASR | unsigned32 | r | 1 | 7 | Bit 7 Durchsatz > Max |
| 40164 | Application.ModbusTest.ASR | unsigned32 | r | 1 | 8 | Bit 8 Durchsatz < Min |
| 40164 | Application.ModbusTest.ASR | unsigned32 | r | 1 | 10 | Bit 10 Waagenstörgröße > Max |
| 40164 | Application.ModbusTest.ASR | unsigned32 | r | 1 | 14 | Bit 14 Gewicht < Min |
| 40164 | Application.ModbusTest.ASR | unsigned32 | r | 1 | 16 | Bit 16 Wägezelle Überlast |
| 40164 | Application.ModbusTest.ASR | unsigned32 | r | 1 | 18 | Bit 18 Wägezelle Alarm |
| 40164 | Application.ModbusTest.ASR | unsigned32 | r | 1 | 20 | Bit 20 Nachfüllzeit abgelaufen |
| 40164 | Application.ModbusTest.ASR | unsigned32 | r | 1 | 24 | Bit 24 Paddel Motor Alarm |
| 40164 | Application.ModbusTest.ASR | unsigned32 | r | 1 | 28 | Bit 28 Paddel Stellbefehl > Max |
| 40164 | Application.ModbusTest.ASR | unsigned32 | r | 1 | 29 | Bit 29 Paddel Stellbefehl < Min |
| 40166 | Application.ModbusTest.CFF | float | r | 2 | -99 | Dosierfaktor Istwert |
| 40168 | Application.ModbusTest.MSD | float | r | 2 | -99 | Durchsatz Abweichung Istwert |
| 40170 | Application.ModbusTest.MFA | float | r | 2 | -99 | Durchsatz Istwert |
| 40172 | Application.ModbusTest.NWA | float | r | 2 | -99 | Nettogewicht Istwert |
| 40174 | Application.ModbusTest.DC1 | float | r | 2 | -99 | Paddel Stellbefehl Istwert |
| 40176 | Application.ModbusTest.DCA | float | r | 2 | -99 | Stellbefehl Istwert |
| 40178 | Application.ModbusTest.TOA | float | r | 2 | -99 | Verbrauch Istwert |
| 40180 | Application.ModbusTest.SGW | unsigned16 | r | 2 | -99 | Waagenbereich Istwert |
| 40181 | Application.ModbusTest.SPA | unsigned16 | r | 1 | -99 | Motor Drehzahl Istwert |
| 40182 | Application.ModbusTest.SP1 | unsigned16 | r | 2 | -99 | Paddel Motor Drehzahl Istwert |
| -99 | -99 | -99 | -99 | -99 | -99 | -99 |
Note
Achtung: Beim Abspeichern unter Excel in CSV- Format werden, je nach Office-Version, die Semikolon am Ende der Teile durch CR ersetzt. Es ist daher Empfohlen dies z.B. unter OpenOffice abzuspeichern, oder die CSV Datei abschließend im Editor zu überprüfen.
- Tabelle geöffnet mit Editor:
-99 an Stelle der Modbus-Registeradresse markiert das Ende des Tabelleneintrag.- Unterstützte Variablentypen
| IEC | In CSV- Tabelle | Ergänzende Informationen |
|---|---|---|
| WORD UINT | unsigned16 | |
| INT | signed16 | |
| DWORD UDINT | unsigned32 | |
| DINT | signed32 | |
| REAL | float | |
| String | string | String(1..255) |
Note
Bit’s(BOOL) innerhalt eines UNSINGNED16/32 können zwar in der Tabelle nacheinander angegeben werden, jedoch wird das Register “normal” übertragen und behandelt. Eine Mehrfachnennung eines Registers wird bei der Übertragung ignoriert. Im Beispiel: Modbusregister 40162 wird 1x regulär als 32bit Variable übertragen. der Bitzugriff in die Unsigned32- Variable muß manuell erfolgen.
- ERROR- Codes
| Error-Code | Bedeutung Norm | Bedeutung hier |
|---|---|---|
| 01 | ILLEGAL FUNCTION | Der FC des Request-Telegramm wird vom Server nicht unterstützt Bsp.: Anfrage mit FC1 |
| 02 | ILLEGAL DATA ADDRESS | Die Angefragte Startadresse wurde in der Tabelle nicht gefunden Bsp.: Hier Anfrage ab Adresse 40118, Diese existiert nicht in Tabelle |
| 03 | ILLEGAL DATA VALUE | Die Abfragelänge ist länger als das letzte Register in der Tabelle Bsp.: Abfrage ab Register 40180 mit der Länge 20. Das letzte existierende Register ist 40182 |
| 04 | SLAVE DEVICE FAILURE | Die Tabelle Konnte nicht geladen werden. Über Modbus können keine Daten bereitgestellt werden. |