Application examples

The visualisation data described in the previous section can be read using the following applications, for example.

ADS access via Object Browser

The operator selects contour visualisation as processing mode before program start. This setting is forwarded to the PLC via a so-called controller which the PLC can permit or reject.

In the same way, the PLC also has the option to select the processing mode = rapid contour visualisation without previous HMI request.

ADS access via Object Browser
ADS access via Object Browser

ADS access via Win32 application

Programing Example

prg_example

ADS access via Win32 application

static BOOLEAN writeContourParameters(

UNS16 channel_nr, UNS32 grid, REAL64 abs_error, REAL64 rel_error)

{

  SGN32 result;

  SGN32 idx_group = 0x20100 + channel_nr;

  if ((channel_nr < 1) || (channel_nr > SYS_KANAL_MAX))

    return FALSE;

  result = AdsSyncWriteReq( &amsCom,     // Ams address of ADS server

                            idx_group,   // index group:

                            0x89,        // index offset:

                            sizeof(grid),// count of bytes
                                            to read

                            &grid);      // pointer to the
                                            client buffer

  if (0 != result)

    return FALSE;

  result = AdsSyncWriteReq( &amsCom,     // Ams address of
                                            ADS server

                            idx_group,   // index group:

                            0x8c,        // index offset:

                            sizeof(abs_error),// count of
                                                 bytes to
                                                 read

                            &abs_error);  // pointer to the
                                             client buffer

  if (0 != result)

    return FALSE;

  result = AdsSyncWriteReq( &amsCom,     // Ams address of ADS server

                            idx_group,     // index group:

                            0x8B,          // index offset:

                            sizeof(rel_error),// count of
                                                 bytes to
                                                 read

                            &rel_error);  // pointer to the
                                             client buffer

  if (0 != result)

    return FALSE;

  return TRUE;

}

static BOOLEAN activateContourVisu( UNS16 channel_nr)

{

  SGN32 result;

  SGN32 idx_group = 0x20100 + channel_nr;

  UNS32 execution_mode = SOLLKON;

  if ((channel_nr < 1) || (channel_nr > SYS_KANAL_MAX))

    return FALSE;

  result = AdsSyncWriteReq( &amsCom,      // Ams address of ADS server

                            idx_group,     // index group:

                            0x3f,          // index offset:

                            sizeof(execution_mode),

                            &execution_mode);

  if (0 != result)

    return FALSE;

  return TRUE;

}

static BOOLEAN readContourData (

SOLLVISU_PDU_CHAN *p_visu_pdu, UNS16 channel_nr)

{

  SGN32 result;

  UNS32 count;

  UNS32 fifo_count;

  SGN32 idx_group = 0x20100 + channel_nr;

  if ((channel_nr < 1) || (channel_nr > SYS_KANAL_MAX))

    return FALSE;

  // Read number of entries in visualisation FIFO output

  result = AdsSyncReadReqEx( &amsCom, // Ams address of ADS server

                             idx_group,  // index group:

                             0x2001,     // index offset:

                             sizeof(fifo_count),

                             &fifo_count,

                             &count);

  if (0 != fifo_count)

{

    // Data present, read via COM

    result = AdsSyncReadReqEx( &amsCom,   // Ams address of ADS server

                            idx_group,     // index group:

                               0x2000,        // index offset:

                               sizeof(*p_visu_pdu),

                               p_visu_pdu,

                               &count)

    if (0 == result)

  return TRUE;

}

    return FALSE;

}

Display of axis positions in DXF format

Programing Example

prg_example

Display of axis positions in DXF format

%contour_visu

N001 G01 G90 X0 Y0 Z0 F1000

N100 X100

N200         Y100

N300 X0

N400 Y0

N500 X50 Y50 Z200

N500 X100 Y100 Z0

N600 X0

N700 X50 Y50 Z200

N800 X100 Y0 Z0

N900 G02 I100

N1000 #CS ON[0,0,100, 45 ,0,0]

N1001 G01 G90 X0 Y0 Z0 F1000

N1100 X100

N1200       Y100

N1300 X0

N1400 Y0

N1500 X50 Y50 Z200

N1500 X100 Y100 Z0

N1600 X0

N1700 X50 Y50 Z200

N1800 X100 Y0 Z0

N1900 G02 I100

N1500 #CS OFF

N2000 #CS ON[0,100,-100, 0, 45,0]

N2001 G01 G90 X0 Y0 Z0 F1000

N2100 X100

N2200       Y100

N2300 X0

N2400 Y0

N2500 X50 Y50 Z200

N2500 X100 Y100 Z0

N2600 X0

N2700 X50 Y50 Z200

N2800 X100 Y0 Z0

N2900 G02 I100

N2500 #CS OFF

M30

The read-out axis positions can be used to display the actual path motion in DXF format.

DXF output file

0

SECTION

  2

HEADER

999

isg.dxf created by TwinCAT CNC

0

ENDSEC

0

SECTION

  2

TABLES

0

ENDSEC

0

SECTION

  2

BLOCKS

0

ENDSEC

0

SECTION

  2

ENTITIES

0

LINE

  8

0

62

  2

10

0.000000

20

0.000000

30

0.000000

11

10.000000

21

0.000000

31

0.000000

0

...

Display of the DXF output file in a viewer
Display of the DXF output file in a viewer