Skip to content

Add NeuroPawn Knight IMU Board Support and Gain Configuration#795

Merged
Andrey1994 merged 4 commits intobrainflow-dev:masterfrom
NeuroPawn:master
Feb 23, 2026
Merged

Add NeuroPawn Knight IMU Board Support and Gain Configuration#795
Andrey1994 merged 4 commits intobrainflow-dev:masterfrom
NeuroPawn:master

Conversation

@neuropawn-admin
Copy link
Contributor

This PR introduces support for the NeuroPawn Knight IMU board and adds gain configuration capabilities for Knight boards.

Key Changes:

  1. New Board Support:
  • Added KnightIMU class (src/board_controller/neuropawn/knightimu.h and .cpp) to handle data acquisition and parsing for the Knight IMU board (Board ID: 66, NEUROPAWN_KNIGHT_BOARD_IMU)
  • Updated BrainFlowBoards definitions in src/board_controller/brainflow_boards.cpp to include the new board constants and default settings
  • Updated BoardController factory in src/board_controller/board_controller.cpp to initialize the KnightIMU board
  1. Gain Configuration
  • Updated Knight and KnightIMU classes to parse gain settings from the params.other_info JSON string (e.g., '{"gain": 6}')
  • Supported gain values: 1, 2, 3, 4, 6, 8, 12 (default is 12)
  • Fixed a scaling bug related to ADC handling in knight.cpp
  1. Documentation
  • Updated docs/SupportedBoards.rst to document usage of the Knight IMU board.
  • Refined initialization examples to demonstrate how to configure gain and select between Knight and Knight IMU boards using BoardIds

Co-authored-by: Kevin <kevinx1698@gmail.com>
Co-authored-by: Kevin-Xue01 <59587075+Kevin-Xue01@users.noreply.github.com>
Co-authored-by: aa217 <125326241+aa217@users.noreply.github.com>
Co-authored-by: abdallah <abdallah.alwan2001@gmail.com>
Copy link
Member

@Andrey1994 Andrey1994 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looks good, in addition to comments attached to code I think it would be better to have a common base class for both Knigh boards and implement different parsing logic since everything else looks the same. Good example how to do it - OpenBCISerial board and Cyton/CytonDaisy implementations

@neuropawn-admin
Copy link
Contributor Author

overall looks good, in addition to comments attached to code I think it would be better to have a common base class for both Knigh boards and implement different parsing logic since everything else looks the same. Good example how to do it - OpenBCISerial board and Cyton/CytonDaisy implementations

I've added a base class like you mentioned above.

Images will be attached to this PR for both boards to be used in the SupportedBoards.rst

@Andrey1994
Copy link
Member

looks good to me, update in BoardIds for other languages is missed(java, c#, julia, etc), other than that all fine

@Andrey1994
Copy link
Member

just noticed that you have gain used only for converting raw values into uV, you dont change settings of the device itself afaict. It doesnt really matter from the brainflow integration point of view, but logically changing gain doesnt change the uV values from the body, it changes the precision of the amplifier. And BrainFlow is meant to return uV value from the body.

So, gain set in brainflow in these equations should match gain set in the amplifier, and to achieve it you need to use config_board method.

@neuropawn-admin
Copy link
Contributor Author

just noticed that you have gain used only for converting raw values into uV, you dont change settings of the device itself afaict. It doesnt really matter from the brainflow integration point of view, but logically changing gain doesnt change the uV values from the body, it changes the precision of the amplifier. And BrainFlow is meant to return uV value from the body.

So, gain set in brainflow in these equations should match gain set in the amplifier, and to achieve it you need to use config_board method.

@Andrey1994 thanks for catching this. I will make the fix!

@neuropawn-admin
Copy link
Contributor Author

just noticed that you have gain used only for converting raw values into uV, you dont change settings of the device itself afaict. It doesnt really matter from the brainflow integration point of view, but logically changing gain doesnt change the uV values from the body, it changes the precision of the amplifier. And BrainFlow is meant to return uV value from the body.
So, gain set in brainflow in these equations should match gain set in the amplifier, and to achieve it you need to use config_board method.

@Andrey1994 thanks for catching this. I will make the fix!

Now, the gain configuration logic via BrainFlowInputParams has been removed. Gain is now purely configured via the config_board() function.

@Andrey1994
Copy link
Member

I think I was not clear with the point here. Its ok to have configurable gain per channel, its also ok to have it as a part of prepare session method or/and as a part of config board.

But gain configuration requires an update in two places - first a command should be sent to the ADS to change gain for a single channel or for all. Second - once its sent you need to update eqiations for this channel(or for all) to use new gain instead, then equations will match the ADS settings and correct value will be returned.

I did smth similar for openbci here https://github.com/brainflow-dev/brainflow/blob/master/src%2Fboard_controller%2Fopenbci%2Fcyton_daisy.cpp#L16 I dont think its required to be in its own class like I did there, but it shows the idea

@Andrey1994
Copy link
Member

But as is its fine for now, can merge it and you can add gain settings in another PR if you want to

@Andrey1994 Andrey1994 merged commit b159fe3 into brainflow-dev:master Feb 23, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants