Sample Program - Fuji Electric PXG-9 Communication Instruction Manual

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

Advertisement

Sample Program

This chapter shows a sample program that runs in Microsoft Visual Basic 6.0 (SP6) for reading and writing data.
The program shown here is meant to be used as a reference for your own program creation, and therefore all its actions are not
guaranteed.
Before running the program, check the following summary of points for communication conditions.
• Parity, communication speed to be set in this program. Please match these values with the conditions of the micro controller.
Warning when using an RS-232C to RS-485 converter
The sent data is sometimes added to the response data from the slave before it is received. In this case, when receiving the data,
process the response data only after first getting rid of the number of bytes from the sent data.
Compatible OS
Windows 2000 Professional
Windows XP Professional Edition
• Windows
Caution
• Visual Basic
Fuji Electric Systems Co., Ltd. assumes no responsibility for damages or infringement upon third party rights as a result of using
this sample program.
Use this program while conforming to the contents of the agreement listed within.
■ Example of data reading
• Operation: Reads and displays 2 word data of the set address at once.
Chapter
8
• Function code to be used: 03H, 04H
• Number of read words: 2
' Variable Declaration ***********************************************************************
Dim idx As Integer
Dim Ansdat() As Byte
Dim Rxbuff As Variant
Dim PauseTime
Dim Stno As Byte
Private Sub Form_Load()
' Initializing the Variable ******************************************************************
Stno = 1
Main.Visible = True
End Sub
'------------------------------------------
'Read continuous words sample program
'Function code : 03H, 04H
'Number of words : 2
'------------------------------------------
Private Sub TX1_Click()
TX1.Enabled = False
®
is a registered trademark of the Microsoft Corporation.
®
is a registered trademark of the Microsoft Corporation.
' Response data stack
' Received data buffer
' Sets the communication wait time.
' The necessary wait time changes depending on the
' Communication number
transmission speed and transmission frame length.
– 68 –

Hide quick links:

Advertisement

Chapters

Table of Contents
loading

This manual is also suitable for:

Pxg-5Pxg-4

Table of Contents