Hallo,
was mach ich falsch? Habe mir jetzt mal das Beispiel angeschaut und auf COM 0 angepasst.
Leider kommt bei übertragen auf die Steuerung immer Kommunikation Fehler (#0). Das übertragen anderer Programme klappt reibungslos.
Code füge ich ein:
PROGRAM PLC_PRG
VAR
(* Communicationparams for 750-65x/003-000 only*)
wBaudRate : WORD := 960;
bDataBits : BYTE := 7;
bParity : BYTE := 0;
bFlowControl : BYTE := 0;
i : INT;
(* COM0 ********************************************)
COM0 : SERIAL_INTERFACE;
xOpenPort0 : BOOL := TRUE;
xInitPort0 : BOOL;
xSendActive0 : BOOL;
SendString0 : STRING := 'Msg from COM0';
ReceiveBuffer0 : typRing_Buffer;
ReceiveBuffer0OldIndex : INT;
ReceiveString0 : STRING(255);
pReceiveStr0 : POINTER TO ARRAY[0..255] OF BYTE;
help0Idx : INT;
iTo2 : INT;
END_VAR
(*----------------------------------------------------------------------------
' WAGO Kontakttechnik GmbH | |
' Hansastr. 27 | Technical Support |
' D-32423 Minden | |
' Tel.: +49(0)571 / 887 - 0 | Tel.: +49(0)571 / 887 - 555 |
' Fax.: +49(0)571 / 887 - 169 | Fax.: +49(0)571 / 887 - 8555 |
' Mail:
info@wago.com | Mail:
support@wago.com |
' www :
http://www.wago.com | |
'-----------------------------------------------------------------------------
' Copyright (C) WAGO 2001 - All Rights Reserved |
'-----------------------------------------------------------------------------
' Filename :
' Version : 1.00
' Date : 21-10-2002
'-----------------------------------------------------------------------------
' Description : Example for using functionblock: "SERIAL_INTERFACE" from the
' Library "Serial_Interface_01.lib".
' For additional information see application note "a110901"
' Communicationparams are only changeable for 750-65x/003-000
'-----------------------------------------------------------------------------
' Required : SerComm.lib
' Serial_Interface_01.lib
'-----------------------------------------------------------------------------
' |Date |Who |Ver |Changes
'-----------------------------------------------------------------------------
' 21.10.02 CM 1.00 Init
'----------------------------------------------------------------------------*)
(* Send and Receive for COM0 *)
COM0( bCOM_PORT_NR := 0,
cbBAUDRATE := wBaudRate,
cbsBYTESIZE := bDataBits,
cpPARITY := bParity,
csSTOPBITS := STOPBITS_1,
cfFLOW_CONTROL := bFlowControl,
utRECEIVE_BUFFER := ReceiveBuffer0,
ptSEND_BUFFER := ADR(SendString0),
xINIT := xInitPort0,
xOPEN_COM_PORT := xOpenPort0,
iBYTES_TO_SEND := LEN(SendString0) +1,
xSTART_SEND := xSendActive0 );
(* Display received data for COM0 *)
IF ReceiveBuffer0OldIndex <> ReceiveBuffer0.Index THEN
iTo2 := ReceiveBuffer0.Index - ReceiveBuffer0OldIndex -1;
IF iTo2 < 0 THEN
iTo2 := iTo2 + SIZEOF(ReceiveBuffer0.Data);
END_IF;
IF pReceiveStr0 = 0 THEN
pReceiveStr0 := ADR( ReceiveString0 );
END_IF;
FOR i:=0 TO iTo2 DO
help0Idx := (ReceiveBuffer0OldIndex + i) MOD (SIZEOF(ReceiveBuffer0.Data));
pReceiveStr0^
:= ReceiveBuffer0.Data[ help0Idx ];
IF ReceiveBuffer0.Data[ help0Idx ] = 16#00 THEN
ReceiveBuffer0OldIndex := ReceiveBuffer0.Index;
END_IF;
END_FOR;
END_IF;
Zur Erinnerung möchte die RS232 Schnittstelle auf dem Controller 8202 benutzen, im Webinterface habe ich die nötigen Einstellungen gemacht.
Vielen Dank schön mal im voraus.
Mfg. WJM