Using multiple FT232H devices on one computer - Page 1
Forum section: electronics / beginners

author: iflorido
author_rank: Newbie
timestamp: September 30, 2024, 01:27:26 pm
content: Hello, does anyone know how to independently control two FT232H devices, it is configured for UART communication with an A7640 and the other in i2c mode for some sensors.Independently they work fine, but when I connect the two USBs they give me an error since it is not able to differentiate the addressesWhen I check the connected devices I get this response.Dispositivos FTDI encontrados:Dispositivo 1: (UsbDeviceDescriptor(vid=1027, pid=24596, bus=8, address=26, sn=None, index=None, description='Single RS232-HS'), 1)Dispositivo 2: (UsbDeviceDescriptor(vid=1027, pid=24596, bus=8, address=24, sn=None, index=None, description='Single RS232-HS'), 1)The one that works in UART I use it by serial with this addressCode:ftdi_url = 'ftdi://ftdi:232h/1'The one who works in I2cCode:i2c.configure('ftdi://ftdi:232h/1', frequency=100000) # 100 kHzThe only difference when identifying the devices is the addressaddress=26address=24How could I modify the addresses so that they work independently? something likeftdi://ftdi:232h/1:24 or ftdi://ftdi:232h/1:26right now it shows meError configuring I²C on ftdi://ftdi:232h/1: 2 USB devices match URL 'ftdi://ftdi:232h/1'Thanks.

author: bson
author_rank: Unknown
timestamp: September 30, 2024, 06:09:49 pm
content: You can supply a serial number or address in the URI. Seehttps://eblot.github.io/pyftdi/urlscheme.html

author: MarkF
author_rank: Super Contributor
timestamp: September 30, 2024, 09:26:57 pm
content: If you want to see a little code for opening by serial number:I use theFTDI D2XX drivers and library version 2.12.28for Win7.If the serial number to FTDIopen() is left empty, it will open the first device. Good if only one device and you don't care about its serial number.Header:Code:#pragma once#include <windows.h>#include <string.h>#include "ftd2xx.h"class hdwr{public:DWORD ftNumDevs;char device_1;char device_2;char device_3;char device_4;char device_5;char device_6;char device_7;char device_8;bool hdwrConnected;hdwr();~hdwr();int FTDIdevices(void);int FTDIopen(char *serial);int FTDIclose(void);private:FT_HANDLE ftHandle;};Class:Code:#include "hdwr.h"//======================================================================hdwr::hdwr(){ftHandle=0;ftNumDevs=0;device_1=0;device_2=0;device_3=0;device_4=0;device_5=0;device_6=0;device_7=0;device_8=0;hdwrConnected=false;}hdwr::~hdwr(){}//======================================================================int hdwr::FTDIdevices(void){FT_STATUS ftStatus;char *BufPtrs;// Initialize the array of pointersBufPtrs = device_1;BufPtrs = device_2;BufPtrs = device_3;BufPtrs = device_4;BufPtrs = device_5;BufPtrs = device_6;BufPtrs = device_7;BufPtrs = device_8;BufPtrs = NULL;ftStatus = FT_ListDevices(BufPtrs, &ftNumDevs, FT_LIST_ALL|FT_OPEN_BY_SERIAL_NUMBER);return (int)ftStatus;}//======================================================================int hdwr::FTDIopen(char *serial){FT_STATUS ftStatus;if ( strlen(serial) > 0 ) {ftStatus = FT_OpenEx(serial, FT_OPEN_BY_SERIAL_NUMBER, &ftHandle);} else {ftStatus = FT_Open(0, &ftHandle); // Device indices are 0 based}if (ftStatus != FT_OK) return (int)ftStatus;ftStatus = FT_ResetDevice(ftHandle);if (ftStatus != FT_OK) return (int)ftStatus;ftStatus = FT_Purge(ftHandle, FT_PURGE_RX | FT_PURGE_TX);if (ftStatus != FT_OK) return (int)ftStatus;ftStatus = FT_SetLatencyTimer(ftHandle,16); // 1-255 (16ms default)if (ftStatus != FT_OK) return (int)ftStatus;ftStatus = FT_SetUSBParameters(ftHandle,256,256); // USB In/Out transfer sizes (4096 default)if (ftStatus != FT_OK) return (int)ftStatus;ftStatus = FT_SetTimeouts(ftHandle,1000,1000); // R/W timeout (1sec default)if (ftStatus != FT_OK) return (int)ftStatus;hdwrConnected = true;return (int)ftStatus;}//======================================================================int hdwr::FTDIclose(void){hdwrConnected = false;return (int)FT_Close(ftHandle);}