Application Note
Matlab Control of the DS8R Stimulator
Updated 19th February 2026
Introduction
One of the most important features of the new Digitimer DS8R Research Stimulator, is its ability to be controlled by external hardware and software. Such control allows for pre-programmed, automated changes in stimulation parameters and opens up opportunities for “closed-loop feedback” control of stimulation, for instance in response to nerve or EMG signals, which might be important in applications such as functional electrical stimulation (FES) and rehabilitation.
The Digitimer DS8R Stimulator incorporates a Windows compatible advanced programmers interface (API) which enables third party control of the stimulator via Matlab, Python and other software packages. When the DS8R was first launched the software GUI included an API that incoporated a Dynamic Link Library (DLL), allowing third party software and bespoke applications to control the stimulator.
In 2025, the D188 and DS8R GUI/API programs were overhauled to prevent PC disconnections, observed when the DS8R and D188 Remote Electrode Selector were connected to the same host PC. In an effort to simplify third-party control of both devices, the new API now takes the form of a Common Object Model (COM) out-of-process Server.
Through a few exposed interfaces, the COM Server enables applications to manage one or more D188 or DS8R Devices connected to the PC. The COM Server manages all the raw communications between the PC and the connected devices. To be able to make use of the API, the chosen programming language must be able to create references to Windows COM objects and support the IDispatch interface. Programming languages known to provide this support are, but not limited to, C++, Visual Basic, C#, Python & Delphi. Additionally, it is possible to create references to COM Objects in MatLab, LabView & Octave. Although these applications may not provide full support for features such as event management.
For existing users, the updated D188 and DS8R sotware continues to support the previous DLL based control.
Here we provide basic instructions for implementing Matlab control of the DS8R and include a sample program (tested in Octave) that provides a basic demonstration of this extremely useful capability.
Hardware & Software Requirements
- DS8R Stimulator.
- USB cable (supplied with DS8R).
- Personal Computer running 32bit or 64bit version of Windows 10.
- Digitimer DS8R Virtual Front Panel Software Installer (supplied with DS8R).
- Base Matlab or Octave package, including a third-party compiler.
- Digitimer DS8R API Reference document (PDF).
Demonstrating Matlab/Octave Control
This simple example program demonstrates control of the DS8R:-
clear;
clc;
clf;
pkg load windows;
global ds8r;
function devCount = WaitForDevice
global ds8r;
ds8r = actxserver("DS8R.DS8RController");
nSeconds = time() + 5;
devCount = 0;
while ((time() < nSeconds) && (devCount == 0))
collection = ds8r.GetState;
devCount = collection.Count;
endwhile
endfunction
function ShowDeviceState(State)
printf("Serial Number = %d\n", State.SerialNumber);
printf("Demand = %d uA\n", State.Demand);
printf("DemandLimit = %d uA\n", State.DemandLimit);
printf("Pulse Width = %d us\n", State.PulseWidth);
printf("Recovery = %d %%\n", State.Recovery);
printf("Dwell = %d us\n", State.Dwell);
endfunction
function ToggleDeviceDemand(State)
global ds8r;
if (State.Demand==0)
State.Demand = 10000;
else
State.Demand = 0;
endif
ds8r.SetState(State);
endfunction
devCount = WaitForDevice();
if (devCount>0)
collection = ds8r.GetState;
state = collection.items(0);
ShowDeviceState(state);
ToggleDeviceDemand(state);
endif
printf("\nFinished\n");
Control using other software
The DS8R API reference document linked above also includes example code for DS8R control using Visual Basic and Python.
Limitatons
The DS8R API allows for a maximum trigger frequency of 10Hz. For applications that require higher frequencies, the DS8R has a dedicated hardware TTL compatible trigger input.
Triggering and parameter changes made over USB may suffer from some timing variability as the PC operating system may prioritise other activities over USB data transfer.