Mitsubishi Electronics MELSEC Q series MELSEC L series Home Theater Server User Manual


 
5.3 Serial Communication
5.3.1 ONDEMAND instruction
5-69
G_ONDEMAND
5
MODULE DEDICATED
INSTRUCTION
G_ONDEMAND
[ST]
PLS(X53, Var_Flag_Inst); (* On-demand transmission instruction pulse *)
IF(Var_Flag_Inst=TRUE)THEN (* Instruction flag ON *)
MOV(TRUE, 1, Var_ControlData[0]); (* Sets transmission channel to 1 *)
MOV(TRUE, 2, Var_ControlData[2]); (* Sets number of send data to 2 words *)
MOV(TRUE, H1234, D10); (* Sets send data to D10 to D11 *)
MOV(TRUE, H5678, D11);
RST(TRUE, Var_Flag_Normal); (* Turns normal completion flag OFF *)
RST(TRUE, Var_Flag_Error); (* Turns error completion flag OFF *)
SET(TRUE, Var_Flag_Exe); (* Turns execution flag ON *)
END_IF;
IF(Var_Flag_Exe=TRUE)THEN (* Execution flag ON *)
GP_ONDEMAND(TRUE, H0, Var_ControlData, D10, Var_Result);
(* Performs on-demand function transmission *)
END_IF;
IF(Var_Result[0]=TRUE)THEN (* Execution finished *)
IF(Var_Result[1]=FALSE)THEN (* Normal completion *)
SET(TRUE, Var_Flag_Normal); (* Turns normal completion flag ON *)
ELSE (* Error completion *)
SET(TRUE, Var_Flag_Error); (* Turns error completion flag ON *)
END_IF;
RST(TRUE, Var_Flag_Exe); (* Turns execution flag OFF *)
END_IF;
1. The communication status can be checked by the SPBUSY instruction.
Section 5.3.6
2. Specify the capacity of the send data (stored in devices from D10 to D11 in the
program example above) and the number of send data within the user-defined
buffer memory range assigned for the on-demand function.