Fuji Electric PXG-9 Communication Instruction Manual page 77

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

Advertisement

' Sending the command. ***********************************************************************
' Creating CRC for Send Data
GoSub 10000
Txdat(Txsu + 1) = CRC1
Txdat(Txsu + 2) = CRC2
' Send the created command.
MSComm1.Output = Txdat
' Wait until all of the response data is sent.
Start = Timer
Do While Timer < Start + PauseTime
DoEvents
If ((Start + PauseTime) - Timer) > PauseTime Then
Start = Timer
End If
Loop
MSComm1.PortOpen = False
Write_command.Enabled = True
Exit Sub
' ********************************************************************************************
10000
' CRC calculation subroutine IN:Txdat(Txsu) / OUT CRC1,CRC2 **************************
CRC = &HFFFF
For i = 0 To Txsu Step 1
CRC = CRC Xor Txdat(i)
For J = 1 To 8 Step 1
CT = CRC And &H1
If CRC < 0 Then CH = 1 Else: CH = 0: GoTo 11000
CRC = CRC And &H7FFF
11000
CRC = Int(CRC / 2)
If CH = 1 Then CRC = CRC Or &H4000
If CT = 1 Then CRC = CRC Xor &HA001
Next J
Next i
CRC1 = CRC And &HFF
CRC2 = ((CRC And &HFF00) / 256 And &HFF)
Return
End Sub
' CRC computation
'
'
' Send one byte
' Saves the waiting start time.
' Has the set wait time passed?
' Passes control to other processes.
' COM port close
– 75 –
Chapter
8

Hide quick links:

Advertisement

Chapters

Table of Contents
loading

This manual is also suitable for:

Pxg-5Pxg-4

Table of Contents