Sign in to follow this  
Followers 0
Bill23

Beckhoff BX3100 PLC and KL6001 question.

1 post in this topic

Hello, I'm trying to make a project with BX3100 and KL6001 module. I want to read from a scale the weight. I made a program and it seems correct but when it runs in the plc,it doesn't receive data. I'm posting the code,any help would be much appreciated. ====================================================PROGRAM MAINVAR(* background communication with the COM port device *) KERNportControl: SerialLineControl; COMportControlError: BOOL; COMportControlErrorID: ComError_t; KL6001_CONFIG:KL6configuration; fbReceiveByte: ReceiveByte; H1: BOOL; (*->>>>>>>>>>>>>>> H1 AT %Q10.4 : BOOL; ->>>>>> *) ReceiveCounter: UDINT; ClearComBuffer1 : ClearComBuffer; S1: BOOL;END_VAR==================================================================================VAR_GLOBAL(* I/O variables for a KL6001 terminal*) COMin_KL6001 AT %I* : KL6InData5B; (* linked to the KL6001 in the TwinCAT System Manager *) COMout_KL6001 AT %Q* : KL6OutData5B; (* linked to the KL6001 in the TwinCAT System Manager *) TxBuffer1: ComBuffer; (* Transmit data buffer; used with all receive function blocks *) RxBuffer1: ComBuffer;END_VAR===================================================================================(*Background communication*) Mode:= SERIALLINEMODE_KL6_5B_STANDARD, pComIn:= ADR(COMin_KL6001), (* I/O data; see global variables *) pComOut:= ADR(COMout_KL6001), (* I/O data; see global variables *) SizeComIn:= SIZEOF(COMin_KL6001), (* I/O data; see global variables *) TxBuffer:= TxBuffer1, (* transmit buffer; see global variables *) RxBuffer:= RxBuffer1, (* receive buffer; see global variables *) Error=> COMportControlError, ErrorID=> COMportControlErrorID);(*KL6001 Configuration*)S1:=TRUE;KL6001_CONFIG(Execute:=S1,Mode:=SERIALLINEMODE_KL6_5B_STANDARD,Baudrate:=9600,NoDatabits:=8,Parity:=PARITY_NONE,Stopbits:=1,Handshake:=HANDSHAKE_XONXOFF,ContinousMode:=0,pComIn:=ADR(COMin_KL6001),pComOut:=ADR(COMout_KL6001),SizeComIn:=SIZEOF(COMin_KL6001));S1:=FALSE;(*Byte reception*)REPEATfbReceiveByte(RxBuffer:=RxBuffer1); IF fbReceiveByte.ByteReceived THEN H1:=TRUE; END_IFUNTIL NOT fbReceiveByte.ByteReceivedEND_REPEATClearComBuffer1(Buffer:=RxBuffer1);

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0