HI,
I'm working with Beckhoff CX5020 series PLC and I'm using Serial ComLibV2 library for serial communication(RS422).
The problem I have is I want to send a constant string NOT time based but event based i.e : If I receive a HIGH on a digital input then I will send this packet over the serial port to the other device. It can be 100 times in a second that this event happens, but every time I need to make sure that I'm sending the string once.
This might sound stupid our simple to you but I could not find how to do this in Twincat. should I use a Trigger(R_TRIGG)? in my code or should I monitor the BUSY flag of the send function? I'm receiving as many as 10 packets(XpingX) on the other device sometimes.
Here is a sample code of what I have:
IF SendTrigger THEN
CASE SendStpes OF
0:
;
1:
LED_Signal:=FALSE;
Send(SendString:= 'XpingX',
TXbuffer:= TxBuffer1,
Busy=> SendBusy,
Error=> SendErrorID);
IF NOT(SendBusy) THEN
SendStpes :=2;
END_IF
2:
;
END_CASE;
This is the Global variable definitions:
COMin_EL62xx AT %I* :EL6inData22B ;
COMout_EL62xx AT %Q* : EL6outData22B;
RxBuffer1: ComBuffer;
TxBuffer1: ComBuffer;
Send: SendString;
SendBusy: BOOL;
SendErrorID: ComError_t;
I also have a "fast_task" running in the background(faster than the main program cycle) that takes care of sending and receiving packets.
Cheers,
I'm working with Beckhoff CX5020 series PLC and I'm using Serial ComLibV2 library for serial communication(RS422).
The problem I have is I want to send a constant string NOT time based but event based i.e : If I receive a HIGH on a digital input then I will send this packet over the serial port to the other device. It can be 100 times in a second that this event happens, but every time I need to make sure that I'm sending the string once.
This might sound stupid our simple to you but I could not find how to do this in Twincat. should I use a Trigger(R_TRIGG)? in my code or should I monitor the BUSY flag of the send function? I'm receiving as many as 10 packets(XpingX) on the other device sometimes.
Here is a sample code of what I have:
IF SendTrigger THEN
CASE SendStpes OF
0:
;
1:
LED_Signal:=FALSE;
Send(SendString:= 'XpingX',
TXbuffer:= TxBuffer1,
Busy=> SendBusy,
Error=> SendErrorID);
IF NOT(SendBusy) THEN
SendStpes :=2;
END_IF
2:
;
END_CASE;
This is the Global variable definitions:
COMin_EL62xx AT %I* :EL6inData22B ;
COMout_EL62xx AT %Q* : EL6outData22B;
RxBuffer1: ComBuffer;
TxBuffer1: ComBuffer;
Send: SendString;
SendBusy: BOOL;
SendErrorID: ComError_t;
I also have a "fast_task" running in the background(faster than the main program cycle) that takes care of sending and receiving packets.
Cheers,