Tondaj SL-814

From sigrok
Revision as of 10:18, 23 October 2016 by Abraxa (talk | contribs) (→‎Protocol)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Tondaj SL-814
Tondaj sl-814.png
Status supported
Source code tondaj-sl-814
Connectivity USB/serial
Frequency range 31.5Hz - 8.5kHz
Measurement range (A) 40dB - 130dB
Resolution 0.1dB
Accuracy (94dB@1kHz) 2dB
Frequency weighting A, C
Time weighting F, S
Website tondaj.cn

The Tondaj SL-814 (also referred to as TDJ SL814 sometimes) is a sound level meter with USB connectivity.

It is available from many different vendors, partly under different names or as noname "sound level meter", e.g. on aliexpress.com, amazon.com (from resellers such as Neewer, Skque, Generic, HDE, BestDealUSA, and many others).

The device has an auto-poweroff feature which leads to a power-off after 5 minutes. There is no known way to prevent this from happening when running off of batteries. When connected via USB, the device stays powered on. As soon as the connection is removed though, the 5 minute timer for poweroff starts.

See Tondaj SL-814/Info for more details (such as lsusb -vvv output) about the device.

Hardware

Device:

USB cable:

Photos

Device:

USB cable:

See Device_cables#Tondaj_SL-814_cable.

Protocol

The device has a mini-USB connector for PC connectivity. It ships with a Prolific USB-to-serial cable (i.e. the PL2303 Prolific chip is inside the cable) which can be attached to that connector. The pinout of the USB side of the cable appears to be a little unusual: 1-NC, 2-TX, 3-RX, 4-GND, 5-GND (green/white swapped, red disconnected).

The device accepts a simple command-based protocol over the (virtual) serial port, using a baudrate of 9600 baud, with 8e1 settings (8 data bits, even parity, one stop bit).

Commands / replies

Commands and replies can consist of multiple bytes, and always end with 0x0d.

Name Command Reply Comments
Init 0x10 0x04 0x0d 0x05 0x0d It's unclear what exactly this command does, likely some kind of initialization. Data transfers also seem to work fine when it is omitted. According to the scheme below in the "Send key" case it might be a "key press", but there doesn't seem to be any visible or noticeable effect at all. E.g. it does not reset any of the settings (A/C, fast/slow, and so on) to their defaults.
Send key 0x10 0xKK 0x0d 0xKK+1 0x0d This command has the same effect as if a certain key/button on the SL-814 had been pressed. The known value encodings for the key (0xKK) are: 0x20 = up arrow key, 0x30 = down arrow key, 0x40 = A/C key, 0x50 = fast/slow key. There doesn't seem to be a key code for the "MAX" button or the power button. Thanks to Chris Hoogenboom for the info about this command.
Get measurement 0x30 0xZZ 0x0d 0xAA 0xBB 0xZZ+1 0x0d For a given command with 0xZZ value (0-255), the device returns 0xZZ + 1 as part of the reply (a simple "sequence number" mechanism which is apparently meant for the host as error-checking mechanism).

Data reply

The first two bytes of the reply to the "get measurement" command (0xAA 0xBB) have the following format:

Byte Bit Value
0
7 A/C measurement type. 0: A, 1: C.
6 Unknown/unused.
5-4 Level. 00: 40, 01: 60, 10: 80, 11: 100
3 Slow/Fast measurement mode. 0: Fast, 1: Slow.
2-0 Value[10..8].
1
7-0 Value[7..0].

The actual measurement value seems to span 11 bits, and is encoded in BCD format. Example: If Value[10..0] is 436 (decimal), the corresponding measurement value is 43.6 dB.

Notes

The "MAX" mode on the device (which always keeps showing the highest measured value since the "MAX" button was pressed) only affects the value shown on the display. The values returned via USB upon the "get measurement" command, always show the current value, not the "MAX" one shown on the display.

Python script

Here's a quick Python script for getting the values out of the Tondaj SL-814.

#!/usr/bin/python3
# Tondaj SL-814 sound level meter Python script
# Copyright (C) 2012 Uwe Hermann <uwe@hermann-uwe.de>
# Released under the terms of the GNU GPL, version 2 or later.

import time
import serial

s = serial.Serial('/dev/ttyUSB0', baudrate=9600, parity=serial.PARITY_EVEN)

while 1:
    # Query
    s.write(bytes([0x30, 0x01, 0x0d]))
    result = s.read(4)
    print('%02x %02x %02x %02x' % tuple(result), end='   -   ')

    # A/C
    ac = (result[0] & (1 << 7)) >> 7
    print('A' if ac == 0 else 'C', end=', ')

    # Slow/Fast
    sl = (result[0] & (1 << 3)) >> 3
    print('Fast' if sl == 0 else 'Slow', end=', ')

    # Level
    factor = (result[0] & ((1 << 5) | (1 << 4))) >> 4
    print('Level: %d' % (40 + (int(bin(factor), 2) * 20)), end=', ')

    # Value
    val = ((result[0] & 0x7) << 8) | result[1]
    tmp_str = '%d' % val
    val_str = tmp_str[:-1] + '.' + tmp_str[-1:]
    print(val_str + ' dB')

    time.sleep(0.5)

s.close()

Example output:

09 af 02 0d   -   A, Slow, Level: 40, 43.1 dB
09 b9 02 0d   -   A, Slow, Level: 40, 44.1 dB
09 e9 02 0d   -   A, Slow, Level: 40, 48.9 dB
89 cb 02 0d   -   C, Slow, Level: 40, 45.9 dB
89 eb 02 0d   -   C, Slow, Level: 40, 49.1 dB
8a 6c 02 0d   -   C, Slow, Level: 40, 62.0 dB
82 99 02 0d   -   C, Fast, Level: 40, 66.5 dB
82 3c 02 0d   -   C, Fast, Level: 40, 57.2 dB
82 72 02 0d   -   C, Fast, Level: 40, 62.6 dB
92 85 02 0d   -   C, Fast, Level: 60, 64.5 dB
93 05 02 0d   -   C, Fast, Level: 60, 77.3 dB
92 68 02 0d   -   C, Fast, Level: 60, 61.6 dB
a3 93 02 0d   -   C, Fast, Level: 80, 91.5 dB
a3 93 02 0d   -   C, Fast, Level: 80, 91.5 dB
a3 93 02 0d   -   C, Fast, Level: 80, 91.5 dB
b3 f2 02 0d   -   C, Fast, Level: 100, 101.0 dB
b3 f2 02 0d   -   C, Fast, Level: 100, 101.0 dB
b3 f2 02 0d   -   C, Fast, Level: 100, 101.0 dB

Resources