Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

SysLibCom and RS485 on WAGO PFC200

2018-03-15
2018-05-09
  • mikkelaunsbjerg

    mikkelaunsbjerg - 2018-03-15

    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:

    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

     
  • maniek765

    maniek765 - 2018-04-03

    Are you sure that it's COM0 not COM1?

     
  • Anonymous - 2018-04-03

    Originally created by: scott_cunningham

    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).

     
  • mikkelaunsbjerg

    mikkelaunsbjerg - 2018-05-09

    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:

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

    /Mikkel

     

Log in to post a comment.