Skip to content

Commit

Permalink
repair KM5 protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
stancecoke committed Jun 30, 2024
1 parent 8a23bf1 commit f39e509
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Inc/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@

//---------------------------------------------------------------------
//Display settings
#define DISPLAY_TYPE DISPLAY_TYPE_BAFANG
#define DISPLAY_TYPE DISPLAY_TYPE_KINGMETER_901U

//---------------------------------------------------------------------
//Regen settings
Expand Down
6 changes: 3 additions & 3 deletions Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2046,16 +2046,16 @@ void kingmeter_update(void)


#if (SPEEDSOURCE == EXTERNAL)
KM.Tx.Speed = ((MS.Speed>>3)*PULSES_PER_REVOLUTION); //>>3 because of 8 kHz counter frequency, so 8 tics per ms
KM.Tx.Wheeltime_ms = ((MS.Speed>>3)*PULSES_PER_REVOLUTION); //>>3 because of 8 kHz counter frequency, so 8 tics per ms
#else
if(__HAL_TIM_GET_COUNTER(&htim2) < 12000)
{
KM.Tx.Speed = (MS.Speed*GEAR_RATIO*6)>>9; //>>9 because of 500kHZ timer2 frequency, 512 tics per ms should be OK *6 because of 6 hall interrupts per electric revolution.
KM.Tx.Wheeltime_ms = (MS.Speed*GEAR_RATIO*6)>>9; //>>9 because of 500kHZ timer2 frequency, 512 tics per ms should be OK *6 because of 6 hall interrupts per electric revolution.

}
else
{
KM.Tx.Speed = 64000;
KM.Tx.Wheeltime_ms = 64000;
}

#endif
Expand Down

0 comments on commit f39e509

Please sign in to comment.