Skip to content

Commit

Permalink
calculate cadence
Browse files Browse the repository at this point in the history
  • Loading branch information
stancecoke committed Oct 1, 2024
1 parent 32e7168 commit 31c7a52
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
5 changes: 2 additions & 3 deletions Inc/config.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/*
* config.h
*
* config.h *
* Automatically created by Lishui Parameter Configurator
* Author: stancecoke
*/
Expand Down Expand Up @@ -63,7 +62,7 @@
#define SPDSHFT 0

//------------------------------ Ride mode setting

#define NUMBER_OF_PAS_MAGNETS 12
#define PAS_TIMEOUT 8000
#define RAMP_END 1600
//#define DIRDET
Expand Down
3 changes: 2 additions & 1 deletion Inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ typedef struct

q31_t Voltage;
uint32_t Speed;
uint32_t Cadence;
q31_t i_d;
q31_t i_q;
q31_t i_q_setpoint;
Expand All @@ -147,7 +148,7 @@ typedef struct
uint8_t char_dyn_adc_state;
uint8_t assist_level;
uint8_t regen_level;
int16_t Temperature;
int16_t Temperature;
int8_t system_state;
int8_t gear_state;
int8_t error_state;
Expand Down
3 changes: 2 additions & 1 deletion Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@ int main(void)
uint32_PAS_HIGH_counter=0;
uint32_PAS_counter =0;
ui8_PAS_flag=0;
MS.Cadence=8000*60/(NUMBER_OF_PAS_MAGNETS*uint32_PAS);
//read in and sum up torque-signal within one crank revolution (for sempu sensor 32 PAS pulses/revolution, 2^5=32)
uint32_torque_cumulated -= uint32_torque_cumulated>>5;
#ifdef NCTE
Expand Down Expand Up @@ -949,7 +950,7 @@ int main(void)
// (q31_t_Battery_Current_accumulated>>8)*i8_direction*i8_reverse_flag,
uint32_SPEEDx100_cumulated>>SPEEDFILTER,
MS.Battery_Current,
temp5);
MS.Cadence);
// sprintf_(buffer, "%d, %d, %d, %d, %d, %d, %d\r\n",(uint16_t)adcData[0],(uint16_t)adcData[1],(uint16_t)adcData[2],(uint16_t)adcData[3],(uint16_t)(adcData[4]),(uint16_t)(adcData[5]),(uint16_t)(adcData[6])) ;
// sprintf_(buffer, "%d, %d, %d, %d, %d, %d\r\n",tic_array[0],tic_array[1],tic_array[2],tic_array[3],tic_array[4],tic_array[5]) ;
i=0;
Expand Down

0 comments on commit 31c7a52

Please sign in to comment.