Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: Teensy USB delay

  1. #1
    Junior Member
    Join Date
    Sep 2019
    Posts
    15

    Teensy USB delay

    Hi,

    I've done latency measurements for the Teensy LC by connecting it to an Arduino with an usb host shield to measure the lag
    with the usblag project, see https://gitlab.com/loic.petit/usblag

    As test program on Teensy I used a very simple program:
    Code:
    void setup() {
      pinMode(1, INPUT_PULLUP);
      Joystick.useManualSend(true);
    }
    
    void loop() {
      Joystick.button(1, !digitalRead(1));
      Joystick.send_now();
    }
    I.e. it reads input pin 1 and outputs it via USB. Pin 1 is connected to the Arduino running usblag.

    When I ran the usblag test program (input 'o', 't')
    the result is a measured delay of 5-7ms although the polling rate is 1ms.

    Here is the output from usblag:
    Code:
    Start
    Interval:		1ms
    Cannot read HID report
    HID Controller initialized
    Override polling interval to 1ms!
    Launching test
    6.51
    6.94
    6.50
    7.09
    6.44
    6.90
    6.70
    6.77
    7.09
    6.96
    7.09
    6.37
    7.16
    The numbers you see are the measured latency values in ms.
    (Of course, maybe 'usblag' is reporting strange values, although the reported values seem to be very reasonable when measuring other joystick controllers.)

    Does anybody has similar experiences with the Teensy LC or other Teensys?
    Is Teensy LC too slow for 1ms poll?



    Just as reference: I setup a new joystick device in usb_desc.h/board.txt. Here is the code:
    usb_desc.h:
    Code:
    #elif defined(USB_SERIAL_JOYSTICK)
      #define VENDOR_ID		0x16C0
      #define PRODUCT_ID		0x0487
      #define DEVICE_CLASS		0xEF
      #define DEVICE_SUBCLASS	0x02
      #define DEVICE_PROTOCOL	0x01
      #define MANUFACTURER_NAME	{'M','a','z','i','a','c'}
      #define MANUFACTURER_NAME_LEN	6
      #define PRODUCT_NAME		{'A','r','c','a','d','e',' ','J','o','y','s','t','i','c','k',' ','E','n','c','o','d','e','r'}
      #define PRODUCT_NAME_LEN	23
      #define EP0_SIZE		64
      #define NUM_USB_BUFFERS	24 //30
      #define NUM_ENDPOINTS		4
      #define NUM_INTERFACE		2
      #define CDC_IAD_DESCRIPTOR	1
      #define CDC_STATUS_INTERFACE	0
      #define CDC_DATA_INTERFACE	  1	// Serial
      #define CDC_ACM_ENDPOINT	    1
      #define CDC_RX_ENDPOINT       2
      #define CDC_TX_ENDPOINT       3
      #define CDC_ACM_SIZE          16
      #define CDC_RX_SIZE           64
      #define CDC_TX_SIZE           64
      #define JOYSTICK_INTERFACE    4	// Joystick
      #define JOYSTICK_ENDPOINT     4
      #define JOYSTICK_SIZE         12	//  12 = normal, 64 = extreme joystick
      #define JOYSTICK_INTERVAL     1
      #define ENDPOINT1_CONFIG	ENDPOINT_TRANSMIT_ONLY
      #define ENDPOINT2_CONFIG	ENDPOINT_RECEIVE_ONLY
      #define ENDPOINT3_CONFIG	ENDPOINT_TRANSMIT_ONLY
      #define ENDPOINT4_CONFIG	ENDPOINT_TRANSMIT_ONLY
    board.txt:
    Code:
    teensyLC.menu.usb.serialjoystick=Serial + Joystick
    teensyLC.menu.usb.serialjoystick.build.usbtype=USB_SERIAL_JOYSTICK

    The code is compiling and the "Joystick" is recognized and working fine under Mac and Linux.

  2. #2
    Junior Member
    Join Date
    Sep 2019
    Posts
    15
    It seems that the problem is not the Teensy (LC) but the usblag. There seem to be lags when usblag is polling the USB.
    It tested on Linux without seeing this problem.

Posting Permissions

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