An ultrasound Teensy USB Mic

damienb

New member
Hello,

This topic is about a Teensy 4.0 ultrasound microphone (open source project).
Our goal is to record bats echolocating sound with a simple device connected to a phone via his USB port. The samplerate is up to 384kHz.

Here is the Github page of the project.

Roadmap :
- Schematics of the board : Done. (link in Github project)
- PCB : Done. (link in Github project)
- High Samplerate : Done. Based on Frank B work
- Windows test : OK. pe1pwf have done a nice work figuring out the modification needed.
- Android test : NOK. Apps crash when trying to record.

i don't know how to debug this. I don't have any hardware USB analyser.

Anyone managed to get a USB Teensy microphone working with Android? I suspect a problem in the enumeration.

I managed to get a log on my phone :
Code:
USB device attached.
checkUSBPermissions: id=1002 vendor=5824 class=0 name = Teensyduino
Device supported id=1002
No USB connection found for id=1002
USB device permission request.
checkUSBPermissions: id=1002 vendor=5824 class=0 name = Teensyduino
Device supported id=1002
USB connection found for id=1002
==============================
Raw descriptors:
12 01 00 02 00 00 00 40 C0 16 D3 04 14 02 01 02 03 01 09 02 E9 00 04 01 00 C0 C8 09 04 00 00 02 03 00 00 00 09 21 11 01 00 01 22 21 00 07 05 82 03 40 00 01 07 05 02 03 20 00 02 08 0B 01 03 01 01 00 00 09 04 01 00 00 01 01 00 00 0A 24 01 00 01 3E 00 02 02 03 0C 24 02 01 01 02 00 01 00 00 00 00 09 24 03 02 01 01 00 01 00 0C 24 02 03 01 01 00 02 03 00 00 00 0A 24 06 31 03 01 01 02 02 00 09 24 03 04 02 06 00 31 00 09 04 02 00 00 01 02 00 00 09 04 02 01 01 01 02 00 00 07 24 01 02 03 01 00 0B 24 02 01 02 02 10 01 00 DC 05 09 05 83 09 00 03 04 00 00 07 25 01 00 00 00 00 09 04 03 00 00 01 02 00 00 09 04 03 01 02 01 02 00 00 07 24 01 03 03 01 00 0B 24 02 01 02 02 10 01 00 DC 05 09 05 03 05 00 03 04 00 84 07 25 01 00 00 00 00 09 05 84 11 04 00 04 07 00 
fileDescriptor = 69
deviceName = /dev/bus/usb/001/002
manufacturer = Teensyduino
product = Teensy Audio
==============================
Configuration Descriptor:
Length: 233 bytes
1 Interfaces
Attributes: BusPowered SelfPowered
Max Power: 400mA

bDescriptorType=USB_INTERFACE_DESCRIPTOR bLength=9 bInterfaceNumber=0 bInterfaceClass=Human Interface Device bInterfaceSubclass=0x00 bAlternateSetting=0 bNumEndpoints=2
bDescriptorType=CS_DEVICE bLength=9
bDescriptorType=USB_ENDPOINT_DESCRIPTOR bLength=7 bEndpointAddress=130 type=Interrupt direction=IN
bDescriptorType=USB_ENDPOINT_DESCRIPTOR bLength=7 bEndpointAddress=2 type=Interrupt direction=OUT
bDescriptorType=11 bLength=8

bDescriptorType=USB_INTERFACE_DESCRIPTOR bLength=9 bInterfaceNumber=1 bInterfaceClass=Audio bInterfaceSubclass=AUDIOCONTROL bAlternateSetting=0 bNumEndpoints=0
bDescriptorType=CS_INTERFACE bLength=10 bDescriptorSubtype=HEADER bcdADC=0x000400
bDescriptorType=CS_INTERFACE bLength=12 bDescriptorSubtype=INPUT_TERMINAL bTerminalID=1 wTerminalType=0x000104 bAssocTerminal=0 bNrChannels=1
bDescriptorType=CS_INTERFACE bLength=9 bDescriptorSubtype=OUTPUT_TERMINAL bTerminalID=2 wTerminalType=0x000104 bAssocTerminal=0
bDescriptorType=CS_INTERFACE bLength=12 bDescriptorSubtype=INPUT_TERMINAL bTerminalID=3 wTerminalType=0x000104 bAssocTerminal=0 bNrChannels=2
bDescriptorType=CS_INTERFACE bLength=10 bDescriptorSubtype=FEATURE_UNIT bUnitID=49 bSourceID=3 bControlSize=1 iFeature=0
bDescriptorType=CS_INTERFACE bLength=9 bDescriptorSubtype=OUTPUT_TERMINAL bTerminalID=4 wTerminalType=0x000104 bAssocTerminal=0

bDescriptorType=USB_INTERFACE_DESCRIPTOR bLength=9 bInterfaceNumber=2 bInterfaceClass=Audio bInterfaceSubclass=AUDIOSTREAMING bAlternateSetting=0 bNumEndpoints=0

bDescriptorType=USB_INTERFACE_DESCRIPTOR bLength=9 bInterfaceNumber=2 bInterfaceClass=Audio bInterfaceSubclass=AUDIOSTREAMING bAlternateSetting=1 bNumEndpoints=1
bDescriptorType=CS_INTERFACE bLength=7 bDescriptorSubtype=AS_GENERAL bTerminalLink=2 bDelay=3 wFormatTag=1
bDescriptorType=CS_INTERFACE bLength=11 bDescriptorSubtype=FORMAT_TYPE bFormatType=1 bNrChannels=2 bSubFrameSize=2 bBitResolution=16 bSamFreqType=1 tSamFreq[0]=384000
bDescriptorType=USB_ENDPOINT_DESCRIPTOR bLength=9 bEndpointAddress=131 type=Isochronous direction=IN
bDescriptorType=CS_ENDPOINT bLength=7 bDescriptorSubtype=AS_GENERAL bmAttributes=0

bDescriptorType=USB_INTERFACE_DESCRIPTOR bLength=9 bInterfaceNumber=3 bInterfaceClass=Audio bInterfaceSubclass=AUDIOSTREAMING bAlternateSetting=0 bNumEndpoints=0

bDescriptorType=USB_INTERFACE_DESCRIPTOR bLength=9 bInterfaceNumber=3 bInterfaceClass=Audio bInterfaceSubclass=AUDIOSTREAMING bAlternateSetting=1 bNumEndpoints=2
bDescriptorType=CS_INTERFACE bLength=7 bDescriptorSubtype=AS_GENERAL bTerminalLink=3 bDelay=3 wFormatTag=1
bDescriptorType=CS_INTERFACE bLength=11 bDescriptorSubtype=FORMAT_TYPE bFormatType=1 bNrChannels=2 bSubFrameSize=2 bBitResolution=16 bSamFreqType=1 tSamFreq[0]=384000
bDescriptorType=USB_ENDPOINT_DESCRIPTOR bLength=9 bEndpointAddress=3 type=Isochronous direction=OUT
bDescriptorType=CS_ENDPOINT bLength=7 bDescriptorSubtype=AS_GENERAL bmAttributes=0
bDescriptorType=USB_ENDPOINT_DESCRIPTOR bLength=9 bEndpointAddress=132 type=Isochronous direction=IN
==============================
 
If you look at the OSWH lab of Damien you can not only find the mic PCB but also a teensy bat detector board he designed. I do not think he built it already but it shows he is well aware of the project I guess.

I built up Damiens microphone PCB and it seems to work well (used an alternatieve opamp for test), it looks like it could do with a little less amplification, but a small change in resistors around the opamp can fix that of course. Using a Knowles SPu0410LR5H-QB microphone it seems to register ultrasound quite nicely.

Only part we ran into is the USB descriptor, or at leas we think the solution should be found there. It would be nice if someone could help us in the right direction.

Edwin
 
Oops, I think I damaged the usb descriptor to a point where windows does not recognize it and I can not reprogram the Teensy.

Or is my Teensy simply broken, I did see some reset trick for the Teensy 3.6 (15 seconds press on the program button). I could not find if something similar exists for the Teensy4.0

The red led does come on after a few presses (an can be switched off), I also managed to mess up the descriptor earlier, but now it really seems broken. Is that even possible? I am not messing with the HID part of the descriptor, just with the audio part.

Any help is appreciated.

Kind regards,

Edwin
 
I could not find if something similar exists for the Teensy4.0
Yes there is:
Memory Wipe & LED Blink Restore
Teensy 4.0 will fully erase its non-volatile memory and return the flash memory to a simple LED blink program if the program button is held between 13 to 17 seconds. The red LED flashes briefly at the beginning of this time window. During flash erase, the red LED is on bright. When completed, Teensy 4.0 will automatically reboot and run the LED blink program, causing the orange LED to blink slowly.
Found on this page.

Paul
 
Thanks Paul, I overlooked the memory wipe function. I searched on that page with the wrong words. I did try to press the button for 15 seconds and als have it pressed for 15 seconds when plugging in the USB cable but that did seem to do the trick. It was actually windows that somehow had the USB messed up. I was able to load working code again using linux.

Now I am back on Windows with a working ultrasound microphone. Linux does not accept it as a working microphone. I also see an analog playback and spdiv playback and input device. I tried changing the descriptor so that it would only show up as mono microphone device but almost every change makes me run into errors.

Edwin
 
Back
Top