Examples | Shop
 
Networking OOPicII+ Modules


 
This example demonstrates how two OOPicII+ modules can be networked together to create a larger programming environment.

This application shows use of one OOPic as a Master and one as a Slave. The master sends an incrementing value to the slave. When the slave receives a new value, it outputs it onto the SLCD216 serial LCD module.


Connections
The two oopics can be networked together using the network cable and terminator accessory.

Slave
IIC Header - Master IIC Header
Power - 6V-15V
Pin 26 - Si on the SLCD216
Pin 24 (GND) - GND on the SLCD216
Pin 22 (+5V) - +5V on the SLCD216

Master
IIC Header - Slave IIC Header
Power - 6V-15V

When connected, download the Slave.osc code to the slave oopic and the Master.osc code to the master oopic.

The Slave LCD will display the value sent from the master.


Download the master and slave code (.osc) here.

 

'***************************************************************************
'***************************************************************************
'MASTER CODE
'Description: This code sets up the master OOPic in a 2 oopic Network. It sends an incrementing value to ‘the slave oopic.
'
'Compiler Version: 5.01 (B2.2+) OOPicII+
'Created: 02/01/03 Revision 1.00
'Written By:Total Robots (Jamie Finnan)
'
'***************************************************************************
'***************************************************************************
Dim Master as new oDDELink 'IIC Link to slave
Dim Val As New oByte 'Store
'***************************************************************************
Sub Main()
Val = 0
OOPic.Node = 1 'Node of oopic to write to
Master.Input.Link(Val.Value) 'Send Val over the network
Master.Node = 2 'Set the master Node
Master.Location = 41 'Master address
Master.Direction = cvSend 'Master is going to send data
Master.Operate = cvTrue 'Open link
Do
If Master.Transmitting = cvFalse then 'If the master has sent a value then
Val = Val + 1 'Increment the value sent
Master.Sync = 1
oopic.delay = 80 '0.8 second delay
End if
Loop 'Loop construct
End Sub
'***************************************************************************
'***************************************************************************

'***************************************************************************
'***************************************************************************
'SLAVE CODE
'Description: This code sets up the Slave OOPic in a 2 oopic Network. It receives a value from the master ‘and displays it on the SLCD216 serial LCD module.
'
'Compiler Version: 5.01 (B2.2+) OOPicII+
'Created: 02/01/03 Revision 1.00
'Written By:Total Robots (Jamie Finnan)
'
'***************************************************************************
'***************************************************************************
Dim Slave As New oDDELink 'IIC link to master
Dim LCD As New oLCDSE 'LCD object
Dim Val As New oByte 'A store
Dim Inc As New oByte 'Another store
'***************************************************************************
Sub Main()
Inc = 0
OOPic.Node = 2 'Set Node of OOPic to read from
Slave.Output.Link(Val.Value) 'Connection to the master oopic
Slave.Operate = cvTrue 'Open link
LCD.IOLine = 31 'LCD output line
Do
If Val <> Inc then 'If Val does not equals Inc then
LCD.Clear 'Clear the LCD screen
LCD.String = "Value is "+Str$(Val) 'Send value received from master
End if
Inc = Val
oopic.delay = 20 'small 0.2 second delay
Loop 'loop
End Sub
'***************************************************************************
'***************************************************************************

Examples | Shop