beautypg.com

B&B Electronics I-7060 - Quick Start Guide User Manual

Page 32

background image

Getting Started

for I-7000 Series Modules

Date: Jan-08, 2002 Version 1.02 page: 32

Put the second “

CommandButton

” control on the “

Form1

” of this program.

Add following codes in the subroutine “

Command2_Click()

” :

Private Sub Command2_Click()

Port = 2

'Use COM2

'Open COM Port with Baud Rate 9600, 8 DataBits,
‘None Paritybits , One stop bit

Open_Com Port, 9600, 8, 0, 0
SendTo7000 = Space(100)

'Declare the buffer

ReceiveFrom7000 = Space(100)

'Declare the buffer

w7000(0) = Port

'COM port in use

w7000(1) = 1

'Module Address at 0x01

w7000(2) = &H7013

'Module ID is 0x7013

w7000(3) = 0

'Checksum 0:disabled

w7000(4) = 100

'Timeout value is 0.1 second

'Call the function "AnalogIn" to get the value from module
'Parameters are w7000(0), f7000(0),
' SendTo7000, ReceiveFrom7000

AnalogIn

w7000(0), f7000(0), SendTo7000, ReceiveFrom7000

'Use the caption of "Command2" button to show the value

Command2.Caption = f7000(0)

'Close the COM port that the user open previously

Close_Com Port

End Sub

Run the program and click the “

Command2

” button. The caption of

Command2

” button will show the analog input value from the module.

Refer to Figure 3-1-10.

For the first program, it has not processed the returned value of each

function. In normal applications, users have to get the returned value and
process it. For detailed descriptions of every function, please refer to the

NAP7000P

user’s manual. The

NAP7000P

software package provides the

user’s manual in .pdf format (or HTML format).

In the

NAP7000P

software package, many demo programs are

provided for the VC++, VB, Delphi and BCB. It contains the complete source
code for the demo programs.