Back to Portfolio Home

Summary - I created a high-level C++ library to interface with a research-grade UART-based FES control system. The instruction for device communication explain the low-level UART control for very fine-grained functionality, but I wanted an interface that was human-readable and easily adjusted, so I made a high-level C++ library that has intitive functions like stim.set_amp(), stim.set_pw(), etc.

High-level C++ FES Library

I developed a library to run a research-grade Functional Electrical Stimulator System based on low-level UART control. This library facilitated my easy use of FES for coordinated use with the exoskeleton I am using to assist arm movements. One main feature of the library is a GUI that displays the current status of FES channels if being controlled externally, or allows for the direct control if desired. An example of the GUI is shown below.

Visualizer

A full set of examples for how to use the library is shown here, but see below for some examples of improvements.

The example code for how to control the simulator included a lot of code like the example below.

if(new_time - old_time > 100){
    chngevnt1[5] = open_loop[i];
    chngevnt1[(sizeof(chngevnt1) / sizeof(*chngevnt1)) - 1] = checksum(chngevnt1, (sizeof(chngevnt1) / sizeof(*chngevnt1)));
    write(fd0, chngevnt1, (sizeof(chngevnt1) / sizeof(*chngevnt1)));		
    old_time = new_time;
    i = i + 1;
}

My goal was to make a library that was much more human-readable and easily configurable. A similar control loop using my library looks like the following.

while (!stop) {
    // update the pulsewidth of each of the stimulation events
    stim.set_amp(bicep, 60);
    stim.write_pw(bicep, 10 + int(10 * sin(t)));

    // command the stimulation patterns to be sent to the stim board.
    // This is required whether using the gui or updating in code.
    test_clock.restart();
    stim.update();
    // wait for the loop to end
    t = timer.wait().as_seconds();
}