ooPIC Logo

ooPIC Programmer's Guide

 Chapter 12 - Dynamic Data Exchange

Back to top of page What is Dynamic Data Exchange?

 Dynamic Data Exchange is a function that allows two or more ooPICs to exchange data. This exchange of data is accomplished by a Virtual Circuit that utilizes oDDELink Objects to transfer data over an I2C Network to or from another ooPIC..

While other processing Objects are used to create Virtual Circuits that manipulate and exchange data with Objects within the same ooPIC, the oDDELink Object is designed to utilize the I2C network to exchange data with other ooPICs.

Back to top of page The oDDELink Object

 The oDDELink Object is a Processing Object that dynamically exchanges data between two ooPICs by transmitting data over an I2C network of which both ooPICs are connected. It can be configured to both send and receive data.

Any properly configured oDDELink Object can initiate a data transfer by setting the Sync property to 1 (cvTrue), thereby causing the data to be either sent to or retrieved from other oDDELink Objects in the network depending on the state of its Direction property.

Back to top of page The DDE Virtual Circuit

 A working knowledge of Virtual Circuits is necessary to understand how the oDDELink Object functions.  If you have not done so already, read Chapter 7 - Your First Virtual Circuit and Chapter 8 - Virtual Circuits.

In order for a Virtual Circuit to be capable of transferring data over the I2C network, an oDDELink Object must be included and linked to other Objects within the ooPIC.  Each Occurrence of the  oDDELink Object has two pointers which are used to link to the Objects which contain the data to be transferred.

The oDDELink Object retrieves the data to be transferred from the Object pointed to by the Input property and the Output property links to the Object that the transferred data will be stored into. 

The oDDELink Object's Sync property, which initiates the data transfer, is an oLogic property and can be controlled by the Virtual Circuit by linking it to other oLogic pointer properties within the Virtual Circuit.

Back to top of page Network Nodes.

 Each ooPIC connected together via an I2C network must be differentiated by a unique Node number. The ooPIC Object's Node property is used to specify this number.  This is the identifier that the I2C network uses to properly route the data when an DDELink transfer is made.

The ooPIC.Node property must be set to a number greater than 0 to turn on the ooPIC's network functions. Once the Node number is set, the I2C network is enabled and starts to listen for incoming data packets. If the ooPIC.Node property is set back to 0 (cvOff), the I2C network is disabled and any incoming data packets are ignored.

It is important to remember to enable the I2C network in both the Master application and the Slave application before the applications attempt to transfer data.

The oDDELink Object also has a Node property.  This property specifies which ooPIC the oDDELink Object is going to be communicating  with.

Back to top of page DDE Conversations.

 When two ooPICs exchange information, they do so by engaging in a DDE conversation. The application that initiates the conversation is called the "Master-Application", or just the "Master"; and the application responding to the Master is the "Slave-Application", or just the "Slave". An application can be configured to engage in several conversations, acting as the Master in some and the Slave in others.

A single oDDELink Object can operate as both the Master and the Slave in a DDELink conversation. In addition, it can act as the Master in a DDELink conversation with one ooPIC, and the Slave in an entirely different DDELink conversation with a different ooPIC.

To initiate a DDELink conversation, the oDDELink Object that is to be used as the Master must be properly configured, pointing to the Node and Location of the Slave oDDELink Object with the Operate property set to 1. Once it is configured, setting the Master's Sync property to 1, initiates the DDELink conversation which synchronizes its data with the Slave.

Back to top of page DDE Masters.

 The Master oDDELink Object always controls the DDE conversation. Whether it is sending data to, or receiving data from the Slave, the Master always initiates the conversation.

In order for the Master to activate a DDE conversation, it must be configured to specify which ooPIC it intends to communicate with and the location of the Slave oDDELink Object within that ooPIC.

To specify the ooPIC that it intends to communicate with, it must set the Master oDDELink Object's Node property to the same number that the Slave application's ooPIC.Node property has been set to.

To specify the Slave oDDELink Object's location, it must set the Master oDDELink Object's Location property to the same number that the Slave oDDELink Object's Address property is set to.  Note: The Address property of all Objects is set when the application is compiled and cannot be changed by the application's program.

In order for the Master to send data, its Input property must be linked to the Object that contains the data to send, and in order for it to receive data, its Output property must be linked to the Object to store the received data into.

How the Master oDDELink Object operates:

When an oDDELink Object's Sync property is set to 1 (cvTrue), it first checks to see if its Operate property is also 1 (cvTrue).  If it is not, the oDDELink Object remains dormant.  If, on the other hand, the Operate property is 1, then the Node and Location properties are checked. If either property is 0.  then the operation is canceled.  If, on the other hand, they are set to values of more than 0, then the DDELink conversation is initiated.

Once a DDELink conversation begins, the Master checks to see how the Direction property is set.  If it is set to 0 (cvSend), then the Master sends data to the Slave, and if it is set 1 (cvReceive), then the Master receives information from the Slave.

When the Master sends data to the Slave, it retrieves the data to send from the Object that its Input property was linked to.  It then sends this data to the Slave which then stores the data into the Object that its Output property is linked to..

When the Master receives data from the Slave, it first sends a request to the slave, which instructs the slave to retrieve the data out of the Object that its Input property is linked to.  The Master then draws this data out of the Slave and stores it in the Object that its Output property is linked to.

The following is an example of an ooPIC application that uses a Master oDDELink Object in a Simple Virtual Circuit.  Note that the ooPIC.Hz1 is not directly linked to the oDDELINK object because you are not allowed to link system (oopic) objects to oDDELINK.

Visual Basic & BASIC syntax C & Java Syntax
Dim Master As New oDDELink
Dim wire As New oWire
Dim hz1 As New oBit

Sub Main()
  wire.Input.Link(ooPIC.Hz1)
  wire.Output.Link(hz1)
  wire.Operate = cvTrue
  ooPIC.Node = 1
  Master.Input.Link(hz1)
  Master.Node = 2
  Master.Location = 43
  Master.Direction = cvSend
  Master.Operate = cvTrue
  Do
    If Master.Transmitting = cvFalse Then
      Master.Sync = 1
    End If
  Loop
End Sub
oDDELink Master = New oDDELink;
oWire wire = New oWire;
oBit hz1 = New oBit;

Void Main(Void){
  wire.Input.Link(ooPIC.Hz1);
  wire.Output.Link(hz1);
  wire.Operate = cvTrue;
  ooPIC.Node = 1;
  Master.Input.Link(hz1);
  Master.Node = 2;
  Master.Location = 43;
  Master.Direction = cvSend;
  Master.Operate = cvTrue;
  Do {
    If (Master.Transmitting = cvFalse) {
      Master.Sync = 1;
    }
  } While (1);
}

Back to top of page DDE Slaves.

 The Slave oDDELink Object continuously monitors the I2C network for DDELink communications from a Master oDDELink Object.  Until it detects a DDELink conversation request from the Master, it remains dormant.

In order for the Slave to engage in an DDELink conversation, it only needs to have its Input and Output properties configured to operate.  The Slave's Operate property does not need to be set to 1 (cvTrue) in order to respond to the masters instructions.

How the Slave oDDELink operates:

When the Slave oDDELink Object is engaged in a DDELink conversation by the Master, it will respond by either sending data to the Master or by receiving data from the Master.

If the Master is requesting data from the Slave, then the Slave responds by retrieved data from the Object pointed to by its Input property, which is then sends to the Master.

If the Master is sending it data to the Slave, then the Slave will wait until the data packet has been received, Once it has the full packet of data, the Slave DDELink Object will copy that data into the Object pointed to be the Output  property.

The following is an example of an ooPIC application that uses a Slave oDDELink Object in a Simple Virtual Circuit.

Visual Basic & BASIC syntax C & Java Syntax
Dim SLAVE As New oDDELink
Dim LED As New oDIO1

Sub Main()
  ooPIC.Node = 2
  LED.IOLine = 31
  LED.Direction = cvOutput
  SLAVE.Output.Link(LED.State)
  SLAVE.Operate = cvTrue
End Sub
oDDELink SLAVE = New oDDELink;
oDIO1 LED = New oDIO1;

Void Main(Void){
  ooPIC.Node = 2;
  LED.IOLine = 31;
  LED.Direction = cvOutput;
  SLAVE.Output.Link(LED.State);
  SLAVE.Operate = cvTrue;
}

Back to top of page I2C Network Connections.

 The I2C network is built in to the hardware of the ooPIC, and runs at 19,200bps. It has 2 5-Pin Network Connectors available on the ooPIC's circuit board which consists of the 5 lines; I2C Serial Data (Data), I2C Serial Clock (Clock), Ground (Gnd), +5 Volts (+5V) and Reset (Rst). The pin out of the 2 5-Pin Network Connectors are identical and can be used to daisy chain the networked ooPICs together.

When connecting ooPICs together with the I2C network, the 3 lines; Data, Clock and Gnd must be connected to each ooPIC on the network, the 2 lines; +5V and Rst can be optionally connected depending on the applications need's.  

2.7k pull up resistors are required on both the Data, Clock lines for the network to operate properly.

BUG: It has been discovered that DDELink does not work between two ooPIC R and/or ooPIC C boards unless there is an ooPIC "S" board (such as an ooPIC I or ooPIC II) in the circuit, even if it is not used, using 22K to 33K pullup resistors on the data and clock lines will usually allow the communication to succeed however.

If the Rst line is connected to each ooPIC on the network, then when any ooPIC's Reset button is pressed, all of the connected ooPICs will also reset. Note: Setting the ooPIC.Reset property to 1 (cvTrue) in any of the network ooPICs does not pull the Rst line low, and therefore will not reset all the ooPICs on the network.


ooPIC Compiler Ver 6.0 (c) Copyright 1997 - 2007 Savage Innovations, LLC.