EasyManua.ls Logo

Fuji Electric PXG-9 - Page 76

Fuji Electric PXG-9
84 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
– 74 –
8
Chapter
' Setting the Communication Number for the Other Party ***************************************
St = Val(Stno1(idx).Text)
Stno = St Mod 256
Stno1(idx).Text = Str(Stno)
' Processing the Address *********************************************************************
AD$ = Str(Val(Address(idx).Text) - 1)
AD$ = Right$(("00000" & AD$), 5)
Area = Val(Left$(AD$, 1))
Adrsh = Int(Val(Right$(AD$, 4)) / 256)
Adrsl = Val(Right$(AD$, 4)) Mod 256
'Creating the Send Command *******************************************************************
Select Case Area
Case 4
'Normal sending data is processed.
Dim byteData(3) As Byte
Dim sHex As String
sHex = Right("00000000" & Hex(Val(Write_data.Text)), 8) 'Decimal to hexadecimal
byteData(0) = CByte("&H" & Mid(sHex, 1, 2)) 'hh byte
byteData(1) = CByte("&H" & Mid(sHex, 3, 2)) 'hl byte
byteData(2) = CByte("&H" & Mid(sHex, 5, 2)) 'lh byte
byteData(3) = CByte("&H" & Mid(sHex, 7, 2)) 'll byte
ReDim Txdat(12) As Byte ' 13 bytes
Txdat(0) = Stno ' Station No.
Txdat(1) = &H10 ' Command
Txdat(2) = Adrsh ' High address
Txdat(3) = Adrsl ' Low address
Txdat(4) = &H0 ' Write no. of words (High)
Txdat(5) = &H2 ' Write no. of words (Low)
Txdat(6) = &H4 ' Write no. of bytes
Txdat(7) = byteData(2) ' Write data (Lo high)
Txdat(8) = byteData(3) ' Write data (Lo lo)
Txdat(9) = byteData(0) ' Write data (High high)
Txdat(10) = byteData(1) ' Write data (High lo)
Txsu = 10 ' No. of sent data
Case Else ' For other values
MSComm1.PortOpen = False ' COM port close
Write_command.Enabled = True
Exit Sub
End Select

Related product manuals