*   TROKANALNI INTERFEJS NA USB SA FT232R KOLOM

 

Firma Future Technology Devices International(FTDI) je već odavno prisutna u proizvodnji  USB kola a pre svega kola za serijsku komunikaciju. Pomoću kola FT232RL moguće je realizovati trokanalni interfejs prema šemi datoj na donjoj slici.

 

 

Kolo se standardnim USB kablom priključuje na PC računar. Izlazi TXD, DTR i RTS  kola dovode se preko otpornika R1 na baze tranzistora u čijem se kolektorskom krugu nalaze relea sa odgovarajućim Led dioda koje signaliziraju da li je rele uključen ili isključen. Ovaj deo kola napaja se eksternim naponom od +5 volti. FT232RL pakovano je u SSOP pakovanju pa ga je u klasičnim uslovima skoro nemoguće zalemiti. Zbog toga je firma Sunrom Techoligies razvila interfejs(ST232R USB- Serial UART)  prikazan na donjim slikama koji omogućuje da se ovo kolo umetne u DIP-24 kućište i ima sve neophodne elemente prema USB što znatno pojednostavljuje izradu interfejsa.

 Za realizaciju ovog interfejs kola potrebni su elementi dati u donjoj tabeli.

Rb.

Komponenta

Količina

1.

ST232R USB- Serial UART

1 kom

2.

T1 – tranzistor 2N2222A

3 kom

3.

D1 - diode  1N4148

3 kom

4.

Led1, Led2 i Led3 – led diode fi 3mm

3 kom

5.

R1 – 1k (1/4W) 

3 kom

6.

R2 – 330W (1/4W) 

3 kom

7.

Re1, Re2 i Re2 – Rele Finder F3611 – 06

1 kom

8.

DIP-24 kućište

1 kom

9.

Vitroplast jednostrani(100 x 160 mm)

1 kom

 

 

Prilikom uključenja ovog kola na USB, Windows XP i Windows Me automatski će ubaciti HID drajver što se vidi na donjoj slici.

 

Softverska podrška:

 

FTDI je razvila odgovarajuće drajvere za podršku svojim USB kolima. Zbog toga je neophodna da sa sajta http://www.ftdichip.com/Drivers/D2XX.htm skinete drajver CDM 2.00.00.zip koji u sebi sadrži FDT2XX.DLL biblioteku za programsku podršku ovom kolu. Ova biblioteka ima sledeće pozive.

 

Private Declare Function FT_Open Lib "FTD2XX.DLL" (ByVal intDeviceNumber As Integer, ByRef lngHandle As Long) As Long

Private Declare Function FT_OpenEx Lib "FTD2XX.DLL" (ByVal arg1 As String, ByVal arg2 As Long, ByRef lngHandle As Long) As Long

Private Declare Function FT_Close Lib "FTD2XX.DLL" (ByVal lngHandle As Long) As Long

Private Declare Function FT_Read Lib "FTD2XX.DLL" (ByVal lngHandle As Long, ByVal lpszBuffer As String, ByVal lngBufferSize As Long, ByRef lngBytesReturned As Long) As Long

Private Declare Function FT_Write Lib "FTD2XX.DLL" (ByVal lngHandle As Long, ByVal lpszBuffer As String, ByVal lngBufferSize As Long, ByRef lngBytesWritten As Long) As Long

Private Declare Function FT_SetBaudRate Lib "FTD2XX.DLL" (ByVal lngHandle As Long, ByVal lngBaudRate As Long) As Long

Private Declare Function FT_SetDataCharacteristics Lib "FTD2XX.DLL" (ByVal lngHandle As Long, ByVal byWordLength As Byte, ByVal byStopBits As Byte, ByVal byParity As Byte) As Long

Private Declare Function FT_SetFlowControl Lib "FTD2XX.DLL" (ByVal lngHandle As Long, ByVal intFlowControl As Integer, ByVal byXonChar As Byte, ByVal byXoffChar As Byte) As Long

Private Declare Function FT_ResetDevice Lib "FTD2XX.DLL" (ByVal lngHandle As Long) As Long

Private Declare Function FT_SetDtr Lib "FTD2XX.DLL" (ByVal lngHandle As Long) As Long

Private Declare Function FT_ClrDtr Lib "FTD2XX.DLL" (ByVal lngHandle As Long) As Long

Private Declare Function FT_SetRts Lib "FTD2XX.DLL" (ByVal lngHandle As Long) As Long

Private Declare Function FT_ClrRts Lib "FTD2XX.DLL" (ByVal lngHandle As Long) As Long

Private Declare Function FT_GetModemStatus Lib "FTD2XX.DLL" (ByVal lngHandle As Long, ByRef lngModemStatus As Long) As Long

Private Declare Function FT_Purge Lib "FTD2XX.DLL" (ByVal lngHandle As Long, ByVal lngMask As Long) As Long

Private Declare Function FT_GetStatus Lib "FTD2XX.DLL" (ByVal lngHandle As Long, ByRef lngRxBytes As Long, ByRef lngTxBytes As Long, ByRef lngEventsDWord As Long) As Long

Private Declare Function FT_GetQueueStatus Lib "FTD2XX.DLL" (ByVal lngHandle As Long, ByRef lngRxBytes As Long) As Long

Private Declare Function FT_GetEventStatus Lib "FTD2XX.DLL" (ByVal lngHandle As Long, ByRef lngEventsDWord As Long) As Long

Private Declare Function FT_SetChars Lib "FTD2XX.DLL" (ByVal lngHandle As Long, ByVal byEventChar As Byte, ByVal byEventCharEnabled As Byte, ByVal byErrorChar As Byte, ByVal byErrorCharEnabled As Byte) As Long

Private Declare Function FT_SetTimeouts Lib "FTD2XX.DLL" (ByVal lngHandle As Long, ByVal lngReadTimeout As Long, ByVal lngWriteTimeout As Long) As Long

Private Declare Function FT_SetBreakOn Lib "FTD2XX.DLL" (ByVal lngHandle As Long) As Long

Private Declare Function FT_SetBreakOff Lib "FTD2XX.DLL" (ByVal lngHandle As Long) As Long

Private Declare Function FT_ListDevices Lib "FTD2XX.DLL" (ByVal arg1 As Long, ByVal arg2 As String, ByVal dwFlags As Long) As Long

Private Declare Function FT_GetNumDevices Lib "FTD2XX.DLL" Alias "FT_ListDevices" (ByRef arg1 As Long, ByVal arg2 As String, ByVal dwFlags As Long) As Long

 

' Return codes

Const FT_OK = 0

Const FT_INVALID_HANDLE = 1

Const FT_DEVICE_NOT_FOUND = 2

Const FT_DEVICE_NOT_OPENED = 3

Const FT_IO_ERROR = 4

Const FT_INSUFFICIENT_RESOURCES = 5

Const FT_INVALID_PARAMETER = 6

Const FT_INVALID_BAUD_RATE = 7

 

 

' Word Lengths

Const FT_BITS_8 = 8

Const FT_BITS_7 = 7

 

' Stop Bits

Const FT_STOP_BITS_1 = 0

Const FT_STOP_BITS_1_5 = 1

Const FT_STOP_BITS_2 = 2

 

' Parity

Const FT_PARITY_NONE = 0

Const FT_PARITY_ODD = 1

Const FT_PARITY_EVEN = 2

Const FT_PARITY_MARK = 3

Const FT_PARITY_SPACE = 4

 

' Flow Control

Const FT_FLOW_NONE = &H0

Const FT_FLOW_RTS_CTS = &H100

Const FT_FLOW_DTR_DSR = &H200

Const FT_FLOW_XON_XOFF = &H400

 

' Purge rx and tx buffers

Const FT_PURGE_RX = 1

Const FT_PURGE_TX = 2

 

' Flags for FT_OpenEx

Const FT_OPEN_BY_SERIAL_NUMBER = 1

Const FT_OPEN_BY_DESCRIPTION = 2

 

' Flags for FT_ListDevices

Const FT_LIST_BY_NUMBER_ONLY = &H80000000

Const FT_LIST_BY_INDEX = &H40000000

Const FT_LIST_ALL = &H20000000.

.

 

 

         Pozivom programa za kontrolu interfejsa dobićemo ekran prikazan na slici dole.

 

 

Programe za podršku kolu sa LCD displejom možete preuzeti ovde.

 

http://vojo.milanovic.org
© Copyright, 2006 Milanović Vojo 
All right reserved