This project provides a MATLAB MEX-based interface to control TDK vibrotactors using the tactor
MEX function. The interface supports both character-based and integer-based commands, enabling efficient communication with TDK devices.
- MATLAB R2024b or later
- Microsoft Visual C++ Compiler (e.g., MSVC 2022)
- TDK API files, including required
.dll
and.lib
files
- Place the
+tdk
folder in your MATLAB path. The best way is by cloning from Git and adding it to your project as a submodule:cd your_project_folder git submodule add [email protected]:Neuro-Mechatronics-Interfaces/matlab_package__tdk.git +tdk
- From MATLAB, run
tdk.install
to compile the MEX file:Usecd your_project_folder; tdk.install();
tdk.install(true)
to force recompilation if needed. - Basically all functions need the
deviceID
returned by tdk.open():You should usedeviceID = tdk.open();
tdk.close();
at the end of a script to ensure that the device connection is closed.
Multiple calls totdk.open()
(e.g. while device is already open) should not disrupt an existing connection, but if a connection already exists the interface assumes thatdeviceID
is 0 and returns that default value.
Now, you can use the tactor
MEX function or the helper package functions in +tdk
as explained below.
The package provides the following high-level functions for ease of use:
Status: Working
Opens the first available device and initializes the TDK library.
- Usage:
deviceID = tdk.open();
- Output:
deviceID
: Integer identifier for the connected device.
Status: Working
Closes the connection to the device and shuts down the library.
- Usage:
tdk.close();
Status: Working
Pulses the connected tactor for a specified duration.
- Usage:
tdk.pulse(deviceID, duration);
- Parameters:
deviceID
: Integer identifier for the connected device.duration
: Duration of the pulse in milliseconds (1-2500).
Status: Working
Sets the gain (intensity) of the connected tactor.
- Usage:
tdk.setGain(deviceID, gain);
- Parameters:
deviceID
: Integer identifier for the connected device.gain
: Integer value between1
(minimum) and255
(maximum).
Status: Working
Sets the frequency of the connected tactor.
- Usage:
tdk.setFrequency(deviceID, frequency);
- Parameters:
deviceID
: Integer identifier for the connected device.frequency
: Integer value between300
and3500
Hz.
Status: Working
Applies a frequency ramp to the connected tactor.
- Usage:
tdk.setFrequencyRamp(deviceID, startFreq, endFreq, duration);
- Parameters:
deviceID
: Integer identifier for the connected device.startFreq
: Start frequency in Hz (300-3500).endFreq
: End frequency in Hz (300-3500).duration
: Duration of the ramp in milliseconds (1-2500).
Status: Working
Applies a gain ramp to the connected tactor.
- Usage:
tdk.setGainRamp(deviceID, startGain, endGain, duration);
- Parameters:
deviceID
: Integer identifier for the connected device.startGain
: Start gain (1-255).endGain
: End gain (1-255).duration
: Duration of the ramp in milliseconds (1-2500).
Status: Working
Stops all active tactors.
- Usage:
tdk.stop(deviceID);
- Parameters:
deviceID
: Integer identifier for the connected device.
Use tdk.example
to install and see how to use functions in the package.
cd your_project_folder;
tdk.example;