Results 1 to 7 of 7

Thread: Teensy 3.6 USB Host control - Talking with USB2AX ;)

  1. #1

    Teensy 3.6 USB Host control - Talking with USB2AX ;)

    As many of you probably know. Over the last year or two I have spent a lot of time playing around with some of the new Teensy boards ( Recently I have been trying to help out to add some USB host support to the Teensy 3.6. Currently we have some support for Keyboards (that have boot protocol), plus Mice, plus Joysticks (PS3/4 USB mode). And now working on Serial adapter support.

    On Serial adapter support, have some support in for FTDI, CDCACM, PL2303, CH341, CPI210x chip sets. I made some significant changes now and doing another round of testing.

    So thought it would be fun to hack up my Arduino AX servo test program to use a Usb serial object and plugged in an USB2AX adapter. Some of it is working, but getting some interesting RX packets back which I am trying to understand if it is a CDCACM encoding scheme or a USB2AX thing or if I should just handle it in the user code.

    From my last posting about it on the PJRC forum:


    Right now I am trying to understand how Serial data is sent back from the device to us... i.e. how rx_data is supposed to work. In particular in the count of actual data bytes in a packet.

    Currently the code gets this by: uint32_t len = transfer->length - ((transfer->qtd.token >> 16) & 0x7FFF);

    Which if you look at the Enhanced Host Controller Document (like:
    And look at the QTD definition we see bits 16-30 are the count to be subtracted from the transfer->length... so this makes sense.

    You have code in that if it is FTDI if count> 2 you subtract 2 from it... Not sure if this is specific to FTDI?

    The issue. When I am receiving data back from USB2AX (CDCACM Atmega32u2), I am getting some interesting results. Not sure if it is by design or something else.
    I do the query for several of the registers of the controller.
    The first few work fine: There is additional printing going on...
    0:ax12 ReadPackettxtimer
      TX data (8) FF FF FD 04 02 00 01 FB 
    rx token: 98100 transfer length: 16 len:7 - FF FF
    rx: FF FF FD 03 00 01 FE 
     - valid data
    1 1:ax12 ReadPackettxtimer
      TX data (8) FF FF FD 04 02 01 01 FA 
    rx token: 80098100 transfer length: 16 len:7 - FF FF
    rx: FF FF FD 03 00 42 BD 
     - valid data
    So we transfer a packet: FF FF FD 04 02 00 01 FB - Read register on device FD Starting register 0 length 1 byte.. FB is checksum
    We receive back a packet: where bits 16-30 = 9 and packet size 16 so 7 byte packet: FF FF FD 03 00 42 BD
    Which translated in Repsonse for FD and result is 1...

    Similar for register 1... - response 0x42.

    However many of the other query responses are somewhat strange.
    FD 4:ax12 ReadPackettxtimer
      TX data (8) FF FF FD 04 02 04 01 F7 
    rx token: 38100 transfer length: 16 len:13 - FF FF
    rx: FF FF FD 02 08 F8 FF FF FD 03 00 08 F7 
     - Checksum
    FF FF FD 2 8 F8 FF  : FE
    FFFFFFFF 5:ax12 ReadPackettxtimer
      TX data (8) FF FF FD 04 02 05 01 F6 
    rx token: 80038100 transfer length: 16 len:13 - FF FF
    rx: FF FF FD 02 08 F8 FF FF FD 03 00 07 F8 
     - Checksum
    FF FF FD 2 8 F8 FF  : FE
    That is by the logic it says the responses are 13 bytes. Again not sure if this is a something different about CDCACM or just how the USB2AX is working.
    Again would expect 7 byte returned.

    Note: I may be able to get right data here. That is if you look at the last ones response: FF FF FD 02 08 F8 FF FF FD 03 00 07 F8
    There are actually two packets here: FF FF marks start, FD=ID, 02 count of bytes remaining including checksum which we check is wrong... FE should be FF

    Currently my code sees this and bails with error. But following this in packet is probably a valid response. I have not actually verified the checksum is
    correct. ...

    So again wondering if this is some CDCACM thing or maybe USB2AX thing... Will try pulling out a different servo controller which is FTDI based and see what it does.

    Will probably also ask up on Trossen forum as the USB2AX developer communicates up there.


    P.S - Next up dig out a Arbotix-Pro (I think I still have one that may work) and see how it responds. And also try plugging in a Teensy running sketch that makes it act like the Arbotix-pro or USB2AX

  2. Re: Teensy 3.6 USB Host control - Talking with USB2AX ;)

    Hey Kurt,

    That's a pretty fun project
    I'll try to have a look into this this week end.
    Personal blog:
    USB2AX documentation:

  3. #3

    Re: Teensy 3.6 USB Host control - Talking with USB2AX ;)

    Yep - Learning a lot about USB stuff here. Including how to use the Saleae logic analyzer to view the USB data...

    I just ordered a new USB2AX v3.2b from Seeed... As the one I am trying with is a 3.1a.

    Would have ordered from Trossen, but they show the 3.2a as out of stock, Unless you buy it with Power supply, Hub, ...

    I have also now tried with the Arbotix-Pro, which is giving different strange results. The response packets are eating the first or second 0xff of the packet so I am erroring those out. Not sure if that is an FTDI issue as our internal Host USB code on FTDI ignores the first two bytes as FTDI sends out 2 byte Packets at an interval, ... Need to learn more about this part...

    Also trying right now with it talking to another Teensy 3.6 acting sort of like an Arbotix-Pro (no IMU stuff). It is getting many of the registers back, but still debugging...

  4. Re: Teensy 3.6 USB Host control - Talking with USB2AX ;)

    v3.2b is not very diffenrent from v3.2a, only one resistor value changed (to lower risks of errors when talking to LOTS of servos).
    You should update the firmware of both to the latest version though. Should not change anything in your case but at least you have erverything as fresh as possible this way.
    Personal blog:
    USB2AX documentation:

  5. #5

    Re: Teensy 3.6 USB Host control - Talking with USB2AX ;)

    Thanks I updated the 3.1a board to the latest earlier today as to make sure I was not running my own version.

    i had problems with gui app on win10 64 bit. So went to Linux box. First attempts failed but then worked when I used sudo

  6. Re: Teensy 3.6 USB Host control - Talking with USB2AX ;)


    So I had a quick look, but so far I'm not sure about anything.
    The USB2AX tries to send back stuff to the host as fast as possible, so the timeout for sending bytes is very low. Low timeout can help lower latency for small packets, but impacts throughput negatively when packets get larger (it will send back the first part of the packet early then have to wait the next frame to sedn the rest instead of sending everything together slightly later).
    All of the logic behind this is hidden away in LUFA, I do not know much about it.

    I don't see how that could help you though... :/
    Personal blog:
    USB2AX documentation:

  7. #7

    Re: Teensy 3.6 USB Host control - Talking with USB2AX ;)

    Thanks Xevel, will be interesting to see if I can still reproduce the case that this happens. Or maybe doesn't with the current image on the usb2ax...

    I am learning a lot more about USB then I ever did, trying to add the support to the host code on the Teensy. Luckily Paul (PJRC) has done all of the hard work...

    Things like the USB2AX sends and receives 16 byte packets, so does not take much to fill them. Many other devices have 64 byte packets including most FTDI and the Teensy...

    As I mentioned, learning a lot, using some Linux commands to figure out how some of the devices are configured.

    Also using Logic Analyzer to decode the USB data.

    Example here is a return packet from the USB2AX to query for one byte:
    Click image for larger version. 

Name:	screenshot.jpg 
Views:	56 
Size:	35.8 KB 
ID:	7096

    I will debug some more later to see if it still reproduces at all...

    Thanks again!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Trying to debug HROS1 with RPI talking to Arbotix Pro
    By KurtEck in forum HR-OS1 Development and Discussion
    Replies: 92
    Last Post: 05-07-2016, 10:11 PM
  2. Replies: 7
    Last Post: 01-10-2016, 04:14 AM
  3. Question(s) Arduino Mega talking to Pincher
    By kelly.edlyn in forum Interbotix Robotic Arms
    Replies: 3
    Last Post: 11-20-2015, 02:06 AM
  4. I2C host controller
    By csdude in forum Arbotix, Microcontrollers, Arduino
    Replies: 8
    Last Post: 01-18-2010, 02:51 AM
  5. Project R2Talk2 - a talking robot with rotating head
    By Macro Man in forum Project Showcase
    Replies: 16
    Last Post: 09-13-2009, 07:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts