551 482 01

Info Note

 

Communication with a PD 6xx module from a PD 602 through a P-NET Gateway service.

 

System overview

 

Building the address

The IP addresses used in this example should be replaced with the actual IP addresses of a specific network.

 

Note that a DPI is the only module that needs to add a port number to the address field. The PD 664, TCPNode, InternalNodes and UDPNode don’t add port numbers to the address field.

 

In this example the IPNetTable in the P-NET Gateway service will not be configured.  Be-cause of this, the Source IPNetID in the PD 602 address field can be set to any value between 1 and 124. The P-NET Gateway service will use its dynamic IP table to send the response back to the PD 602. In this example the Source IPNetID has been set to “2”.

 

The only difference between the addresses between the Module A and Module B is that  the packet has to go through the internalNode on InternalNet1. Because of this a single “2” needs to be added to the ad-dress field.

 

From PD 602 to Module A

Out of PD 602 (Port 1)

Source IPNetID (Defines on which Net the PD 602 is located – Set to a value between 1 and 124)

On to a node on Ethernet (Net No. 1)

On to UDPNode Node 20

On to TCPNode Node 4

Out on LightLink to hit Module A Node 40

 

PD_6xx_FreeRun : LongInteger[devicetype:1000] AT NET: (1,2,1,20,4,40) SOFTWIRE: $7;

 

From PD 602 to Module B

Out of PD 602 (Port 1)

Source IPNetID (Which Net is the PD 602 located on – Set to a value between 1 and 124)

On to a node on Ethernet (Net No. 1)

On to UDPNode Node 20

On to InternalNode 2

On to TCPNode Node 4

Out on LightLink to hit Module A Node 40

 

PD_6xx_FreeRun : LongInteger[devicetype:1000] AT NET: (1,2,1,20,2,4,40) SOFTWIRE: $7;

 

 

Setting up the PD 602

IPNetTable

Goto “EthernetPort.IPNetTable.IPNets[1]”

Write the IP address of the PC running the P-NET Gateway service 192.168.10.223

IPAddr.b[0] = 192

IPAddr.b[1] = 168

IPAddr.b[2] = 10

IPAddr.b[3] = 223

 

Set the UDPPort to 34380 – (Nodeaddress of P-NET Gateway service – Default is “20”)

UDPPort = 34380-20 = 34360   

 

Set UsePassword = False

 

Set Router = The last digit of the Default gateways IP address.

If the default gateway for the PD 602 is 192.168.10.1 then router should be set to 1.

 

Set IPNetType = 2 (UDPRange net)

 

MaxResponseTime

Set “Service.WriteEnable” = True

Set “EthernetPort.SpecialFeatures.MaxResponseTime” to the expected response time for a transmission. Keep in mind that GPRS communication has a relatively long roundtrip time. An initial value of 5 seconds is recommended. If transmission errors occur, try setting MaxResponseTime to a higher value.

 

Example PP code

The following PP code will try to read the FreeRun timer of a module through the P-NET Gateway service.

 

PROGRAM PD602 [ObjectType = 6000; capabilities = ExtendedPNET ; RAMStart = EFF000];

 

(*$I'PD602v119.SYS'*)

 

{$MIB MIB_Invisible, MIB_NoBackup}

 

(*$I'..\inc\PD60XSafetyVars.inc'*)  (* Declaration of 15 "safe" variables *)

 

{$MIB MIB_Visible, MIB_ReadAccess, MIB_WriteAccess, MIB_Backup}

                            (* Default backup from here *)

(*$I'..\inc\Pd60XFlash.INC'*)

 

VAR

  PD6xx_FreeRun : LongInteger[Devicetype:1000] AT NET: (1,2,1,20,2,4,40) SOFTWIRE: $7; 

  MyPD6xx_FreeRun :LongInteger;

 

TASK PD602Dummy;

BEGIN

  Loop

    ChangeTask;

  End;

END;

 

Please note the GPRS communication has a relatively long roundtrip time. If a TimedInterrupt Tasks is used, is it advisable to use the principle shown below to avoid that the program is blocked in the period where the transmission takes place.

 

{This task will read the PD6xx FreeRun timer every 10 seconds.}

Task Read_PD6xx_FreeRun TimedInterrupt:10.0;

BEGIN

  Enable(AutoChangeTask);             (* Enable ChangeTask while

                                       a transmission takes place *)

  Loop

    CyclicTask;                       (* Change to CyclicTask *)

    MyPD6xx_FreeRun := PD6xx_FreeRun; (* Read PD6xx FreeRun *)

    TimedTask;                        (* Change back to TimedTask *)

    ChangeTask;

  End;

END;            

END.