Fuji Electric PXG-9 Communication Instruction Manual page 73

Digtal controller micro controller x communication function (rs-485 modbus)
Hide thumbs Also See for PXG-9:
Table of Contents

Advertisement

' Import the response data into a byte array.
MSComm1.InputMode = comInputModeBinary
length = MSComm1.InBufferCount
MSComm1.InputLen = 0
Rxbuff = MSComm1.Input
Ansdat = Rxbuff
' Calculating CRC for Received Data
Ansu = length - 3
GoSub 20000
' Error check
If (length = 0) Then
Noans = Noans + 1: Rx_data.Caption = "Noans": GoTo 150'
ElseIf ((Ansdat(length - 2) <> CRC1) + (Ansdat(length - 1) <> CRC2)) Then
CRCErr = CRCErr + 1: Rx_data.Caption = "CRCErr": GoTo 150
ElseIf Ansdat(1) >= &H80 Then
CMDErr = CMDErr + 1: Rx_data.Caption = "CMDErr": GoTo 150
End If
' Processing correctly received data
wrk1 = Ansdat(3)
wrk2 = Ansdat(4)
wrk3 = Ansdat(5)
wrk4 = Ansdat(6)
If Ansdat(5) > 128 Then
Rx_data.Caption = Str(((wrk3 * (2 ^ 24)) + (wrk4 * (2 ^ 16)) + (wrk1 * (2 ^ 8)) + wrk2) - (2 ^ 32))
Else
Rx_data.Caption = Str(((wrk3 * (2 ^ 24)) + (wrk4 * (2 ^ 16)) + (wrk1 * (2 ^ 8)) + wrk2))
End If
150
MSComm1.PortOpen = False
TX1.Enabled = True
Exit Sub
' Set binary mode
' Retrieve the no. of sent data bytes
' Set retrieval of all data
' Import received data into the received buffer
' Assign received data into the byte array
' Received data length
' CRC computation
' Received data minus time
' COM port close
– 71 –
' No answer
' CRC error
' Command error
Chapter
8

Hide quick links:

Advertisement

Chapters

Table of Contents
loading

This manual is also suitable for:

Pxg-5Pxg-4

Table of Contents