RMA
Member
I've got to scan a bar-code using a Cognex DataMan scanner. For reasons of convenience (my convenience!), I want to run the complete data acquisition in an FC which is called in one Step of the main program - i.e. this FC will run to completion in one CPU cycle. In itself, this is not a problem - if it weren't for the fact that I need a Trigger Impulse to start things off and I need a variety of other Timers to monitor potential fault conditions.
Now (I believe) I know that Timers run asynchronously to the CPU cycle, so I assume that something like the following code ought to work:
D_1: NOP 0; //Get character 1
CALL "Get DataMan Data" (
Start_Byte := "MW_DataMan_Next_Byte");
SET
R "M_FC1_First_Time_Data";
L 2; //Toggle RR Bit in KL6001 Control Byte
T "PAB_KL6001_Control_Byte"; //write output Byte directly
W_1: NOP 0;
AN "M_KL6001_Status_RA"; //warten bis RA gelöscht wird
JC D_2;
A "M_FC1_First_Time_Data";
L S5T#100MS;
SD "T_Data_holen";
SET ;
S "M_FC1_First_Time_Data";
A "T_Data_holen";
JCN W_1; //warte bis RA toggles
S "TP1".Stoerung199; //Data transfer Timeout
S "KV".BA.Sammelstoerung;
BEC ; //Exit
D_2: NOP 0; //Get characters 2 - 4
Question 1 - is this assumption correct?
What I'm less sure of is how to drive my pulsed output. Since I need to write the outputs directly, that means I need to write (at least) a full Byte at a time. This means I need to read the current state of the output Byte and OR it with my Trigger Bit. I know I can read the output Byte in the Process Image (and since I can't find anywhere where the Outputs are being directly accessed, at present, that would probably be enough), but:
second question - is it possible to read the Peripheral Output Byte PQB1 directly?
Cheers
Roy
Now (I believe) I know that Timers run asynchronously to the CPU cycle, so I assume that something like the following code ought to work:
D_1: NOP 0; //Get character 1
CALL "Get DataMan Data" (
Start_Byte := "MW_DataMan_Next_Byte");
SET
R "M_FC1_First_Time_Data";
L 2; //Toggle RR Bit in KL6001 Control Byte
T "PAB_KL6001_Control_Byte"; //write output Byte directly
W_1: NOP 0;
AN "M_KL6001_Status_RA"; //warten bis RA gelöscht wird
JC D_2;
A "M_FC1_First_Time_Data";
L S5T#100MS;
SD "T_Data_holen";
SET ;
S "M_FC1_First_Time_Data";
A "T_Data_holen";
JCN W_1; //warte bis RA toggles
S "TP1".Stoerung199; //Data transfer Timeout
S "KV".BA.Sammelstoerung;
BEC ; //Exit
D_2: NOP 0; //Get characters 2 - 4
Question 1 - is this assumption correct?
What I'm less sure of is how to drive my pulsed output. Since I need to write the outputs directly, that means I need to write (at least) a full Byte at a time. This means I need to read the current state of the output Byte and OR it with my Trigger Bit. I know I can read the output Byte in the Process Image (and since I can't find anywhere where the Outputs are being directly accessed, at present, that would probably be enough), but:
second question - is it possible to read the Peripheral Output Byte PQB1 directly?
Cheers
Roy
Last edited: