Using NI CompactRIO and NI LabVIEW to Control a Supine Gait Rehabilitation Device

  Print Print

"We chose the CompactRIO platform because it features real-time capabilities, customization flexibility for real-time control with FPGA, digital output for the hip and knee linear actuators, and analog output for the ankle linear actuator with analog input for the EMG signals."

- Ruyi Foong, National University of Singapore

The Challenge:
Stimulating lower limb neuro-motor learning for bedridden stroke patients to increase their success in future gait therapy and to better regain mobility.

The Solution:
Using NI CompactRIO hardware and NI LabVIEW software to develop a robotic device that moves the patient’s lower limbs in a gait cycle.

Ruyi Foong - National University of Singapore
Haoyong Yu - National University of Singapore

We developed a supine gait rehabilitation Device’ device for subacute stroke patients consisting of robotic links that attach a hospital bed. The mechanical links move the lower limb joints in the main degree of freedom. Linear actuators change the angles of the hip, knee, and ankle joints according to the gait cycle. Figure 1 shows the conceptualized design Figure 2 shows the completed prototype of one side of the device with an artificial leg as the load.

We place surface electromyography (EMG) electrodes on the main muscle groups of the patients’ lower limbs to generate signals and stimulate the neuro-motor learning effects. We use EMG which commonly indicates the onset and offset of muscle activity in clinical practice to detect the patients' will to move their limbs.

Our device helps patients use their time in bed to undergo rehabilitation even if they cannot sit or stand. The device provides biofeedback to stimulates neuro-motor learning and focuses on the gait cycle. This means patients’ lower limb muscles  become more receptive to conventional gait rehabilitation later on when they regain the necessary strength, which increases the likelihood of regaining mobility.


System Overview

The NI CompactRIO platform controls the linear actuators as a system. We chose the CompactRIO platform because it  features real-time capabilities customization flexibility for real-time control with FPGA, digital output for the hip and knee linear actuators, and analog output for the ankle linear actuator with analog input for the EMG signals. Our system includes the NI cRIO-9022 controller, the NI cRIO-9111 chassis, and various suitable C Series modules. We use NI LabVIEW software for the system development and programming on a host PC. Figure 3 shows the block diagram of  the NI system and Figure 4 shows how the C Series modules connect to the external hardware.

The higher level control consists of the user interface on the host PC and the real-time operating system (RTOS) in the NI controller (Figure 3). The user interface receives the input parameter values set by the patient while the RTOS processes these values to calculate corresponding output values. The lower level control then receives instructions to execute the FPGA code to move the actuators according to the gait cycle trajectory. The actuators move the links which guide the patient’s limbs and generate muscle activation and EMG signals. The system internally performs position feedback through the drivers of the linear actuators. The patient can interact with the user interface while using the device.


Finite State Machine for Higher Level Control

There are many ways to implement the higher level control, but we chose finite state machine architecture. Due to speed and safety considerations, there are three ‘states’: the initializsation state in which the actuators move to the first stroke-length value, the exercise state in which the actuators move the mechanical links according to the gait cycle, and the return home action in which the actuators move back toward zero stroke length. In light of this, we are using simple finite state machine architecture with just three states. Figure 3 shows the flow between the states. The dialog boxes illustrate when the top-level program runs. Other parameters ensure there are no infinite loops, but we excluded them from the diagram for simplicity.


User Interface

Patients can select and adjust some parameters of the gait cycle with the user interface. The user interface is especially important for providing biofeedback to the patients as they can see their EMG signals. By providing such feedback, the device stimulates neuro-motor learning in the leg muscles. Figure 6 shows the user interface and Table 1 explains the various user interface controls and indicators.


System Modes

There are two modes: auto and EMG trigger (Figure 6). These modes provide more flexibility to the patients and accommodate their different strength conditions. In the auto mode, the system guides the patients' limbs through the gait cycle trajectory without any input from the patients affecting the movement. This mode especially benefits weak patients who need to regain strength in their muscles and is based on the literature review that repetitive actions help activate and strengthen the muscles and rebuild the neural pathways at the same time. However, a purely passive exercise is undesirable. Thus, to engage patients, the system records their EMGs so they can see that their muscles receive the exercise.

In the EMG trigger mode, at any point in time of the exercise, the device moves only when the muscle activation produced by the patient and detected via EMG, is past a certain threshold. Users can adjust the threshold as levels of muscle activation vary depending on the severity of the stroke and the stage of recovery. Patients who have regained some strength and need the challenge to further improve find this mode useful. This mode is based on the literature review that patients should be as actively involved in their rehabilitation as possible to aid the neuroplasticity effect, and therefore only use robotic assistance when the patient puts in the effort to produce a minimum amount of force.

Figure 7 shows the general flow of the modes. When the program starts, if the user selects auto mode, the program moves the actuators. However, if the user chooses EMG trigger mode, the program waits until the patient succeeds in generating enough muscle activation for the EMG signal to exceed the threshold value. This comparison happens at every point in time of the gait cycle.


Test Results

We tested the system under the auto mode and the EMG trigger mode with generated EMG signals. Figures 8 and 9 show screenshots of the user interface at the end of some tests. In the auto mode (Figure 8), there is no red line indicating a specified EMG threshold because there is no EMG comparison to perform. However, the EMG signal from the patient is shown to provide the biofeedback. Figure 9 shows an EMG trigger mode example, including a red line on the EMG graph with an adjustable EMG threshold. During the test, we successfully verified that the device only moved when the EMG signal was above the threshold value.



We used CompactRIO and LabVIEW to develop a supine gait rehabilitation device that provides in-bed rehabilitation to sub-acute stroke patients. We combined the NI CompactRIO with robotic links and various linear actuators to control the device to move the patients’ lower limbs in the gait cycle. The system used finite state machine architecture for the higher level control, while the lower-level control was via FPGA. The system also incorporated different modes of therapy. We developed a user interface to interact with the patient and provide biofeedback to stimulate neuro-motor learning.

The Design-Centric Programme in the Faculty of Engineering, National University of Singapore funded and supported this project. Various NI engineers also provided invaluable advice and help.

Author Information:
Ruyi Foong
National University of Singapore
21 Lower Kent Ridge Road
Tel: 6582369309

Bookmark and Share

Explore the NI Developer Community

Discover and collaborate on the latest example code and tutorials with a worldwide community of engineers and scientists.

‌Check‌ out‌ the‌ NI‌ Community

Who is National Instruments?

National Instruments provides a graphical system design platform for test, control, and embedded design applications that is transforming the way engineers and scientists design, prototype, and deploy systems.

‌Learn‌ more‌ about‌ NI