Project Overview

TL;DR

  • 4 channel sip/puff assistive HID device
  • Strain based joystick
  • Mountable via 1/4" nut
  • OSHW - all files available (Code, 3D Models, PCBs)
  • Software intended to support similar projects
  • 2 Versions with commercial and self-made pressure sensors
  • Less than 20 USD in parts

Introduction

I recently published an updated version of the Mouth Operated Mouse from 2015. To be honest, this was a byproduct of the AHID Mouse, which could be seen as the pro version, offering more advanced functionality and expandability while still keeping the cost of the required parts down.

I liked the idea of a strain-based joystick, which kind of defines the design. It allows the device to be quite compact while requiring minimal movement. Basically, everything is static. This also allows the pressure sensors for sip-and-puff detection to be placed very close to the stick.

Speaking of pressure sensors: I wanted to include my 3D-printed pressure sensor in the project, but I also wanted to have a commercial alternative. Therefore, there are two versions: one with the DIY sensors and one with the CFSensor XGZP160010S. Theoretically, any pressure sensor in the range of ±10 kPa should do the job, but the CFSensor one costs around $1.50 compared to other sensors that can cost 10× as much. This makes a huge difference when you have four of them on the board.

Another aspect is the software side of things. The AHID Mouse should be seen as an assembly of ideas that can be transformed into something completely different while using the same software with a different configuration. The software is able to process signals from joysticks, sensors, buttons, load cells, and other devices such as a Wii Nunchuk, etc., and map them to output actions such as pressing a mouse button or moving an analog stick on a gamepad.

I hope this creates a basis for an ecosystem that allows existing hardware to be quickly adapted into custom devices made for a person’s individual needs. But I think there is still a long way to go to get there.

So, if someone wants to help with this, please contact me. Especially feedback and ideas from people who are using such devices are very welcome. You don’t have to be a technical person to contribute.

Project Overview

Disclaimer

I hope this design is helpful or sparks some creative ideas! It’s not a ready-to-go product, though, so it does take a bit of skill to make and may not work perfectly on the first try. Have fun experimenting, and feel free to adapt it for your own projects. If you have any problems, I’m happy to help as long as I have the time, but if I’m busy, you’re on your own.

Software

The device uses the AHID firmware. It is based on the same code already used for the Mouth Operated Mouse II, but I have extended it since then. It now supports simulating not only mouse actions, but also gamepad and keyboard actions.

The mapping system has been reworked to support different mapping lists, which are combined into a profile. This allows multiple profiles to be defined and used for different tasks, such as a basic and an advanced mouse profile or different profiles for different games.

The firmware is still intended to be expandable and to serve as a basis or starting point for similar projects. Especially when using similar hardware in other configurations, a project can be set up in very little time.

There is now an M2M interface in addition to the command-line interface. It is a binary interface for machine-to-machine communication. This allows external software to configure the device and will make it easier for non-technical users to create, edit, or modify mappings and profiles. It can also be used for calibration. I think this interface has the potential to replace the command-line interface sooner or later.

Mappings are now based on a usage ID. In order to allow profiles to be shared even between different devices, mappings use a “usage ID”. This ID allows an input, such as a joystick, to be matched to a mapping based on its basic functionality.

For example, the strain-gauge-based joystick of the AHID mouse and the resistive joystick of the Mouth Operated Mouse both serve the same purpose. By using the same usage ID, it is possible to use the same mapping on both devices, even if the terminology or internal IDs do not match.

I also added a way to introduce a time-dependent component to a mapping by adding a configurable delay to the setting and clearing of condition flags. This makes it possible, for example, to implement a long button press using the mapping concept.

There is now an I²C transfer sequencer, which will allow communication with external peripherals or devices in the future, such as port expanders or a Wii Nunchuk.

Management tool

There is a vibe-coded tool that can support creating profiles and running the calibration. I’ll leave this outside the project for now, as I’m not sure about the licensing and legal issues it might bring.

As I’m not a JS guy, this is the best I can offer until someone does a better job of implementing it. It uses a web-based approach but runs completely locally in the browser.

This should be seen more as a placeholder for a configuration tool until someone comes up with a better idea or implementation:

AHID Manager

Project Overview

Mappings

Mappings are a central concept of the AHID Firmware. In order to understand the concept, it is necessary to first introduce the vocabulary used:

Signal: A signal is anything we can use as an external or internal input. It can be digital (on/off) or analog (x to y). Normally, it is externally manipulated by the user. It can be a button press or the movement of a joystick. A signal is a single value that is scaled to express the state of an input with a value between -100 and 100.

An example of a digital signal could be a button. If it is not pressed, the signal is 0. If it is pressed, the signal is 100. An example of an analog signal could be the X-axis of a joystick. In the idle position, the signal is 0. If the joystick is fully moved to the left, the signal is -100; if it is fully moved to the right, the signal is 100. If it is moved halfway to the right, the signal is 50, and so on.

By scaling signals to this defined range, we have a uniform range to work with for any input.

Action: An action is something a signal can be connected to. An action can be either something external, such as pressing a button on a gamepad, or something internal, such as changing a condition flag.

The supported actions on the AHID mouse, for example, include the emulation of typical HID devices such as a mouse, keyboard, or gamepad. Another important action is changing the state of a condition flag. However, an action could also be something like switching on an LED or moving an actuator.

Mapping: The main intent of a mapping is to connect a signal to an action. For example, the movement on the X-axis of a joystick can be connected to the Move Mouse Left or Move Mouse Right action.

A mapping further allows a signal to be conditioned. When a signal is used by a mapping, it is only processed further if it is positive. The mapping therefore allows the signal to be inverted. It also allows a window to be defined that specifies the range in which the signal is valid. Everything outside this window is treated as zero. Additionally, a positive or negative offset can be added, for example, to compensate for a window starting at a higher value.

Actions nearly always have a specific set of options. For example, an action such as Press Mouse Button needs to be further specified by the mouse button that should be pressed (left, middle, or right). This information is called the action option and is also part of the mapping.

Another important part of the mapping is the condition which is declared in the next section.

Condition: Mappings are not always enabled. In some circumstances, it is useful to disable a mapping based on the current system state. A condition allows a mapping to be disabled. To achieve this, the firmware uses up to 32 condition flags.

Depending on whether a condition is met, the mapping is either disabled or behaves as if its input were set to zero. Condition bits can be set by using the corresponding action.

To make this a bit less abstract, let us say we want an extended mouse profile. Besides moving the cursor, we want to use the joystick for scrolling. We use a dedicated sip/puff channel to switch between cursor and scroll mode.

We introduce a mapping that sets condition flag 1 when a sip is detected and clears it when a puff is detected. We then add mappings for cursor movement that are set to zero when condition flag 1 is not set, and add mappings for scrolling that are set to zero when condition flag 1 is set.

This way, we can use conditions to implement additional functionality. The actions used to set the condition flags can also add a time component by introducing a delay before setting the condition flag.

Profile: A profile bundles multiple mappings into a single unit that can be loaded or saved. It allows users to quickly switch between different sets of functions for different use cases. For example, one profile could be configure the deviuce for use as a mouse, while another could configure the device for use as a gamepad.

Mapping Examples

Let’s say we want to use the AHID Mouse as a standard mouse device that moves a cursor and allows us to press the left and right mouse buttons. A mapping could look something like this:

Signal Action Window Min Window Max Offset Invert Condition Condition Behaviour Action Option
Strainstick X Mouse Move 5 100 -5 No — None Move Left
Strainstick X Mouse Move 5 100 -5 Yes — None Move Right
Strainstick Y Mouse Move 5 100 -5 No — None Move Up
Strainstick Y Mouse Move 5 100 -5 Yes — None Move Down
Middle Sip/Puff Sensor Mouse Button Press 10 100 0 Yes — None Press Button Left
Middle Sip/Puff Sensor Mouse Button Press 10 100 0 No — None Press Button Right

Let’s get into the details. We are using the signals for the X and Y axes of the strainstick twice. By enabling inversion, we use the negative part of the signal for movement to the right and the positive part for movement to the left, and similarly for up and down.

The valid window is chosen to start at 5%. Analog signals are normally never perfect, there will always be some noise and drift. By setting the window, we compensate for this. Everything below 5 is treated as zero.

In order to prevent the movement from going directly from 0 to 5, we add an offset of -5. There are no condition flags used for this simple mapping. The action options should be self-explanatory.

Now that we have a basic mapping, we might want to add some more functionality by adding the possibility to switch between a cursor and a scroll mode:

Signal Action Window Min Window Max Offset Invert Condition Condition Behaviour Action Option
Strainstick X Mouse Move 5 100 -5 No Flag 1 set Set Zero if met Move Left
Strainstick Y Mouse Move 5 100 -5 No Flag 1 set Set Zero if met Move Up
Strainstick Y Mouse Move 5 100 -5 No Flag 1 set Set Zero if met Move Down
Strainstick X Mouse Move 5 100 -5 No Flag 1 set Set Zero if met Move Right
Strainstick Y Mouse Scroll 5 100 -5 No Flag 1 cleared Set Zero if met Scroll Down
Strainstick X Mouse Scroll 5 100 -5 No Flag 1 cleared Set Zero if met Scroll Left
Strainstick X Mouse Scroll 5 100 -5 No Flag 1 cleared Set Zero if met Scroll Right
Strainstick Y Mouse Scroll 5 100 -5 No Flag 1 cleared Set Zero if met Scroll Up
Middle Sip/Puff Sensor Mouse Button Press 10 100 0 Yes — — Press Button Left
Middle Sip/Puff Sensor Mouse Button Press 10 100 0 No — — Press Button Right
Aux Pressure Sensor Toggle Condition Flag 10 100 0 Yes — — Flag 1, no delay

Not much has changed about the mouse movement mappings. The only difference is that there is now a condition entry.

For all Mouse Move entries, the mapping’s input signal is set to zero if Condition Flag 1 is set. In addition to the Mouse Move mappings, there are now Mouse Scroll mappings that use a similar condition setting, but in the opposite way. If Condition Flag 1 is cleared, the input of the Mouse Scroll mappings is set to zero.

To summarize: if Condition Flag 1 is set, we use the scroll mappings. If it is cleared, we use the movement mappings.

There is also another mapping that allows us to set Condition Flag 1. It uses the Toggle Condition Flag action. This means that the same input, in this case a sip, toggles the condition flag and allows us to switch between the movement mappings (cursor mode) and the scroll mappings (scroll mode).

Let’s say we want to get even more functionality out of our setup. We don’t want to dedicate an entire sip/puff channel to switching between cursor and scroll mode, so we want to use the middle sip/puff channel to do the switching as well:

Signal Action Window Min Window Max Offset Invert Condition Condition Behaviour Action Option
Strainstick X Mouse Move 5 100 -5 No Flag 1 cleared Set Zero if met Move Left
Strainstick X Mouse Move 5 100 -5 No Flag 1 cleared Set Zero if met Move Right
Strainstick Y Mouse Move 5 100 -5 No Flag 1 cleared Set Zero if met Move Up
Strainstick Y Mouse Move 5 100 -5 No Flag 1 cleared Set Zero if met Move Down
Strainstick X Mouse Scroll 5 100 -5 No Flag 1 set Set Zero if met Scroll Left
Strainstick X Mouse Scroll 5 100 -5 No Flag 1 set Set Zero if met Scroll Right
Strainstick Y Mouse Scroll 5 100 -5 No Flag 1 set Set Zero if met Scroll Up
Strainstick Y Mouse Scroll 5 100 -5 No Flag 1 set Set Zero if met Scroll Down
Middle Sip/Puff Sensor Mouse Button Press 10 100 0 Yes — — Press Button Left
Middle Sip/Puff Sensor Mouse Button Press 71 100 0 No — — Press Button Right
Middle Sip/Puff Sensor Toggle Condition Flag 10 70 0 No — — Flag 1, Delay 1s

What has changed is the window of the mapping that triggers the right button press. It now only reacts to a signal level between 71 and 100. This means that a right click is only executed when using a puff with higher pressure.

We also changed the signal window of the Toggle Condition Flag mapping so that it reacts to a lower pressure, from 10 to 70. You might think that this would cause the mode to switch with every right click as well, but there is another important detail: we added a delay to the execution of the toggle.

This means that the toggle is only executed if the signal remains between 10 and 70 for at least one second. Since a right click is normally not held for longer than a couple of milliseconds (for typical desktop use, not CAD 😉), we can sneak additional functionality into the same input channel or signal.

In this way, the middle sip/puff sensor can be used for both right-clicking and switching between cursor and scroll modes, depending on the pressure and duration of the input.

Assembly

The AHID design focuses on cost-effectiveness while providing a maximum of functionality. The PCBs use components that should be possible to source in most locations. The design does not use any parts that require specialized soldering equipment. The goal was to provide a device that can be assembled by a person with intermediate skills, for example in a makerspace, using a basic soldering iron and simple magnification, along with widely available consumables such as super glue and access to a 3D printer capable of printing PLA.

I won’t describe how to assemble the PCBs. You will find the required information, such as KiCad sources, bills of materials (including the interactive BOM), schematics, Gerber files, etc., in the release section of the corresponding hardware repositories. For the strain stick PCB, there is a whole article about the assembly. The other PCBs are very simple boards that do not require specialized assembly methods.

Besides the PCBs, you will need some 3D-printed parts as well as some hardware, silicone hoses, etc. A list is provided for each version.

AHID Mouse CFSensor Version

AHID Mouse CFSensor Version

Required parts:

  • PCBs

  • 3D-printed parts

    • cf_front
    • cf_sensor_spacer
    • cf_pcb_spacer_6
    • rod
    • rod_base
    • cf_pcb_spacer_8_4
    • nut_cap
    • cf_back or cf_back_debug if you want to connect a debug adapter
    • cf_mouthpiece
  • Silicone hoses (ID: 2mm, OD: 4mm)

    • 2 × 42mm
    • 1 × 60mm
    • 1 × 70mm
  • Hardware

    • 4 × M3 × 30mm (e.g. DIN 7985)
    • 2 × M3 × 12mm (e.g. DIN 7985)
    • 6 × M3 nut (e.g. DIN 934)
    • 1 × 1/4"-20 nut
  • Cables

    • 100mm 8p JST SH reverse (first pin to first pin)

AHID Mouse CFSensor Version

  1. First, push two M3 nuts into the slots of the rod.
  2. Install the rod_base onto the AHID_STRAIN_STICK PCB on the side with the strain gauges and screw the rod tight using an M3 × 12 mm screw. Make sure the nut slots are pointing down. See the 3D renders for reference.
  3. Add the four M3 × 30 mm screws to the front of the case and put the sensor spacer onto the front.
  4. Install the AHID_CF_SENSOR_QUAD board and the cf_pcb_spacer_6. Make sure the board has the correct orientation (connector pointing down).
  5. Install the AHID_STRAIN_STICK PCB. The connector should be on the right when looking from the rear (see the 3D renders).
  6. Add the cf_pcb_spacer_8_4 and the AHID_MAIN_CON PCB to the stack, and make sure the board connects correctly to the AHID_STRAIN_STICK PCB.
  7. Push the 1/4"-20 nut into the cf_back and secure it with the nut_cap.
  8. Insert four M3 nuts into the slots on the cf_back.
  9. Add the back to the rest of the stack and screw it tight.
  10. Assemble the cf_mouthpiece. Add the silicone hoses to the mouthpiece as shown in the picture.
  11. Screw the mouthpiece to the case and attach the hoses to the sensors.

AHID Mouse CFSensor Version

AHID Mouse CFSensor Version

AHID Mouse DIY Sensor Version

AHID Mouse CFSensor Version

Required parts:

  • PCBs
  • 3x DIY Sensor
  • 3D printed parts
    • diy_front
    • diy_sensor_spacer
    • diy_pcb_spacer
    • rod
    • rod_base
    • nut_cap
    • diy_back or diy_back_debug if you want to connect a debug adapter
    • diy_mouthpiece
  • Silicon hoses (ID: 2mm OD:4mm)
    • 2x 42mm
    • 1x 60mm
  • Hardware
    • 4x M3x30mm (e.g. DIN7985)
    • 2x M3x12 (e.g. DIN7985)
    • 6x M3 nut (e.g. DIN934)
    • 1x 1/4"-20 nut
    • 6× M2.5×5 countersunk screws (or self-tapping screws)
  • Cables
    • Some silicone wire (30AWG) to connect the sensors
  1. First, install the DIY pressure sensors to the diy_front by securing them in place with the countersunk M2.5 screws. Use the provided slots for cable management.
  2. Add the 4x M3x30mm screws and slide on the diy_sensor_spacer. Make sure the cables are going throug the latches on the side.
  3. Push two M3 nuts into the slots of the rod.
  4. Install the rod_base onto the AHID_STRAIN_STICK PCB on the side with the strain gauges and screw the rod tight using an M3 × 12 mm screw. Make sure the nut slots are pointing down. See the 3D renders for reference.
  5. Install the AHID_STRAIN_STICK PCB. The connector should be on the right when looking from the rear (see the 3D renders).
  6. Add the diy_pcb_spacer and the AHID_MAIN PCB to the stack, and make sure the board connects correctly to the AHID_STRAIN_STICK PCB.
  7. Push the 1/4"-20 nut into the diy_back and secure it with the nut_cap.
  8. Insert four M3 nuts into the slots on the diy_back.
  9. Add the back to the rest of the stack and screw it tight.
  10. Assemble the diy_mouthpiece. Add the silicone hoses to the mouthpiece as shown in the picture.
  11. Screw the mouthpiece to the case and attach the hoses to the sensors.

AHID Mouse CFSensor Version

Flashing the Firmware

There are two ways to get the firmware onto the microcontroller. You can use the debug port and a wlink compatible debuger/programmer. For most people it will be easier to just use the integrated USB bootloader. When pressing the pushbutton on the board while powering up the device, it will enter the bootloader. You can then use e.g. a tool like wchisp to upload the firmware. I also provide a web-based version for flashing the firmware:

Firmware Flash Tool

Calibration

Before using the device, perform an initial calibration of the joystick and the pressure sensor. Calibration is done through a serial terminal. You can use a terminal program such as PuTTY or Minicom. If you prefer not to install any software, you can use my web-based terminal instead:

Serial Terminal

The cal command provides several subcommands for calibration. First, list all available inputs that can be calibrated:

cal list

> cal list
0: Joystick x-Axis
1: Joystick y-Axis
2: Pressure Sensor
>

To calibrate an input, use the cal start command followed by the input number. The calibration process will guide you through the required steps. If you are not satisfied with the result, simply do not confirm the calibration. The previous calibration will be restored automatically.

cal start

> cal start 0
Please don't operate Joystick x-Axis and leave it in the idle position!
Measuring baseline
Operate Left and leave idle afterwards.
Operate Right and leave idle afterwards.
Please test calibration:        0
Operate both functions (Left and Right) to keep the calibration.
Restoring previous calibration.
Done.
>

Repeat this process for all inputs. Once all channels have been calibrated, the device is ready for use.

Finally, store the calibration in persistent memory. If you skip this step, the calibration will be lost after the device is power-cycled.

cal write

> cal write
Calibration stored successfully!
>

Repositories and Release Files

3D printed parts:

Hardware:

Software