Tibbo DS100 Tutorial

Using visual basic (vb) to communicate with the device

Advertisement

Tibbo
VB Tutorial
TECHNOLOGY
Using Visual Basic (VB) to communicate with the
DS100 and EM100
Please, register at
www.tibbo.com
to receive update notifications
Version: 2.0a
Tibbo Technology, Inc. 2001, 2002

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the DS100 and is the answer not in the manual?

Questions and answers

Summary of Contents for Tibbo DS100

  • Page 1 Tibbo VB Tutorial TECHNOLOGY Using Visual Basic (VB) to communicate with the DS100 and EM100 Please, register at www.tibbo.com to receive update notifications Version: 2.0a Tibbo Technology, Inc. 2001, 2002...
  • Page 2: Table Of Contents

    Setting up the DS100/EM100SK 2.6. Testing the LAN link Creating the WinSock Demo 3.1. WinSock Demo action plan 3.2. Step 1: creating a simple UDP/IP Demo 3.3. Step 2: learning to control the DS100/EM100 over the network 3.4. Step 3: TCP/IP communications...
  • Page 3: Introduction

    EM100 Ethernet Module from Tibbo Technology support standard UDP and TCP protocols the WinSock can also be used to build applications that communicate with and control the DS100 and EM100. This Tutorial provides step-by-step instructions on using VB to create three rudimentary programs (called “WinSock Demos”) that communicate with and program the DS100/EM100 over the network.
  • Page 4: Preparing The Ds100/Em100Sk

    2.1. Connecting cables To test out the WinSock Demos you will need to connect the Ethernet port of the DS100/EM100SK to the LAN (to which your test PC is also connected), and the RS232 port- to the PC’s COM port. Our WinSock Demos will communicate with the DS100/EM100SK directly via the Ethernet (which is a TCP/IP network).
  • Page 5: Choosing An Ip-Address

    Note: The Ethernet port of the DS100/EM100SK is of 10BaseT type, not 100BaseT. You can use the DS100/EM100SK on “10” or “Auto 10/100” LANs, but not on “100” LANs. WinSock WinSock Demo Demo Hyper Hyper Terminal Terminal Test PC Test PC...
  • Page 6 • Use our WAS-1498 cable to directly connect your PC to the DS100/EM100SK. This way you will disconnect from the rest of the LAN (a lot of possible problems will be cut out…) • Use the WINIPCFG program to find out the IP-address of your PC (see explanation below). In 99% of cases, choosing the address for the DS100/EM100SK that differs slightly from your PC’s IP-...
  • Page 7: Installing The Hyperterminal

    HyperTerminal. This program is also used here to setup the DS100/EM100SK. Actually, there is a setup software called DS Manager (part of Tibbo Device Server Toolkit available for download from www.tibbo.com/downloads.htm) that can be used to setup the DS100/EM100SK.
  • Page 8: Setting Up The Hyperterminal

    2.4. Setting up the HyperTerminal Once the HyperTerminal is installed (or found ☺), launch it and follow the procedure below: • When the Connection Description dialog opens, type any descriptive string (like “DS100”) and press OK • When the Connect to dialog opens, select an appropriate COM port from the Connect Using drop- down box (for example, “Direct to COM1”)
  • Page 9: Setting Up The Ds100/Em100Sk

    Green Status LEDs blink three times) • Push the Setup Button (it is on the back of the DS100 and on the PCB of the EM100SK) - both Status LEDs will start blinking (Red-Green-Red-Green-…)- the DS100 is now in the Serial Programming mode (read all about it in Section 4.2.
  • Page 10: Testing The Lan Link

    After the initialization the DS100 is set to work in the Slave Routing Mode, with the UDP/IP communications protocol. The data exchange is to be effected with Data Port #1001. OK, now disconnect the DS100’s power and then connect it again- the unit will resume operation with the new functioning parameters.
  • Page 11 DS100/EM100SK does, indeed, reply to your PC’s “pinging”. Obtaining a “good ping” from the DS100/EM100SK is a required step in setting up your test network. Nothing will work as expected unless your PC can find the DS100/EM100SK by “pinging” it.
  • Page 12: Creating The Winsock Demo

    • In step 2 we will show how to program (setup) the DS100/EM100 over the network. Same UDP/IP protocol will be used, but this time to communicate with the Command Port of the DS100/EM100SK • In step 3 we will show how to exchange data with the DS100/EM100 using the TCP/IP protocol.
  • Page 13 Scroll down to Microsoft Winsock Control 6.0 and “check” it Click OK- the Winsock control will be added to your project’s Toolbox • Add the following controls to your Project’s form (see Fig. 3): Fig. 3. Controls for the Demo, step 1 CmdSend CommandButton (change its Caption property to “Send”) TxtSend TextBox (change its Text property to “”, i.e.
  • Page 14 WinSock control, adjust its properties as follows: Protocol: 1-sckUDPProtocol RemoteHost: 192.168.100.40 (or whatever IP-address you’ve set for the DS100/EM100SK) RemotePort: 1001 (must be specified!) • Add the following code to the project: For the Click event of the CmdSend button: Private Sub CmdSend_Click() WinSock.SendData TxtSend.Text...
  • Page 15: Step 2: Learning To Control The Ds100/Em100 Over The Network

    3.3. Step 2: learning to control the DS100/EM100 over the network The DS100/EM100 can be programmed (setup) over the network (see Section 4.3 of the DS100 Tech Manual). Programming commands are sent as UDP datagrams (one datagram per command) to the DS100/EM100’s Command Port whose number is fixed at 65535.
  • Page 16 Run the Demo again • In the Send textbox type “V” and click Send, the DS100/EM100 will respond with its version string, i.e. “V2.20” You can type most commands like this. Right now we will show you how to change the Transport Protocol (i.e.
  • Page 17 End Sub There is another bug in the WinSock control. Without the line that repeatedly assigns “255.255.255.255” each time you are about to send the datagram the WinSock will not always process all the replies from all the DS100/EM100s! •...
  • Page 18: Step 3: Tcp/Ip Communications

    • Stop the Demo • If you have assigned a new IP-address to the DS100/EM100 in the previous section then change the RemoteHost property of the WinSock control accordingly • Change the RemotePort property of the WinSock back to 1001...
  • Page 19 • Change the Protocol property of the WinSock control to “0- sckTCPProtocol” (you have already switched the DS100/EM100 to TCP/IP earlier) • Change the Enabled property of the CmdSend button to “Disabled” (because the data cannot be sent unless the connection is established) •...
  • Page 20 Case 8: LblState.Caption = "Peer closing" Case Else: LblState.Caption = "Error" End Select 'set the caption of the "Connect" button If WinSock.State = 0 Then CmdConnect.Caption = "Connect" Else CmdConnect.Caption = "Disconnect" End If 'enable or disable the "Send" button If WinSock.State = 7 Then CmdSend.Enabled = True Else...
  • Page 21 Click Connect button. The Status will change to “Connecting”, then to “Connected”. If the program cannot connect to the DS100/EM100 (because the device is off, because you are connecting to a wrong IP-address, because somebody is already connected to this DS100/EM100, etc. etc.) then the Status will hang on “Connecting”...

This manual is also suitable for:

Em100Em100sk

Table of Contents