The stimulator RehaStim2 developed by the company HASOMED offers an open communication protocol named ScienceMode2. The device has eight stimulation channels and can be externally controlled via a standard USB interface (USB-serial). Galvanic isolation of the serial link is built-in into the stimulator device.

A detailed desciption of the ScienceMode2 protocol for the RehaStim2 can be found here.

Different ways exist to control the RehaStim2 stimulator from Simulink:

Real-Time Windows Target Eclipse IDE / Embedded Coder Simulation with Real-Time Sync Block xPC-Target (hard real-time)
State of implementation Implementation is possible, but not started Done for Windows (32 and 64 Bit) and Linux (32 Bit only tested) Done Not possible (requires RS232 interface)
Real-time capability Very good (hard real-time) Good (problems under high CPU load, soft real-time) Average (problems under high CPU load and when moving/resizing Matlab-related windows, soft real-time) Very good (hard real-time)

In order to allow the realization of custom stimulation programs, a stimulator interface block for Simulink was developed. This allows scientists to change stimulation parameters like pulse widths and current amplitudes in real-time using the ScienceMode2 protocol (supported is only the channel-list mode). Every pulse can be adjusted individually. Another interesting feature is the triggering of higher frequency pulse groups, like doublets and triplets. Communication between the stimulator and the PC is established via USB (virtual COM port). The communication link is electrically isolated for safety reasons. Using the large block set available within Simulink, the user is able to create complex stimulation patterns. Even the set-up of state machines as well as the design and the implementation of feedback control systems are possible.

Simulink Diagram with stimulator interface and real-time sync block.

The following installation steps are for MS Windows 7 and Matlab 2012b.

Eclipse IDE / Embedded Coder (soft real-time)

Check out the latest code using Subversion:

svn checkout svn:// simulink_rehastim2_embedded_coder

Then please follow the instructions given in the document Simulink_ScienceMode2.pdf which you can find inside the checked out code directory.

Simulation with Sync-Block (soft real-time)

Check out the latest code using Subversion:

svn checkout svn:// simulink_rehastim2

• Install the Microsoft SDK 7.1. Chose it as compiler by using in Matlab the command

mex –setup

• Change in Matlab to the code directory simulink_rehastim2, then execute


in order to generate the mex-files for the block s-functions.

Then please follow the instructions given in the document Simulink_ScienceMode2_SoftRealTime_Windows.pdf which you can find in the documentation directory.

Download Releases

rehastim2.txt · Last modified: 2017/01/11 15:30 by kuberski

Page Tools