Hallo allerseits
Ich versuche mit einer Beckhoff CX8091 via FB_ReadAdsSymByName Daten von einer CX9010 zu lesen. Dazu habe ich ein Testprogramm auf beiden Seiten geschrieben (siehe unten). Lese ich nun eine Variable aus dem Main Programm, also in meinem Fall MAIN.iMainCount, funktioniert das bestens. Versuche ich aber eine globale Variable zu lesen, geht das nicht. Was mache ich falsch? Wie ist der Syntax um globale Variablen zu lesen? Global_Variables.iGlobalCount funktioniert leider nicht.
Beim Lesen der globalen Variable erhalte ich die ErrorId 1808 (symbol not found).
Danke für Eure Hilfe!
BitShift
CX9010 **************************************************
MAIN (PRG)
10ms Task
**************************************
PROGRAM MAIN
VAR
iMainCount: INT := 0;
END_VAR
IF iMainCount <= 32767 AND iMainCount >= 0 THEN
iMainCount := iMainCount + 3;
ELSE
iMainCount := 0;
END_IF
IF iGlobalCount <= 32767 AND iGlobalCount >= 0 THEN
iGlobalCount := iGlobalCount + 7;
ELSE
iGlobalCount := 0;
END_IF
Global_Variables *****************************************
VAR_GLOBAL
iGlobalCount: INT := 0;
END_VAR
CX8091 *************************************************
MAIN (PRG) 10ms Task *************************************
PROGRAM MAIN
VAR
iReadMainCount: INT;
iReadGlobalCount: INT;
fbReadMain: FB_ReadAdsSymByName;
fbReadGlobal: FB_ReadAdsSymByName;
bReadPuls: BOOL;
END_VAR
IF bReadPuls THEN
bReadPuls := 0;
ELSE
bReadPuls := 1;
END_IF
fbReadMain.bRead := bReadPuls;
fbReadMain.sNetId := '10.102.123.121.1.1';
fbReadMain.nPort := 801;
fbReadMain.sVarName := 'MAIN.iMainCount';
fbReadMain.nDestAddr := ADR(iReadMainCount);
fbReadMain.nLen := 2;
fbReadMain.eComMode := 0;
fbReadMain();
fbReadGlobal.bRead := bReadPuls;
fbReadGlobal.sNetId := '10.102.123.121.1.1';
fbReadGlobal.nPort := 801;
fbReadGlobal.sVarName := 'iGlobalCount';
fbReadGlobal.nDestAddr := ADR(iReadGlobalCount);
fbReadGlobal.nLen := 2;
fbReadGlobal.eComMode := 0;
fbReadGlobal();