Applied-motion SV7-Q-EE Bedienungsanleitung Seite 15

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 19
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 14
6/26/2010
9200032a3eSCLCommunicationReferenceManual Page15
switchsettingsofyourdrive.Youcanedittheaddressesandclick“SavetoDrive”toinstallanewsetof
addressesinyourdrive.YoucanalsosaveacopyoftheIPaddresstabletoafilebyselecting“SavetoFile”.
AftersavinganewsetofIPaddressestoyourdrive,thedrivewillcontinuetocommunicateusingitsexistingIP
addressuntilyoucyclepower.
AppendixB:ExampleUDPPrograms
Allexampleprogramsareavailablefordownloadatwww.applied
motion.com/ampinfo/software/samplecode/.Youshouldstillreadthissectionsothatyouunderstandthekey
elementsofthecodeandwhattradeoffsyoumayencounter.
VisualBasic6
EventhoughVB6isanolderlanguage,itsrefreshingsimplicitymakesitacompellingchoiceforquickly
developinganEthernetapplication.
TocommunicateoverEthernetUDPfromVB6,you’llneedtheWinsockcontrol(MSWINSCK.OCX),whichis
includedintheProfessionalandEnterpriseeditionsofthelanguage.ToconfigureaninstanceofWinsock,you
mustspecifytheprotocolasUDP,choosealocalportnumber,andsettheremoteIPaddressandportnumber
tomatchthedrive.Inthecodeexamplebelow,7775istheportofthedrive.driveIPaddressistheIPaddress
ofthedrive(“10.10.10.10”or“192.168.0.130”forexample).7777istheportofthePC.
Winsock1.RemotePort = 7775
Winsock1.RemoteHost = driveIPaddress
Winsock1.Protocol = sckUDPProtocol
Winsock1.Bind 7777
// if port 7777 is in use by another application, you will get an error.
// that error should be trapped using the On Error statement
// and an alternate port should be chosen.
Sending“RV”command:
Dim myPacket(0 to 4) as Byte ‘ declare a byte array just large enough
myPacket(0) = 0 ‘ first byte of SCL opcode
myPacket(1) = 7 ‘ second byte of SCL opcode
myPacket(2) = “R” ‘ R
myPacket(3) = “V” ‘ V
myPacket(4) = vbCR ‘ carriage return
Winsock1.SendData myPacket
Toreceivearesponse,youwillneedtoplacesomecodeintheWinsock_DataArrivalevent.Thiseventis
automaticallydeclaredassoonasyouaddaWinsockcontroltoyourform.TheDataArrivaleventwill
automaticallytriggereachtimeapacketis received. ThecodebelowextractstheSCLresponsefromtheUDP
payloadanddisplaysitinamessagebox.
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim udpData() As Byte, n As Integer
Dim hexbyte As String, packetID As Long, SCLrx As String
Winsock1.GetData udpData
' remotehost gets clobbered when packet rec'd,
Seitenansicht 14
1 2 ... 10 11 12 13 14 15 16 17 18 19

Kommentare zu diesen Handbüchern

Keine Kommentare