Skip to content

Commit

Permalink
Fix source voltage compensation on R6B board (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
at-wat authored Aug 16, 2023
1 parent 6d10be8 commit fda338e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions tfrog-motordriver/controlVelocity.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ typedef struct _DriverState
uint32_t velcontrol;
uint32_t ping_request;
uint32_t odom_drop;
int32_t vsrc_max;
} DriverState;

#ifdef static_assert
Expand Down
15 changes: 14 additions & 1 deletion tfrog-motordriver/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,19 @@ int main()
driver_state.ifmode = 0;
driver_state.watchdog = 0;
driver_state.odom_drop = 0;
driver_state.vsrc_max = 0x3ff;
switch (driver_state.board_version)
{
case BOARD_R6A:
case BOARD_R4:
break;
case BOARD_R6B:
#if defined(tfrog_rev5)
driver_state.vsrc_max = 0x3ff * VSRC_CONV_B;
#endif
break;
}

// Driver loop
while (1)
{
Expand Down Expand Up @@ -1014,7 +1027,7 @@ int main()
driver_state.vsrc = Filter1st_Filter(&voltf, (int32_t)(analog[7] & 0x0FFF));
ADC_Start();

if (driver_param.vsrc_rated >= 0x03FF)
if (driver_param.vsrc_rated >= driver_state.vsrc_max)
{
driver_state.vsrc_factor = 32768;
}
Expand Down

0 comments on commit fda338e

Please sign in to comment.