Legacy Forum: Preserving Nearly 20 Years of Community History - A Time Capsule of Discussions, Memories, and Shared Experiences.

libFTDI with USB2Dynamixel?

Bioloid robot kit from Korean company Robotis; CM5 controller block, AX12 servos..
13 postsPage 1 of 1
13 postsPage 1 of 1

libFTDI with USB2Dynamixel?

Post by tafoxx » Mon Jun 29, 2009 8:42 am

Post by tafoxx
Mon Jun 29, 2009 8:42 am

I've heard some talk of latency issues using the default serial port driver in Linux. I've seen for myself that I can't get much more than 40 read-writes per second, which for my purposes should be pretty sufficient, but if I could increase that by an order of magnitude without a huge amount of work, I'd be very interested in doing so. I've been looking at libFTDI, and this post about latency, but I still have a few questions.
First of all, let's see if I have my basic assumptions right. This seems to be a library, not a driver, which will fulfill the function of using a (specifically FTDI-powered) USB-to-serial connector as a serial bus, but with much faster response than the default Linux solution? So it will not require installing any special drivers or anything more complicated than using a different library? The device this code is for has several other serial devices connected via USB converters, so I don't think switching the drivers is an option.
Is this library compatible with Windows? Right now I'm communicating with the serial port device with POSIX-standard methods, but I'm considering adding in Windows support... but it would be great if libFTDI could provide a one-stop solution.
Oh, I guess I should have asked this first: Will this library work with the USB2Dynamixel device? The post I linked to seemed to be about custom devices... this library is for PC-side communications, right?

Thanks for the help.
I've heard some talk of latency issues using the default serial port driver in Linux. I've seen for myself that I can't get much more than 40 read-writes per second, which for my purposes should be pretty sufficient, but if I could increase that by an order of magnitude without a huge amount of work, I'd be very interested in doing so. I've been looking at libFTDI, and this post about latency, but I still have a few questions.
First of all, let's see if I have my basic assumptions right. This seems to be a library, not a driver, which will fulfill the function of using a (specifically FTDI-powered) USB-to-serial connector as a serial bus, but with much faster response than the default Linux solution? So it will not require installing any special drivers or anything more complicated than using a different library? The device this code is for has several other serial devices connected via USB converters, so I don't think switching the drivers is an option.
Is this library compatible with Windows? Right now I'm communicating with the serial port device with POSIX-standard methods, but I'm considering adding in Windows support... but it would be great if libFTDI could provide a one-stop solution.
Oh, I guess I should have asked this first: Will this library work with the USB2Dynamixel device? The post I linked to seemed to be about custom devices... this library is for PC-side communications, right?

Thanks for the help.
tafoxx
Robot Builder
Robot Builder
Posts: 17
Joined: Thu Jun 18, 2009 11:43 am

Post by RandomMatt » Mon Jun 29, 2009 10:41 am

Post by RandomMatt
Mon Jun 29, 2009 10:41 am

You should be able to do better than 40Hz.

The USB spec says that USB frames occur at 1kHZ - so given you need 1 frame from the PC to the FTDI and one from the FTDI to the PC, the best response time will be 2ms or 500Hz (and that assumes that the FTDI chip knows to put the whole dynamixel packet in one USB frame).

Before you worry about libFTDI (which is written by the FTDI people, so there is a windows version) - are you sure that you have switched off buffering?

Also.. check that you have set the response time on the servo to 0 (i.e. as fast as possible).
You should be able to do better than 40Hz.

The USB spec says that USB frames occur at 1kHZ - so given you need 1 frame from the PC to the FTDI and one from the FTDI to the PC, the best response time will be 2ms or 500Hz (and that assumes that the FTDI chip knows to put the whole dynamixel packet in one USB frame).

Before you worry about libFTDI (which is written by the FTDI people, so there is a windows version) - are you sure that you have switched off buffering?

Also.. check that you have set the response time on the servo to 0 (i.e. as fast as possible).
RandomMatt
Savvy Roboteer
Savvy Roboteer
Posts: 117
Joined: Sat Dec 20, 2008 11:16 pm

Post by tafoxx » Mon Jun 29, 2009 11:09 am

Post by tafoxx
Mon Jun 29, 2009 11:09 am

Switched off buffering? Where? And how?
Switched off buffering? Where? And how?
tafoxx
Robot Builder
Robot Builder
Posts: 17
Joined: Thu Jun 18, 2009 11:43 am

Post by tafoxx » Mon Jun 29, 2009 1:39 pm

Post by tafoxx
Mon Jun 29, 2009 1:39 pm

Okay, it looks like reading a single register from the servo (receiving the data packet) requires a wait time of about 25 milliseconds. Compared to that, the return delay (maximum of .5 milliseconds) isn't even noticeable.
Okay, it looks like reading a single register from the servo (receiving the data packet) requires a wait time of about 25 milliseconds. Compared to that, the return delay (maximum of .5 milliseconds) isn't even noticeable.
tafoxx
Robot Builder
Robot Builder
Posts: 17
Joined: Thu Jun 18, 2009 11:43 am

Post by RandomMatt » Mon Jun 29, 2009 1:45 pm

Post by RandomMatt
Mon Jun 29, 2009 1:45 pm

tafoxx wrote:Switched off buffering? Where? And how?


This is all unix specific... (but it is POSIX)

firstly you want to use read() and write() - this removes the buffer in the C standard library. Although you can call fflush alot instead

secondly you want use tcsetraw() to remove the line buffering - assuming you are talking to a serial port.

thirdly, you might need to ioctl() to flush the internal buffers in the OS - look up TIOCFLUSH. not sure... but fsync might be worth a look
tafoxx wrote:Switched off buffering? Where? And how?


This is all unix specific... (but it is POSIX)

firstly you want to use read() and write() - this removes the buffer in the C standard library. Although you can call fflush alot instead

secondly you want use tcsetraw() to remove the line buffering - assuming you are talking to a serial port.

thirdly, you might need to ioctl() to flush the internal buffers in the OS - look up TIOCFLUSH. not sure... but fsync might be worth a look
RandomMatt
Savvy Roboteer
Savvy Roboteer
Posts: 117
Joined: Sat Dec 20, 2008 11:16 pm

Post by tafoxx » Mon Jun 29, 2009 1:59 pm

Post by tafoxx
Mon Jun 29, 2009 1:59 pm

Oh, I'm already doing all that.
Oh, I'm already doing all that.
tafoxx
Robot Builder
Robot Builder
Posts: 17
Joined: Thu Jun 18, 2009 11:43 am

Post by RandomMatt » Mon Jun 29, 2009 3:58 pm

Post by RandomMatt
Mon Jun 29, 2009 3:58 pm

tafoxx wrote:Oh, I'm already doing all that.

To be honest, I'm not surprised... but its always worth checking :wink:.

The fact that you cannot notice the difference between a large servo response time and a short one suggests that you problem is much bigger than that effect. But, I'm sorry, I'm out of ideas - unless you count using a smart controller on the end of the FTDI (like a CM5).
tafoxx wrote:Oh, I'm already doing all that.

To be honest, I'm not surprised... but its always worth checking :wink:.

The fact that you cannot notice the difference between a large servo response time and a short one suggests that you problem is much bigger than that effect. But, I'm sorry, I'm out of ideas - unless you count using a smart controller on the end of the FTDI (like a CM5).
RandomMatt
Savvy Roboteer
Savvy Roboteer
Posts: 117
Joined: Sat Dec 20, 2008 11:16 pm

Post by tafoxx » Tue Jun 30, 2009 2:17 pm

Post by tafoxx
Tue Jun 30, 2009 2:17 pm

So does anyone have experience with libFTDI? The documentation is pretty scrawny.
So does anyone have experience with libFTDI? The documentation is pretty scrawny.
tafoxx
Robot Builder
Robot Builder
Posts: 17
Joined: Thu Jun 18, 2009 11:43 am

Post by Bullit » Tue Jun 30, 2009 5:20 pm

Post by Bullit
Tue Jun 30, 2009 5:20 pm

If you going to use lots of different serial converters your in for some problems. They are not all created equally. I have worked with many. Some will have huge latencies. Save yourself a lot of hassle.
FTDI modules are cheap, fast and consistent. There is a high performance windows driver that has 2ms latency available on their site.
If you going to use lots of different serial converters your in for some problems. They are not all created equally. I have worked with many. Some will have huge latencies. Save yourself a lot of hassle.
FTDI modules are cheap, fast and consistent. There is a high performance windows driver that has 2ms latency available on their site.
Bullit
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 291
Joined: Wed May 31, 2006 1:00 am
Location: Near robot

Post by siempre.aprendiendo » Wed Jul 01, 2009 11:26 pm

Post by siempre.aprendiendo
Wed Jul 01, 2009 11:26 pm

Thanks again, Bullit

It is really fast, I test it when you post it last year

Do you know if there is also fast drivers for windows and, specially, windows ce?
Thanks again, Bullit

It is really fast, I test it when you post it last year

Do you know if there is also fast drivers for windows and, specially, windows ce?
siempre.aprendiendo
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 559
Joined: Wed Aug 08, 2007 9:13 pm
Location: Barcelona

Post by Bullit » Thu Jul 02, 2009 3:26 am

Post by Bullit
Thu Jul 02, 2009 3:26 am

The D2XX drivers are the fastest. I don't know about the performance with windows CE but FTDI has drivers for CE
http://ftdichip.com/Drivers/D2XX.htm
As I recall there is a low latency setting in the interface.
The D2XX drivers are the fastest. I don't know about the performance with windows CE but FTDI has drivers for CE
http://ftdichip.com/Drivers/D2XX.htm
As I recall there is a low latency setting in the interface.
Bullit
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 291
Joined: Wed May 31, 2006 1:00 am
Location: Near robot

Post by tafoxx » Thu Jul 02, 2009 2:53 pm

Post by tafoxx
Thu Jul 02, 2009 2:53 pm

I'm not interested in Windows drivers--in fact, I'd rather stay away from specialized drivers entirely. I'd like this code to Just Work. Which it basically does, in Linux, just with high latency. I'm trying out the libFTDI libraries now, to see if I can speed that up a bit, and hopefully it'll also make the code easily portable to Windows... I think.
It's just a bit difficult to figure out how to work with these libraries.
I'm not interested in Windows drivers--in fact, I'd rather stay away from specialized drivers entirely. I'd like this code to Just Work. Which it basically does, in Linux, just with high latency. I'm trying out the libFTDI libraries now, to see if I can speed that up a bit, and hopefully it'll also make the code easily portable to Windows... I think.
It's just a bit difficult to figure out how to work with these libraries.
tafoxx
Robot Builder
Robot Builder
Posts: 17
Joined: Thu Jun 18, 2009 11:43 am

Post by siempre.aprendiendo » Thu Jul 02, 2009 6:41 pm

Post by siempre.aprendiendo
Thu Jul 02, 2009 6:41 pm

Bullit wrote:The D2XX drivers are the fastest. I don't know about the performance with windows CE but FTDI has drivers for CE
http://ftdichip.com/Drivers/D2XX.htm
As I recall there is a low latency setting in the interface.


The windows driver isn't very fast... but I should find and try setting this "low lattency".

When I receive the cable for the IPaq 214 (with usb host) I will prove the Win CE driver, but I think it will not be as fast as the linux driver.

Thank you again, Bullit
Bullit wrote:The D2XX drivers are the fastest. I don't know about the performance with windows CE but FTDI has drivers for CE
http://ftdichip.com/Drivers/D2XX.htm
As I recall there is a low latency setting in the interface.


The windows driver isn't very fast... but I should find and try setting this "low lattency".

When I receive the cable for the IPaq 214 (with usb host) I will prove the Win CE driver, but I think it will not be as fast as the linux driver.

Thank you again, Bullit
siempre.aprendiendo
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 559
Joined: Wed Aug 08, 2007 9:13 pm
Location: Barcelona


13 postsPage 1 of 1
13 postsPage 1 of 1