Using MpDataRecorder - Question regarding global variables

Newbe here :wink:

I Have the program where I cant address variables outside this task.
Not even global ones.
The local variables are logged ok.

Can any point me in the direction how this can be done ?
Is it a syntax thing or more complicated ?

BR Claus

PROGRAM _INIT
	(* Insert code here *)
	FB_DataRecorder.MpLink:= ADR(gDataRecorder); //poniter 
	FB_DataRecorder.Enable:=TRUE;				// Start af DataRecorder
	FB_DataRecorder.SamplingTime:=T#2000ms;  //2 sekunder mellem mÄlinger
	FB_DataRecorder.DeviceName:=ADR('USER'); //Lokation for CSV filer defineret i config pÄ PLC	
		
	
	Data_RegPar.MpLink:=ADR(gDataRecorder) ; //Def. til variabler der skal recorderes
	Data_RegPar.Enable:=TRUE;
	Data_RegPar1.MpLink:=ADR(gDataRecorder) ;//Def. til variabler der skal recorderes
	Data_RegPar1.Enable:=TRUE;
	Data_RegPar2.MpLink:=ADR(gDataRecorder) ;//Def. til variabler der skal recorderes
	Data_RegPar2.Enable:=TRUE;
	Data_RegPar3.MpLink:=ADR(gDataRecorder) ;//Def. til variabler der skal recorderes
	Data_RegPar3.Enable:=TRUE;	
		
END_PROGRAM

PROGRAM _CYCLIC
	(* Insert code here *)
	Speed:=gTEST;
	FB_DataRecorder();

	//FB_DataRecorder.RecordMode:=mpDATA_RECORD_MODE_VALUE;  //Logger nÄr der er Þndring i PV vÊrdier
	FB_DataRecorder.RecordMode:=mpDATA_RECORD_MODE_TIME ;  // Logger med fast interval
	
	Data_RegPar();
	Data_RegPar.PVName:=ADR('GDataRec:Speed');
	Data_RegPar1();
	Data_RegPar1.PVName:=ADR('GDataRec:Temp_Inlet_1');
	Data_RegPar2();
	Data_RegPar2.PVName:=ADR('GDataRec:Temp_Inlet_2');
	Data_RegPar3();
	//Data_RegPar3.PVName:=ADR('DataLogger:gTEST');
	Data_RegPar3.PVName:=ADR('GDataRec:Temp_Inlet_3');

Hi there,

assuming “gTEST” is suposed to be your global variable, you don’t prepend the task (that’s indicating a local variable)
See B&R Online Help

So it’s supposed to be ADR('gTEST')

Please also note that especially in test cases where you’re simply testing things out like this, you might not have used “gTEST” as a variable anywhere and thus the variable has been discarded (you’ll notice that it also isn’t accessible via the watch window, in that case) - simply assign a value at least once in code to circumvent that.

Thanks for the answer.
gTEST is defined as a global variable.

//Claus

Hi,

that clarifies my assumption, but doesn’t acknowledge any of the rest of my post.

a) Did you test using ADR(‘gTEST’) ?
b) Did you make sure to use the variable gTEST somewhere in the code so the compiler doesn’t throw it away?

(note: a) and b) are both to be done, not just one of them)

Best regards

Global variable now working :grinning_face: (Data_RegPar3.PVName:=ADR(‘gTEST’):wink:

Is it possible to address a local variable in another task ?

BR. Claus


Found the solution
Data_RegPar3.PVName:=ADR(‘Program:Program1’);


Moderator: merged posts