USBlini - USB to LIN Interface
USBlini connects a LIN bus via USB to a host system. It provides easy access to LIN bus devices and can act as both master and slave. It features a logic analyzer function to sample the logic levels on the LIN RX line.- Open source Python library (Windows, MacOS, Linux)
- Master mode (generate frames) and slave mode (response to master requests)
- Logic analyzer function: sample logic levels on LIN-RX with 100ksps
- Integrated 1kOhm master pullup
- Flexible baudrate configuration via software 1200 – 20000 Baud (e.g. 9600, 10400, 19200)
- Firmware sources available; bootloader for firmware updates
Contents
Software
A Python library is available for easy and rapid development on different operating systems.Python library "pyUSBlini" (Windows, MacOS, Linux)
pyUSBlini is a Python library for the USBlini adapter which allows easy, platform-independent access to LIN devices.
Step-by-step tutorials:
Depending on the application, under Windows a libusb-1.0.dll is required. These can be found for various architectures on the libusb project homepage under "Download -> Windows Binaries". Please place the DLL in the application folder (e.g. in the "Scripts" folder for Anaconda Python).
Step-by-step tutorials:
Installation
The easiest way to install the library is using pip:pip install git+https://github.com/EmbedME/pyUSBlini
Drivers
The library uses libusb. On Linux and MacOS X no kernel driver is needed. Please use following tool for Windows to install the "WinUSB" driver:Depending on the application, under Windows a libusb-1.0.dll is required. These can be found for various architectures on the libusb project homepage under "Download -> Windows Binaries". Please place the DLL in the application folder (e.g. in the "Scripts" folder for Anaconda Python).
Example
Request data for ID 0x10 via master write:from usblini import USBlini usblini = USBlini() usblini.open() data = usblini.master_write(0x10, USBlini.CHECKSUM_MODE_LIN2, []) print(data) # print out response usblini.close()
Simple graphic interface "USBliniGUI" (Windows, MacOS, Linux)
Based on the python library there is a simple graphic application: USBliniGUI.
How-to use USBlini with Python on Windows 10 and run USBliniGUI.py.
How-to use USBlini with Python on Windows 10 and run USBliniGUI.py.
Logic analyzing with PulseView (Windows, MacOS, Linux)
With the logic recording function (USBliniGUI -> Logic), the logic level on the LIN RX line can be captured and then analyzed with PulseView.
How-to analyse USBliniGUI recordings with PulseView
How-to analyse USBliniGUI recordings with PulseView
Firmware
Source code and HEX file
The firmware of USBlini is available as precompiled HEX file and as C (XC8 compiler) source code.
Precompiled HEX and source code archive:
Precompiled HEX and source code archive:
USBlini_firmware_v1.01.zip (2022-11-08) Increased receive timeout (intrabyte: 16 tbit, response: 50 tbit)
USBlini_firmware_v1.00.zip (2021-12-28) First public version
Firmware update via bootloader
Start the bootloader via software (e.g. start_bootloader.py). Use a bootloader application ( MPHidFlash) to load the new firmware into USBlini:
mphidflash -w USBlini_firmware_v1.01.hex -r
Hardware
Schematic - USBlini's circuit diagram
Partlist - Build your own USBlini!
Here you find a list of all parts needed to build your own USBlini board.
Partnumber | Value |
---|---|
C1 | 4,7u |
C2, C3, C4 | 220n / 50V |
C5 | 1u / 50V |
C6 | 220p / 100V |
D1 | BAT54S |
IC1 | PIC16F1454 |
IC2 | MCP2003B |
LED1 | red LED |
R1, R2, R3 | 1k |
X1 | USB-B |
X2 | 2pol 2.54mm |
Troubleshooting
Linux: "LIBUSB_ERROR_ACCESS" as non-root
Add udev rule to give permissions to all users.sudo bash -c $'echo \'SUBSYSTEM=="usb", ATTRS{product}=="USBlini", MODE="0666"\' > /etc/udev/rules.d/50-USBlini.rules' sudo udevadm control --reload-rules
Gallery
Please tell me about your USBlini project!
Retrieve status from LIN slave 8W1919616 (Audi A4 audio control panel). Example Python script: 8W1919616.py by Thomas Fischl (06/2022) |
||
Set voltage of alternator (controlled by TLE8880) and monitor temperature and battery voltage. Python script: TLE8880.py by Lucas K. (12/2022) |
||
Digital BMWay uses USBlini as a development tool for the BMW Ambient Light+ retrofit kit.
by Digital BMWay (02/2023) |
||
Read parameter from refrigerator Thetford N4000 series via CI-bus: supply type and voltages are interpreted. Unfortunately, it is not yet known how the temperature can be read - you know? Please contact us! Github project: CI-Bus interface for Thetford N4000 refrigerator by Jörg W. (07/2023) |
||
Maxim has wired a USBlini from several breakout boards. by Maxim D. (06/2024) |
||
Stefan has designed a housing for the USBlini board: USBlini Case on Thingiverse. by Stefan N. (09/2024) |
Links
Other LIN interface projects/products
PLIN-USB by PEAK-SystemLUC by ucandevices
Kvaser Leaf Professional LIN