beautypg.com

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

Page 31

background image

Getting Started

for I-7000 Series Modules

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

These codes are described as follows :

‘Declare a variable which has the Integer data type.

Dim wt As Integer

‘Specify the COM port number that the user is currently using

Port = 2

‘Call the function “Open_Com”
‘the parameters are COM Port number: 2, Baubrate: 9600,
‘DataBits: 8, ParityBit: 0(None parity bit), StopBits: 0(One stop bit)

Open_Com Port, 9600, 8, 0, 0

‘Use this command “$01M” to get the module name at address 0x01

SendTo7000 = "$01M"

‘Declare a space to store the string of returned value

ReceiveFrom7000 = Space(100)

‘Call the function “Send_Receive_Cmd”
‘Parameters are Command String, Returned String,
‘Timeout value: 100(0.1 second) , Checksum: 0(disabled)
‘wt: will report the time has been used for this command

Send_Receive_Cmd Port, SendTo7000, ReceiveFrom7000, 100, 0, wt

‘Use the caption of “Command1” button to show the returned value

Command1.Caption = ReceiveFrom7000

‘Close the COM port
‘Parameter is COM port number that the user opened previously.

Close_Com Port

Figure 3-1-10. Use function “

AnalogIn

” to get the analog input value