CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Fri Oct 18, 2019 7:42 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Oct 21, 2013 11:47 am 
Offline

Joined: Thu Oct 17, 2013 12:50 pm
Posts: 4
Hi

I am new to this forum and I am just beginning to us codesys.

I am trying to get communication between berghof EC1000 and roboteq 2130. I am using 232 serial port. I am using a program I got from the codesys store ( http://store.codesys.com/serial-com.html ). I am using Codesys v3.5 SP1 Patch 4.

My problem is that I can send one message through the serial port whit out any problems, but when I try to do it again nothing happens. Then I have to logout from the project and download it again to be able to send the messages again.

Can anybody please help me with this problem?


Top
   
PostPosted: Wed Oct 23, 2013 5:21 pm 
Offline

Joined: Thu Oct 17, 2013 12:50 pm
Posts: 4
I have tried it with and without handshake. I have also tried it without closing the port between sending messages. Here is the code I am using.



IF xStartTest THEN

//The parameters are set for the COM Port
aCom1Params[1].udiParameterId := COM.CAA_Parameter_Constants.udiPort;
aCom1Params[1].udiValue := 1; // the correct Port should be adapted
aCom1Params[2].udiParameterId := COM.CAA_Parameter_Constants.udiBaudrate;
aCom1Params[2].udiValue := 115200;
aCom1Params[3].udiParameterId := COM.CAA_Parameter_Constants.udiParity;
aCom1Params[3].udiValue := COM.PARITY.NONE;
aCom1Params[4].udiParameterId := COM.CAA_Parameter_Constants.udiStopBits;
aCom1Params[4].udiValue := COM.STOPBIT.ONESTOPBIT;
aCom1Params[5].udiParameterId := COM.CAA_Parameter_Constants.udiTimeout;
aCom1Params[5].udiValue := 0;
aCom1Params[6].udiParameterId := COM.CAA_Parameter_Constants.udiByteSize;
aCom1Params[6].udiValue := 8;
aCom1Params[7].udiParameterId := COM.CAA_Parameter_Constants.udiBinary;
aCom1Params[7].udiValue := 0;

// Handshake Paramet

//aCom1Params[8].udiParameterId := COM.udiDtrControl;
//aCom1Params[8].udiValue := 16#02; // handshake
//aCom1Params[9].udiParameterId := COM.udiOutxDsrFlow;
//aCom1Params[9].udiValue := 1; // true
//aCom1Params[10].udiParameterId := COM.udiRtsControl;
//aCom1Params[10].udiValue := 16#02; // handshake
//aCom1Params[11].udiParameterId := COM.udiOutxCtsFlow;
//aCom1Params[11].udiValue := 1; // true

// Handshake Parameter

aCom1Params[8].udiParameterId := COM.udiInX;
aCom1Params[8].udiValue := 1; // true
aCom1Params[9].udiParameterId := COM.udiXonChar;
aCom1Params[9].udiValue := 17;
aCom1Params[10].udiParameterId := COM.udiXonLim;
aCom1Params[10].udiValue := 2048;
aCom1Params[11].udiParameterId := COM.udiOutX;
aCom1Params[11].udiValue := 1; // true
aCom1Params[12].udiParameterId := COM.udiXoffChar;
aCom1Params[12].udiValue := 19;
aCom1Params[13].udiParameterId := COM.udiXoffLim;
aCom1Params[13].udiValue := 512;
aCom1Params[14].udiParameterId := COM.udiTXContinueOnXoff;
aCom1Params[14].udiValue := 0; // false




END_IF


IF xPortOpen THEN
//The first Port is opened with the given parameters
como1(xExecute := TRUE, usiListLength:=SIZEOF(aCom1Params)/SIZEOF(COM.PARAMETER),pParameterList:= ADR(aCom1Params));

IF como1.xError THEN
xCom1OpenError := TRUE;
iState := 1000;
END_IF
IF como1.xDone THEN
iState := 10;
END_IF

END_IF

IF xWrite THEN
// the write process is started for the first port
comw1(xExecute := TRUE,hCom:= como1.hCom,pBuffer:= ADR(sWrite),szSize:= SIZEOF(sWrite));

IF comw1.xError THEN
xCom1WriteError := TRUE;
END_IF

// if the writing process is completed the reading process can be started
IF comw1.xDone THEN
iState := 15;
END_IF
END_IF

IF xPortClose THEN

// The first port is closed and the used handle released
comc1(xExecute := TRUE, hCom:= como1.hCom);

IF comc1.xError THEN
xCom1CloseError := TRUE;
END_IF

IF comc1.xDone OR comc1.xError THEN
iState := 1000;
END_IF
END_IF


Top
   
PostPosted: Tue Oct 29, 2013 9:09 pm 
Offline
Frequent User
Frequent User
User avatar

Joined: Tue Jun 06, 2006 9:03 am
Posts: 410
You call comw1 only with execute := true.
This is the trigger to start.
To trigger it again, call the FB with execute := false at least one time in between.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited