Hi,
I have an application were need to read a 6 byte telegram on my serialport twice per second (ASCII value from a weightcell).
I'm having troubble getting the wago app.note (serial_interface.lib, sercomm.lib) to work so I figured I could just make the function myself.
In the documentation for the serialmodule (750-653) there is a step by step procedure on how to initialize and read data.
Have anyone tried to do this without using the libraries? just reading and writing byte for byte following the manual.
The default settings in the module looks to be right for the application already so I shouldn't need to change them in my app.
The Wago app. note just gives me "sercomm" built warnings and then a "wrong array index" alarm when I try to run it.
Any tips would be greatly appriciated.
Regards,
Havard
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Havardf hat geschrieben:
Hi,
Have anyone tried to do this without using the libraries? just reading and writing byte for byte following the manual.
I have coded this. It works fine with Wago module 750-650/000-006 (9600/E/8/1). Here is code example
VAR
  TAAT%I*:BOOL;
  RRAT%I*:BOOL;
  IAAT%I*:BOOL;
  IBFAT%I*:BOOL;
  IL0AT%I*:BOOL;
  IL1AT%I*:BOOL;
  IL2AT%I*:BOOL;
  IB1AT%I*:BYTE;
  IB2AT%I*:BYTE;
  IB3AT%I*:BYTE;
  TRAT%Q*:BOOL;
  RAAT%Q*:BOOL;
  IRAT%Q*:BOOL;
  OL0AT%Q*:BOOL;
  OL1AT%Q*:BOOL;
  OL2AT%Q*:BOOL;
  QB1AT%Q*:BYTE;
  QB2AT%Q*:BYTE;
  QB3AT%Q*:BYTE;
  step:BYTE:=0;(*program step*)END_VAR
  CASEstepOF
    (*initialization*)
    0:
      IR:=TRUE; (*set IR*)
      (*clearoutputbytes*)
      OL0:=FALSE;
      OL1:=FALSE;
      OL2:=FALSE;
      QB1:=0;
      QB2:=0;
      QB3:=0;
      xInit_Failed:=FALSE;
      xRead_Failed:=FALSE;
      xWrite_Failed:=FALSE;
      step:=1;(*go to step 1*)
      RETURN;
    (*initializationcheck*)
    1:
      IFIA=TRUETHEN
        (*initializationdone!*)
        step:=2;(*go to step 2*)
      ELSE
        (*initializationfailed, exitprogram*)
        xTrans_Request:=FALSE;
        xInit_Failed:=TRUE;
        step:=0;
      END_IF
      IR:=FALSE; (*reset IR*)
      RETURN;
 Â
    (*writedata*)
    2:
      setbitsOL0-OL2andbytesQB1-QB3respectively
 Â
        (*invertTR*)
        TR:=NOTTR;
        step:=3; (*go to step 3*)
 Â
        (*clearreceivebuffer*)
      RETURN;
    (*checkwriting*)
    3:
      IFTR=TATHEN
        step:=4; (*go to step 4*)
        read_flag:=FALSE;
        (*starttimer*)
      ELSE
        (*writingfailed, exit*)
        xTrans_Request:=FALSE;
        xWrite_Failed:=TRUE;
        step:=0;
      END_IF
      RETURN;
    (*readdata*)
    4:
      (*checkinputbufferoverflow*)
      IFIBFTHEN
        xTrans_Request:=FALSE;
        xRead_Failed:=TRUE;
        step:=0;
        RETURN;
      END_IF
      (*checkdataforreading*)
      IFRR<>RATHEN
        (*checkbitsIL0-IL2andreaddatafrombytesIB1-IB3*)
 Â
        RA:=NOTRA;
 Â
      ELSE
        (*checktimer*)
      END_IF
      RETURN;
  END_CASEELSE
  step:=0;END_IF
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I have an application were need to read a 6 byte telegram on my serialport twice per second (ASCII value from a weightcell).
I'm having troubble getting the wago app.note (serial_interface.lib, sercomm.lib) to work so I figured I could just make the function myself.
In the documentation for the serialmodule (750-653) there is a step by step procedure on how to initialize and read data.
Have anyone tried to do this without using the libraries? just reading and writing byte for byte following the manual.
The default settings in the module looks to be right for the application already so I shouldn't need to change them in my app.
The Wago app. note just gives me "sercomm" built warnings and then a "wrong array index" alarm when I try to run it.
Any tips would be greatly appriciated.
Regards,
Havard
Thanks a lot for that example, just the answer I was looking (and hoping) for!
Regards,
HÃ¥vard