Sunteți pe pagina 1din 36

Instruction Manual

USB Driver

* Matsusada Precision

Rev. 0.4
CONTENTS

Page
1 Introduction 1

1- 1 Device driver 1

1 - 2 Driver CD 1

2 Install 2

2-1 Connection to USB controller 2

2-2 Installation of driver(Windows XP/2000) 2

2-3 Installation of driver(Windows Vista) 8

2-4 Installation of driver (Windows 98SE/Me) 17

2-5 In case not able to install....................................................... 18

2-6 Confirmation of virtual Com port number 18

3 Sample program 19

3 - 1 Direct version, executable file of communication program 19

3 - 2 Sample program with Visual Basic 6.0 20

3 - 3 Sample program with Visual C++ 6.0 26

1 Introduction

Thank you very much for purchasing our USB product.

Although we have made all possible efforts to produce a very accurate manual, if you find any

mistakes, please contact our customer support. The contents of this manual may be changed

without notice. No liability can be accepted for any errors.

The contents is made based on image of Windows XP Professional, Windows VistaM'indows

9aSE. Notice that you may see some different image if using other as version.

The software does not function by itself. Please use our Power Supply and Digital Controller after

installing your special application program based on our sample.

1 -1 Device driver

There are following two models of device drivers for attaching to our products.
Directly control USB interface: Direct version
Use as serial port (Com port): Virtual Com port version

If application software made by the customer is RS-232C controlled, our products will be

controlled by just adding Com port assigned to existing process by using virtual Com port version.

However, if using several units controlled together, generate application on direct version. (See 3.

Sample Program, in case mUltiple units are used)

Sample program is described some examples e of how device driver of direct version is used.

* In case use of only direct version, virtual Com port is installed and new Com port is assigned.

1-2 Driver CD

MTP USB Driver


L 98ME folder Device driver for Windows98/Me
L amd64 folder 64bits driver/interface/support file
L i386 folder 32bits driverlinterface/support file
L Sample folder Sample program for VBNC++ 6.0
L D2XXPG34.pdf Device driver of direct version "Programmer's guide"
L ftd2xx.h Direct version of device driver header file
L ftdibus.cat Direct version of device driver reference file of direct version
L ftd iport. cat Virtual Com port version of device driver reference file
L MTPBUS.inf Direct version of device driver install file
L MTPPORT.inf Virtual Com port version of device driver install file
2 Install

2 -1 Connection to the USB controller

Connect the unit to 2 PC with an USB cable. (\Nhen the power of the unit is off)

2 - 2 Installation of driver(Windows XP/2000)

Turn on the power of the unit.

Note that the following procedure is based on the case of Windows XP(Microsoft).

When turning on the unit, windows of driver search will pop up (fig. 1)

Check < Install from a list or specific location [Advanced] >,

and click < Next>

Welcome to the Found New


Hardware Wizard
This wizard helps you install software for:

MATSUSADA PRECISION USB MODULE

. ,) If your hardware came wilh an inslallalion CD


.. 0;:) or floppy disk., imerl il now.

What do you want the wizard to do?

C::' Install the software automaticall Recommended


i~) JQ~ta.IrJi.Ci.ii)·.a.J.J.s.-i.·.·Qrjp..i~.I.ik}Ci.c..~Hg·QJA.~.Y..~.6.c..~.~j

Click Next to continue.

Next> 1 [ Cancel

fig.1
When the window of fig. 2 pop up, insert the attached CD-ROM to the PC.

After that check < Search for the best driver in these locations. > and

< Search removable media [floppy, CD-ROM .. j >,

then click < Next>.

P:ease choose your search end installation option:>_

'::~:' ii.~:;~S:i9.~::iF~::~~~.t:.~:ii:~~~::!~::\h~~ii~~~~Iq:~~::
Use the check boxes below to limit or expand the default search, vklich includes local
paths and removable media. The best driver found will be installed.

[:2] Search removable media (floppy, CD-ROM ..


o Include this l.Qcation in the search:

() .Qon't search. I will choose the driver to install.


Choose this option to select the device driver from a list. Windows does not guarantee that
the driver you choose will be the best match for your hardware.

<~ack I[ Hext> ] I Cancel

fig.2

If the window of fig.3 pop up, click < Continue Anyway>.

The software you are installing for this hardware:

MATSUSADA PRECISICIN USB MODULE

has not passed Windows Logo testing to verify its compatibility


with Windows XP. (T ell me why this testing is important.)

Continuing your installation of this soflware may impair


01 destabilize the correct operation of your system
either immediately or in the future. Microsoft shongly
recommends that you stop this installation now and
contact the hardware vendorfor software that has
passed Windows logo testing.

Fig.3
Please wail l'inile the wizard inslalls lhe software...

FT DZ<XU ~l. exe


To C\WIt,mOWS\System32

fig A

When the window of fig.5 appear, install is completed. Click < Finish >.

Completing the Found New


Hardware Wizard
The wizard has finished installing the software for:

MATSUSADA PRECISION USB MODULE

Click Finish to close the wizard.

fig.5
Afier turn on a computer, and completes installation of direct version of device driver, it
continuously displays installation retrieval screen of virtual Com port of device driver. (fig. 6)
Check < Install from a list or specific location [Advanced] >,
and click < Next>

Welcome to the Found New


Hardware \Vizard
This wizald helps you insla:l software fOI:

USB Serial Port

. <) If 'yOU! hardware came with an installation CD


....!~1 or flopp'y disk, insert it now.

What do you want the wizard to do?

c:· Install the software automaticall Recommended


(,.;. J0.'~x~rIJr.().fJ1··~Oi.I.st.~i·iP~~.lti~.'i(jc..~.ij'(J.rllA~.;;.~.~.~.~~J

Click Next to continue.

tl ext> J l Cancel
fig.6
When the window of fig. 7 pop up, insert the attached CO-ROM to the PC.

After that check < Search for the best driver in these locations. > and

< Search removable media [floppy, CD-ROM ... ] >,

then click < Next>.

fl:o:ase choose your search and insl.:;llation options.

<~:)~e.:~:i~h:i9.f::iEe.::~~i(::~:;ix~r::j;i:th~~ij(~~~tI.9:6~::
Use the check boxes below to limit or expand the derault search, which includes local
paths and removable media. The best driver found will be installed

o Search removable media [floppy, CD·ROM ... )


o Include this l.Qcation in the search:

() .Qon't search. I will choose the driver to install.


Choose this option to select the device driver from a list. Windows does not guarantee that
the driver you choose will be the best match for your hardware.

<ftack ][ !lext> ] l Cancel

fig.?

If the window of fig.8 pop up, click < Continue Anyway>.

The software you are installing for this hardware:

MATSUSADA PRECISION USB MODULE

has not passed Windows Logo testing to verify its compatibility


with Windows XP. (T ell me why this testing is important.)

Continuing your installation of this software may impair


or destabilize the correct operation of your system
either immediately or in the future. Microsoft strongly
recommends that you stop this installation now and
contact the hardware vendor for software that has
passed Windows Logo testing.

fig.8
Please wait while the wizard installs the software._.

~{il.TSUSp.DA PRECiSION US8 ~lOD\JLE

FT DZXXU N axe
To C:\WINDOWS\S,\Jslem32
.... -·--.------------~-----------··--I

fig.9

If screen (fig. 10) pops up, the installation of virtual Com port of device driver is completed. Click
<Finish>

Completing the Found New


Hardware Wizard
The wizard has finished installing the software fOl:

MATSUSADA PRECISION USB MODULE

Click Finish to close the wizard.

fig.10
2 - 3 Installation of driver(\Nindows Vista)

Turn on power of the unit.

Note that the fol/owing procedure is based on the case of Windows Vista (Microsoft).

On Windows Vista, it directly specifies the driver and start install.

Driver can be installed different way which is not described on this manual, but driver of the other

OS (Windows 98 Me and so on) would be searched and installed. Therefore, install the driver after

confirming manual to use normally.

After turning on, searching screen of direct version of device driver will pop up.

Select <Locate and install driver software (recommended»

, : Found New Hardware .. ;-,:-'"


" , .,,'.

* It takes longer searching depends on usage environment.


When next screen pops up, select <I don't have the disc, Show me other options, >

V /GU ;·J~,.·t:1h-c l;i~( (-lj11:l~i':":: ~\lrl ),:,1_1' J;:.·.'i:~t: . in~c·t i: nc.'., ..:.:;': ll~:'i~ ;·,:1 c:.t.tJ~·r·,~~.i'~Jl'y
~t'3'(h th::- (11:'( f:jr :.Iri·, ~r ~.Jlt.'~:rr.:

Message shows, Windows couldn't find driver software for your device, but select <Browse my
computer for driver software (advanced) >

-> Check for u solution


Viir,d:).\'; 'I. iii {h~d: 10 '''~ if lilf.f eft it<;E /GIJ (an tck" 10 gd you. Gb'l(t
·.. \ ·crkl . . . . ;;.

~\ BLGw;e my cornputer for dril,'er sofwlare:.adva:iCed)


Lo~atc .m:! in~LJII driver ~~fb\'Jrc mJnu~lly,

Cancel
When next screen pops up, insert an attached CD-ROM to a PC, and select the inserted CD-ROM
drive on <Browse>.
* Remove the check mark from <Include subfolders> Click next

Found ~JE:W Hard:v~are- co Seriese, .


. -~;;.~ _~:~-:':~::;5.'~:,';j-:-; -. -.". --~ ;·~.,~~:h~.-~ ....~~\~.,,'

Select CD-ROnt1 drive

Remove check mark

Search for selected CD-ROM drive

Sea rCIli,'1g F:\ fo 1- softwa re .. ,


When finding driver, switch the screen and continue installing.

*It may take longer time searching virtual Com port depending on your usage environment.

r~' Windows Security'·

I tJ Windows can"t verify the publisher of this driver software

~ Don't install this driver sofh,vare


'leu ~heuld ch~ck yeur manufactlJrl:r'~ 'h~bit~ fer updated driv~r ~eftwar~
fer your devie e.

•~ InstaH this driver sofr.vare anYv'o/ay


Only imtall driver software obtained from your manufacturer's website or
disc. Unsigned software from other ,ourees may harm your computer or steal
information.

i, v' See Qetail~


When end screen displays, the installation of direct version of device driver is completed. Click
<Close>.

'liinc!c'/·.·' has finishEd imtal::n~: thE clri'itr scft'har" fer thi, dE,..icE:

L1ATSUS':'DA. PRECISION USB [,,10DULE

After completing the installation of direct version of device driver, the installation of virtual Com port

version of device driver starts.

*It may take longer time searching virtual Com port depending on your usage environment.

In the same way for the instillation of virtual Com port, select <\ don't have the disc. Shows me
other options. > and <Next>.

If ycu ha'ie the dl~c that came '81th ycur de'icE, imE:t it nc,.'" '''','inclc'.'.,~ ','fill aut:;l11atica'l~
,earch the c1i,c fer dri'ier ,dt",are,

!
.;
"

.~ I dO'lt :la',/e t'le disc. Sho~v me otler opti01S.


.~
{j
"

~-I ~
"

I Cancel

Message shows <Windows couldn't find driver software for your device>, but select <Browse my
computer for driver software (advanced».

WindO'1NS couldrl't find driver softv<Jare for ,vour de\.'ice

. -) <:rleck for a solution


'Nindow, >,', ill check to SEe if thEre arE ,teps ycu can ta ke te get ycur de'lice
','Icrking,

-" Browse my computer for driver soft\Nare (ad'.!d·lCed)


Locate and install driver software manually,
When next screen displays, insert the attached CD-ROM to computer, and select the inserted CO­
ROM drive on<Browse>.
*Remove the check mark from<lnclude subfolders>.
Click <Next> bottom.

Select CD-ROM drive

Remove check mark

'~'---l
I Ntxt -! I'---l
CanCf:! ~
,":
..".-,,,-~; ·,~\"~"'J,"i1.;n."{.W7:""''''''''''J''''~~~I~,f~1I\-.!!·r:!!'-··':,'''F,V,-I':

Search indicated CD-ROM drive

Searcni"g F:\ for 5oftv,:are."


When finding driver, switch the screen and continue installing.

Found New Hard'Nare- USB Serial Pori:}


. _~;.·_·~\·:1~~. -. _ . . 0 .:-. ":"~--;y'jf>:::'j~}L?}~-

f····················································· - -.-..................•.•.................•...................•............:

~ Don't install this driver sofnvare

You ~hculd ched:your rnanufacturer'~ ·.'ieb~ite fer updated driver ooft'Nare

for your de··jice.

~) lnstalJ t;1is driver softl,.vare anyway


Only install driver softvvare obtained from your manufacturer's website or
disc. Unsigned software from other sources may harm your computer or steal
information.

,v See getail~
When end screen displays, the installation of virtual Com port version of device driver is completed.

Assigned Com port number on virtual Com port is indicated as installed driver name. Click <close>.

Found New Hardwar ; MAT5USADA' PEECISION USB MODULE(CO~M)


-": \:-~:i~!~ki;{~f>:;~:·,~:~~·-,'sr:· ·~<~·;··'~~~~tt:t~:~;:::f.!jt~~:::L,-:;'i~~~1irj~~l.-i~~~~::}:, ..,~~.:,~:,')~-".~c:·-·'· ~',>.

- ." jt.t
-\SLa:i~( \

Assigned Com port


'/:1: ,:!c,--s hac fini,he:c1 insta!ling the c1ri-.e:1' :dt',arE fcr thi, cJEvicE:
number
:.1
i
,-,1;:" T5U5ADA PEECI5IOr-) USB r,IODULE

:··".·r·'j,.... '.·.l'.l".-...-. )X.)·':t.,.iJ.:\:'.-r.,·",,;


2 -4 Installation of driver (Windows 98SE/Me)

There are D2XX (Direct version of device driver9NCp (virtual Com port version of device driver)

in 98Me folder on MTP USB Driver Disk.

Alternative of Direct version of device driver or Virtual Com port version of device driver can be

installed. Select either version depends on your usage environment.

*As installing direct version of device driver, message [Cannot find file name of ftd2xx.cat] might

be appeard on the display, however, you can skip it since file [ftd2xx.cat] is not used.

2 - 5 In case not able to install

Click < Add Hardware> in control panel to install the driver.

Ede ~dlt llJew F9.vontes Iools tielp

£:..­
Search

0" Control Panel


r;,
'.\
~-i-;
<'~ I
~." !..--.;I 'wJ
L
; ":'-l,.

_.J
~--.:. ...

Accessibility Add or Administr at;ve Date and Time Display


Options Remov Toots
......
-J~
.1,
,
.--­
I ".i
; iJ~~J
+-~
;~
See Also
Folder Optiuns Fonts Game Internet Keyboard ~louse
{) \Ii/indo'.",'s Update Controllers Options
iiJ,.1 He:lp 2r,d ':'upport
~ .' '1
~-"
'<.r,
-J,,' ".I
.-'/' ~ .::~
Network Phone and Power Options Printers and Regional and Scanners and
Connections Modem Faxes Language. ,. Cameras

t\
!~ ")/ {J L::ii ~,
I ~ _c'.! IfA.'-'J ~
Scheduled Sounds and Speech System Taskbar and User Accounts
Tasks Audio Devices Start Menu

2 - 6 Confirmation of virtual Com port number

Confirm or change virtual Com port number from device manager


~J;~1',':" \':,' "~"\'. .=l.QJB
[~~~~1J=~~~T~iTI.-L~_~_jl~~~.
._::~'~~~~~=~~~~~]

± {:y DVD!CD-ROM drives

:±: ~3 Floppy disk controllers

i:t·8 Floppy disk drives

:t: @ IDE ATA!AT API controllers

± . ~ Keyboards

ct S')
Mice and other pointing devices

:±: .:~ Monitors

± ~ National Instruments GPlB Interfaces

± .1.;1 Network adapters

-=-jJ Ports (COM & LPT)

,)} Communications Port (COMt)

,y Communications Port (COM2)

,j} ECP Printer Port (LPn)

. ,f:! j'rde!i~UinBilf!ltilm~;nGlt:!I!iiE+lnd
±.-tSCSI and RAID controllers

:£qi·:
Sound, Video and game controllers

ct .~
System devices

S ~ Universal Serial Bus controllers

Intel(R) B2801BA/BAM USB Universal Host Controller - 2442

r'------.
• .•
j
..... ",

Intel(R) 82B01BA!BAM USB Universal Host Controller - 2444


MATSUSADA PRECISlON USB MODULE
USB Root Hub

USB Root Hub


-~-----~- ----.--------;---------;----­
3 Sanlple program

In sample folder, executable file of communication program of direct version and

VBNC++6.0(MS) .

Regarding details of function, see the [D2XXPG34.pdn progr2mming guide on an attached CD­

ROM.

3 -1 Direct version, executable file of communication program

Windows shown below shall be open when execute the executable file "USBtest.exe" in sample
folder.
This "USBtest.exe" is an executable file compiled sample program source code in VC folder in
enclosed CD-ROM. Use this program to verify the communication between Matsusada power
supplies.
Note that the operation verification of these executable program "USBtest.exe" was done in the
environment of our factory, and not to confirm the operation in any environment, and as such
support on this program is not to be provided. Indemnification is not to be provided either for any
damaged caused by using or diverting this program.

[Start-up window]

Vvr ite Data I

Data Send box

. Read Data I ~--;---- Data receive box


~~--:O--:-:--':""""-------7-A~-r-- Status display of program
Status'", ·,Iritialize EndJ~:.~,_----~..~.'-2'i~''--~r-== :~~~ ~~~~~

[Operation when sending data]

Input a command (REN: remote enable command).


* Refer the Command List in our instruction manuals
for other digital communication commands.
Read~at~J' .
, --., --'­ ,--~--", .

Status ;,..,..,-:...;,::....':-:-:",....--..:,:..:..:.,-.....-",--------'--~---.--- Click on Write button (input command is to be sent).

Status of command send is displayed .


.... ~ad
[Operation when receiving data]

\/Jirite Data RT~<.iiiiiiiiiiiiO~==--""'""''''''''"'''''''''''~ Input a command (STS: receive status of power supply).
* When receiving, input commands for read out.
Read Data

Click on Write button (input command is to be sent).


~-"""-:::::>.c:::::"J~
Status
)Write OK!
Status of command send is displayed.

Click on Read button (receive data which power supply

Write Data ISTS return from input command).

Head Data fic505FRU;;M1iC5iCS-~~;;;;;;;;;;;;;;=;;;:=~C::'J. Received data is displayed.

(CO RM CC: receive status of power supply).

Status *CO: Output enable status/RM: Remote control/CC:

CC operation

\Ilk ite

Status of command received is displayed

3-2 Sample program with Visual Basic 6.0

Sample program is on the attached CD-ROM. The sample of Visual Basic is located at VB folder
in sample folder on the CD-ROM.
"Project1.exe" in VB folder in the CD-ROM sample folder is an executable file compiled sample
program source code in VB folder. This program operate just as "USBtest.exe" does described in
previous page, but when used with only this program, VB6.0 run time library shall be required.

: :'; ':,~_:,~-~ ~:~>:'~"::~;,\;.-'-:':- ',~,::_~:~:) ;~;-~- !T·:;:::!'·~'·:. ~ .:' :-: ;-:.- ~~.":f;:->;~~·.<--.--:~~:; _,~,~~~:~?:,< <.~ -,:- :
• .• , ._':~. ;,,". '. ,,~,.' :;.~ • ~ . • • • . • • '-' .:'"',_ •• ~ ,;;'~-'-~'-.>. ' •• '-' . "

: : :: \IlI\:ite Data :; I Form: Form1


..
' . .

~' '~',,":- ~.-;; '.': :"", -':.!;-' ~:·<:~'~·r~' -~


• .' ~ -.- • co, '. ,.' ~.. •

· . .'. ... ,....


_ . .- ~ ".

: : : : Status

. Write

·. ... .... . .' ~ '-,- -. " . . . . . . . . . -. .

Private Declare Function FT_Open Lib "FTD2XXDLL" (ByVal intDeviceNumber As Integer, ByRef IngHandle
As Long) As Long

Private Declare Function FT_OpenEx Lib "FTD2XXDLL" (ByVal pArg1 As String, ByVallngFlags As Long,
ByRer IngHandle As Long) As Long

Private Declare Function FT_Close Lib "FTD2XXDLL" (ByVal IngHandle As Long) As Long

Private Declare Function FT_Read Lib "FTD2XXDLL" (ByVal IngHandle As Long, ByVal IpszBuffer As String,
ByVal IngBufferSize As Long, By Ref IngBytesReturned As Long) As Long

Private Declare Function FT_Write Lib "FTD2XXDLL" (ByVal IngHandle As Long, ByVal IpszBuffer As String,
ByVal IngBufferSize As Long, ByRef IngBytesWritten As Long) As Long

Private Declare Function FT_SetBaudRate Lib "FTD2XXDLL" (ByVal IngHandle As Long, ByVal IngBaudRate
As Long) As Long

Private Declare Function FT_SetDataCharacteristics Lib "FTD2XXDLL" (ByVal IngHandle As Long, ByVal
byWordLength As Byte, ByVal byStopBits As Byte, ByVal byParity As Byte) As Long

Private Declare Function FT_SetFlowControl Lib "FTD2XXDLL" (ByVal IngHandle As Long, ByVal
intFlowControl As Integer, ByVal byXonChar As Byte, ByVal byXoffChar As Byte) As Long

Private Declare Function FT_ResetDevice Lib "FTD2XXDLL" (ByVal IngHandle As Long) As Long

Private Declare Function FT_Purge Lib "FTD2XX.DLL" (ByVal IngHandle As Long, ByVal IngMask As Long) As
Long

Private Declare Function FT_SetTimeouts Lib "FTD2XXDLL" (ByVallngHandle As Long, ByVal


IngReadTimeout As Long, ByVallngWriteTimeout As Long) As Long

Private Declare Function FT_GetQueueStatus Lib "FTD2XXDLL" (ByVal IngHandle As Long, ByRef
dwRxBytes As Long) As Long

, Return codes
Canst FT_OK =0
• Word Lengths
Canst FT_BITS_8 = 8
, Stop Bits
Canst FT_STOP_BITSJ =0
, Parity
Const FT_PARITY_NONE =0
, Flow Control
Const FT_FLOV'tNONE =&HO
, Purge rx and tx buffers
Const FT_PURGE_RX = 1
Const FTYURGE_TX = 2
, FT_OpenEx Flags
Const FT_OPEN_BY_SERIAL_NUMBER =1

, USB Handle
Dim IngHandle As Long
· Write Buffer 256 Byte
Dim strWriteBuffer As String * 256
· Read Buffer 256 Byte
Dim strReadBuffer As String * 256

· USB Open
Sub UsbOpen()
· Open
If FT_Open(O. IngHandle) <> FT_OK Then 'How to open the device when connecting only one our
product.
If FT_OpenExCC0001001 ", FT_OPEN_BY_SERIAU\IUMBER, IngHandle) <> FT_OK Then
'When opening the device while connecting
multiple our products (or only one is also possible) to
one PC.

Write USB SIN on the place of C0001 001 which is

enclosed with ''''(double quotation).

Either FT Open or FT OpenEx is to be used.

In case only 1 unit is used for all series. use FT_Open (recommended).
(Even with FT_Open Ex, if USB SIN is written it will work)
In case multiple unit is used
CO series .. 'Write USB SIN in the place of C0001 001 which is enclosed with
''''(double quotation) of FT_OpenEx (e.g.C0001001)
Other series " 'Write USB SIN in the place of C0001 001 which is enclosed with
""(double quotation) of FT_OpenEx
e.g. RK series FT_OpenEx("RK001001", .
e.g. DRA series FT_OpenEx("DRA01001" ..
e.g. XXXXX series FT_OpenEx(IXXXXX001", .
Exit Sub
End If
, BaudRaie 9600bps Set
If FT_SetBaudRate(lngHancie. 9600) <> FT_OK Tilen

UsbClose

Exit Sub

End If
, 8 data bits, 1 stop bit, no parity
If FT_SetDataCharacteristics(lngHandle. FT_EITS_8, FT_STOP_BITSJ, FT_PAF-iITY_NONE) <> FT_OK
Then
UsbClose
Exit Sub
End If
I no flow control
If FT_SetFlowControl(lngHandle, FT_FLOW_NONE, 0, 0) <> FT_OK Then

UsbClose

Exit Sub

End If
'50m second read,write timeout
If FT_SetTimeoutsCingHandle. 50, 10) <> FT_OK Then

UsbClose

Exit Sub

I Rx Clear

End If

If FT_PurgeClngHandle. FT_PURGE_RX) <> FT_OK Then

UsbClose

Exit Sub

End If

I Tx Clear
If FT_Purge(lngHandle, FT_PURGE_TX) <> FT_OK Then

UsbClose

Exit Sub

End If
End Sub

I USB Close
Sub UsbCloseO
FT_Close ClngHandle)
End Sub

'USB Write
Function UsbWriteCdata As String) As Boolean
Dim wlen As Long
_-=~_n=~~~~=-'~~="""""'~Y_-~_~~~_~~'_~_~_""- _ _~
wlen :: Len(data)
strWriteBuffer :: data
UsbWrite :: FT_Write(lngHandle, strWriteBuffer, wlen, Ln)
End Function

'USB Read
Function UsbRead(data As String, n tv;:, Integer) As Boolean
Dinl I As I_ong
UsbRead:: FT_Read(lngHandle, strReadBuffer, n, I)
jf I >0 Then
data:: Left(strReadBuffer, I - 1)
Else
data:: ""

End If
End Function

Private Sub Command1_ClickO


Dim wdata As String
Dim Rt As Long

Label5.Caption :: ""

wdata:: Text1.Text & Chr(&HD)

Rt:: UsbWriteCwdata) 'Send command written in TextBox

If Rt :: FT_OK Then

Label5.Caption :: "Write OKI"


Else
Label5.Caption :: "Write NG!"
End If
End Sub

Private Sub Command2_ClickO


Dim rdata As String
Dim Rt As Long

LabeI5.Caption:: ""
Rt:: Usb Read(rdata, 20) 'Receive data
Label3.Caption :: rdata 'Indicate the data received
If Rt :: FT_OK Then
LabeI5.Caption:: "Read OKl"
Else
LabeI5.Caption:: "Read NG!"
End If
End Sub

Private Sub Form_LoadO


UsbOpen
End Sub

Private Sub Form_UnloadCCancel As Integer)


Dim I As Integer

UsbClose

'close all sub forms


For 1= Forms.Count - 1 To 1 Step-1
Unload Forms(I)
Next
End Sub
3 - 3 Sample program with Visual C++ 6.0

The sample program is on the attached CD-ROM. The sample of Visual C++ is located at VC
folder in sample folder on the CD-ROM

IDC_WriteData
IDC_ReadData
IDC_StatusData
: ~~a~u.s. : : jEdit

:: :::: :: :: ::: :: ::~·~·~:~:~:;:~:;:~:~:~:~:~:~:~:::::::~:~:r~:~~-;~~:


~~ ~ :~~ ~ ite j: Read
------ -~~~--

ftd2xx.lib Link
ftd2xx.h Include

public:
FT_STATUS ftStatus;
FT HANDLE fnHandle;
OnlnitDialogO
I II Form2tting II I I II I I II I I II I II I I I I III I1/111///1 I I I I I I I 1// / I I I / / I I I I I/ I I I I I I I I
ftStatus =FT_Open(O, &fnHandle); How to open the device when connecting only one our
product

// ftStatus =FT_OpenExCC0001 001 ". FT_OPEt\LBY_SERIAL_NUMBER, &fnHandle);


When opening the cevice while connecting

multiple our products (or only one is also possible) to one PC.

Write USB SIN on the place of C0001001 which is enclosed

with ""(double quotation).

Either FT ODen or FT ODenEx is to be used.


if (ftStatus == FT_OK) {
SetDlgltemT extODC_StatusData, "Open OK !"):

else
SetDlgltemTextODC_StatusData. "FT_Open Error !"):
return TRUE;

In case only 1 unit is used for all series, use FT_Open (recommended).
(Even with FT_Open Ex, if USB SIN is written it will work)
In case multiple unit is used
CO series ., 'Write USB SIN in the place of C0001 001 which is enclosed with
""(double quotation) of FT_OpenEx (e.g.C0001001)
Other series' "Write USB SIN in the place of C0001 001 which is enclosed with
''''(double quotation) of FT_OpenEx
e.g. RK series FT_OpenEx("RK001001", .
e.g. DRA series FT_OpenEx("DRA01001", .
e.g. XXXXX series FT_OpenEx(IXXXXX001", .

I I BaudRate 9600bps Set

ftStatus =FT_SetBaudRate(fnHandle. 9600);

if (ftStatus = FT_OK) {

SetDlgltemT extODC_StatusData, "BaudRate 9600bps Set !");

else {
SetDlgltemTextODC_StatusData. "FT_SetBaudRate Error !");
FT_Close (fnHandle); I I End processing
return TRU E;

I I 8 data bits, 1 stop bit. no parity

ftStatus = FT_SetDataCharacteristics(fnHandle, FT_BITS_8, FT_STOP_BITS_1, FT_PARITY_NONE);

if (ftStatus = FT_OK) [

1-=-~~~S-e-tD-I-gI~t-em-T-e-xt~(j-D-C-_-S-ta-t-u-s-D-at-a=,-"-8~d-a-ta"""'b~it-s.-1-s-t-o-p~b-it-.-no~;:jty Set7~

else {
SetDlgltemTextODC_StatusData, "FT_SetDataCharacteristics Error n;
FT_Close (fr,Handle); / / End processing
return TRUE;

/ / no flow control

ftStatus = FT_SetFlowControICfnHandle, FT_FLOW_NONE, O. 0);

if CftStatus = FT_OK) {

SetDlgltemTextODC_StatusData, "no flow control Set n;

else {
SetDlgltemTextODC_StatusData, "FT~SetFlowControl Error n;
FT_Close CfnHandle); / / End processing
return TRUE;

/ / SOm second read,write timeout

ftStatus = FT_SetTimeoutsCfnHandle, 50, 50);

if CftStatus = FT.OK) {

SetDlgltemTextCIDC_StatusData, "SOm second read,write timeout Set !");

else {
SetDlgltemTextODC_StatusData, "FT_SetTimeouts Error!");
FT_Close CfnHandle); / / End processing
return TRUE;

/ / Rx Clear

ftStatus = FT_PurgeCfnHandle, FT_PURGE_RX);

if CftStatus = FT_OK) {

SetDlgltemTextODC_StatusData, "Rx Clear Set !");

else {

SetDlgltemTextODC_StatusData. "FT_Purge Error !"):

FT_Close CfnHandle); / / End processing

return TRUE;

/ / Tx Clear

ftStatus = FT_PurgeCfnHandle. FT_P~U,-,-R~G~E_~T~X0.); _

~~~ ~~~.o.7~~~_~~~~.~~~~ ~ _

if CftStatus =::: FT_OK) (


SetDlgltem TextODC_StatusData. "Tx Clear Set !"):

else {
SetDlgltemText(IDC_StatusData, "FT_Purge Error 1");
FT_Close (fnHandle); I I End processing
return TRUE;

SetDlgltemTextODC_StatusData, "Initialize End n:


I I / Formatting up to here /1/1/1/1III I / / I I III II II I / I I I I I / /11/1 II I II II I II I I1//I / I /1/1/1/1/
1/-----------------------------------------------------------------------------­
I I Writing data
void CUSBtestDlg::OnWriteO

CString strData:

char data[256];

DWORD I;

unsigned long len;

GetDlgltemTextODC_WriteData, strData); I I Obtain word of Writedata


strcpyCdata, strData); 1/ CString-+char

len =strData.GetLengthO; 1/ Obtain length of word

data[len] = OxOD; 1/ CR at the end of word

ftStatus ::: FT_WriteCfnHandle, data, len + 1, &1); 1/ Writing data

if CftStatus = FT_OK) {

SetDlgltemText(IDC_StatusData, "Write OK !");

else {

strData.FormatCWrite Error No. %d", ftStatus);

SetDlgltemText(IDC_StatusData, strData);

__
~_~~~ . : w " " V : ~ = : I ' - = : I l " ~ ~ ~ - = - - = ' ~ = ~ ~ ~ = ~ _ ~ . . . . . , ~ ~ ~ ~ ~ _ ~ ~ _ ~ ~ __
/ / Read in data
void CUSBtestDlg::OnReadO

CString strData;
char data[2561
DWORD \;

ftStatus =FT_Read(fnHandle dcta, 20, &1); // Read in data


if (ftStatus == FT_OK) {
SetDlgltemTextODC_StatusData, "Read OK n;
else [
strData.FormatC'Read Error No. %d", ftStatus);
SetDlgltemText(IDC_StatusData, strData);

if (I ) 0) I I / In case word returned


strData.FormatC%s", data); 1/ char-CString
SetDlgltemTextODC_ReadData, strData.Left(l); 1/ Description of word to Read data

else {
SetDlgltemText(IDC_ReadData, "");

)
//------------------------------------------------------------------------------

OnCancelO
FT_Close (fnHandle);
---~--~--'---_._-----_._---------------------.

Matsusada Precision Inc.


USA / Canada / Mexico
West Coast San Jose office +1-408-273-4573
Central/Mid West Dallas office +1-972-663-9336
East Coast New York office +1-631-244-1407
·Contact to above offices if any question or inquiry
(English, Voice mail available)
Other countries
International office(Japan) +81-75-229-6355
(English or Japanese, no voice mail)
Headquarters / Factory

745 Aoji-cho Kusatsu Shiga 525-0041 Japan

Tel: +81-77-561-2111

(English or Japanese, no voice mail)

S-ar putea să vă placă și