Skip to content

Commit

Permalink
Fix ganglion accel (brainflow-dev#150)
Browse files Browse the repository at this point in the history
* fix ganglion bled accel

* add wifi ganglion accel fixes

* final fix from andrey
  • Loading branch information
daniellasry authored Apr 26, 2020
1 parent e51320c commit 4d80b87
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
8 changes: 5 additions & 3 deletions src/board_controller/openbci/ganglion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,16 @@ void Ganglion::read_thread ()
int last_digit = data.data[0] % 10;
switch (last_digit)
{
// accel data is signed, so we must cast it to signed char
// due to a known bug in ganglion firmware, we must swap x and z, and invert z.
case 0:
accel_x = accel_scale * data.data[19];
accel_z = -accel_scale * (char)data.data[19];
break;
case 1:
accel_y = accel_scale * data.data[19];
accel_y = accel_scale * (char)data.data[19];
break;
case 2:
accel_z = accel_scale * data.data[19];
accel_x = accel_scale * (char)data.data[19];
break;
default:
break;
Expand Down
7 changes: 4 additions & 3 deletions src/board_controller/openbci/ganglion_wifi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ void GanglionWifi::read_thread ()
if (b[32 + offset] == END_BYTE_STANDARD)
{
// accel
package[5] = accel_scale * cast_16bit_to_int32 (b + 26 + offset);
package[6] = accel_scale * cast_16bit_to_int32 (b + 28 + offset);
package[7] = accel_scale * cast_16bit_to_int32 (b + 30 + offset);
// mistake in firmware in axis
package[5] = accel_scale * cast_16bit_to_int32 (b + 28 + offset);
package[6] = accel_scale * cast_16bit_to_int32 (b + 26 + offset);
package[7] = -accel_scale * cast_16bit_to_int32 (b + 30 + offset);
}
// place analog data
if (b[32 + offset] == END_BYTE_ANALOG)
Expand Down
2 changes: 1 addition & 1 deletion src/board_controller/openbci/inc/ganglion.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Ganglion : public Board

bool is_valid;

float const accel_scale = 0.032f;
float const accel_scale = 0.016f;
float const eeg_scale = (1.2f * 1000000) / (8388607.0f * 1.5f * 51.0f);

volatile bool keep_alive;
Expand Down
2 changes: 1 addition & 1 deletion src/board_controller/openbci/inc/ganglion_wifi.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class GanglionWifi : public OpenBCIWifiShieldBoard
{
float const accel_scale = 0.032f;
float const accel_scale = (0.02f / 16.0f) / 1.25f; // 1.25 experimental number
float const eeg_scale = (1.2f * 1000000) / (8388607.0f * 1.5f * 51.0f);

protected:
Expand Down

0 comments on commit 4d80b87

Please sign in to comment.