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 Tue Sep 17, 2019 11:23 am

All times are UTC+01:00




Post new topic  Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Thu Mar 15, 2018 11:44 am 
Offline

Joined: Wed Mar 07, 2018 2:16 pm
Posts: 2
Greetings.

I have an PFC200 PLC from WAGO (750-8208), which has a RS232 / RS485 port on the front.

I would like to use that port to communicate with an external device using a custom RS485 protocol (i.e. not modbus rtu). I have implemented using the SysLibCom library and tested the protocol code using the simulator. I cannot get the communication to work when connecting the PLC to the device, or even to my laptop via a FTDI RS485 dongle. I suspect that something is not right in the com port setup on the PLC.

Maybe I'm missing something obvious, but I can't see a way to tell SysLibCom that COM0 should be treated as an RS485 port and not a RS232. Can anyone tell me how to do this? Is it even necessary?

My code looks like this:

Code:
PROGRAM PT100_PRG
VAR
   sComSettings: COMSETTINGS;
   ePort : PORTS := COM0;
   bIsConfigured: BOOL := FALSE;
   bIsOpen: BOOL := FALSE;
   dwHandle: DWORD;
   dwErrorCount : DWORD := 0;
END_VAR

VAR CONSTANT
   bAddress : BYTE := 0;
   dwErrorHandle : DWORD := 16#FFFFFFFF;
END_VAR

(* implementation starts here *)

IF bIsOpen = FALSE THEN
   bIsConfigured := FALSE;
   dwHandle := SysComOpen(ePort);

   IF dwHandle <> dwErrorHandle THEN
      bIsOpen := TRUE;
   END_IF
END_IF


IF bIsOpen = TRUE AND bIsConfigured = FALSE THEN
   sComSettings.byParity := 0;
   sComSettings.byStopBits := 0;
   sComSettings.dwBaudRate := 38400;
   sComSettings.dwTimeout := 0;
   sComSettings.dwBufferSize := 0;
   sComSettings.dwScan := 0;

   IF SysComSetSettings(dwHandle, ADR(sComSettings)) = TRUE THEN
      bIsConfigured := TRUE;
   END_IF
END_IF

(* ... and some write logic here *)



Thanks in advance.

/Mikkel


Top
   
PostPosted: Tue Apr 03, 2018 8:04 pm 
Offline

Joined: Tue Feb 07, 2017 11:03 pm
Posts: 5
Are you sure that it's COM0 not COM1?


Top
   
PostPosted: Tue Apr 03, 2018 8:33 pm 
Offline
Frequent User
Frequent User

Joined: Fri Sep 02, 2011 8:02 pm
Posts: 304
It is typically a hardware setup, not on the coding side. On some controllers, it is a BIOS setting. Perhaps it is a configuration selection however you setup the hardware (WAGO specific).

_________________
Scott Cunningham
KEB America, Inc.
www.kebblog.com
www.kebamerica.com


Top
   
PostPosted: Wed May 09, 2018 1:09 pm 
Offline

Joined: Wed Mar 07, 2018 2:16 pm
Posts: 2
Thanks for the inputs. With the help of WAGO support, I found the solution which I'm posting here for future reference.

When using the RS232/RS485 port on the PFC200 module, make sure to:

  • Use Serial_Interface_01.lib from the PFC200 library folder
  • Use COM0
  • Set flowcontrol to half-duplex for RS485

What tripped me, was using the "wrong" library, not that it was documented anywhere that I could find.

/Mikkel


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

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 2 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