another SCL question

sparkysliderz

Member
Join Date
Feb 2005
Location
Posts
68
Hi Guys,

yeah, its me again! I'm slooooowly getting to grips with this SCL stuff but I am stuck again!

I am trying to read in a time variable from a DB and load it into a timer
Code:
FUNCTION FC1: VOID 
VAR_INPUT
	State:BOOL;	 
	ByteNum:INT;	 
	BitNum:INT;	 
	MyTime :TIMER; 
END_VAR
VAR
	TimerNum:INT;
	set:BOOL;
	reset:BOOL;
	bcdvalue:S5TIME;
	binvalue:WORD;
	initalvalue:S5TIME;
END_VAR
BEGIN
	 IF State = 1 THEN 
		q[ByteNum,BitNum]:=1;
	 END_IF;
	 IF State = 0 THEN
		q[ByteNum,BitNum]:=0;
	 END_IF;
	TimerNum:=WORD_TO_INT(db1.dbw8);
	set:=i[0,0];
	reset:=i[0,1];
[color=seagreen]	initalvalue:=T#10s;		 // this will compile[/color]
[color=red]	initalvalue:= db1.dbw6;	 // this wont!
[/color]	bcdvalue:= S_ODT( T_NO := TimerNum,
						s:= set,
						tv:= initalvalue,
						r:= reset,
						bi:= binvalue,
						q:=q0.7);
	qw4:=binvalue;
 
 
END_FUNCTION
BUT!..... I'm not sure what format the time value is in. Is there a "cast" function I should be using?

Each time i try to compile I have the following (unhelpful) error message, "Invalid Data Type"

I have tried to change the type of value from "S5TIME" to "Time" in the DB but I just cant get it to compile!

Any help would be appreciated!

Thanks in advance guys.
 
I couldn't see the solution in Berger (for SCL) so my pragmatic solution is to add an s5time variable as an input parameter for your FC1 and then assign it to your temp variable. I was able to use DB1.dbw8 (declared as s5time type) in the parameter call to FC1

Code:
VAR_INPUT
	State:BOOL;	 
	ByteNum:INT;	 
	BitNum:INT;	 
	MyTime :TIMER;
   [b] Mys5Time:S5TIME;[/b] 
END_VAR
...
...
...
 
   [b]initalvalue:=Mys5Time;[/b]
...
...
 

Similar Topics

Hi, The hardware is: Click Plc model # CO-O1DD1-O HMI model # S3ML-R magnetic-inductive flow meter model # FMM100-1001. I will set the flow meter...
Replies
4
Views
136
So I had an odd request from a customer for the above. I have written the logic and tested it all in one PLC with only using 7 outputs and 7...
Replies
15
Views
428
Hello I need to message read the entire 16 channel raw analog inputs from a 1769-L33ER Compact Logic controller to another 1769-L33ER Compact...
Replies
8
Views
244
I am noticing a problem where i am using MOV instruction and writing literal text into source and String datatype in destination. It works fines...
Replies
6
Views
486
I'm not actually in front of the equipment yet, but this is the information that I have been given by a client: ------------ Data from HART...
Replies
2
Views
336
Back
Top Bottom