See the code in the main.c of my fork and my posts with the graphs some pages before.casainho wrote: ↑Apr 12, 2018 7:58 amThis mod doesn't work because the output signal from the sensor is always the same: ui16_pas_on_time_counter > ui16_pas_off_time_counter for both directions, so, there is not way to detect rotation direction. This is probably why they have added hardware/cost.
Any ideas??
Code: Select all
#if defined(TORQUESENSOR) || defined(TORQUE_SIMULATION)
// Update cadence, torque and battery current after PAS interrupt occurrence
if (ui8_PAS_Flag == 1)
{
ui16_PAS=ui16_PAS_Counter; //save recent cadence
ui16_PAS_High=ui16_PAS_High_Counter;
#if (PAS_DIRECTION)
if((float)ui16_PAS/(float)ui16_PAS_High>PAS_THRESHOLD){
if (PAS_act<7) {PAS_act++;}
}
else{
if (PAS_act>0) {PAS_act--;}
}
#endif
#if (!PAS_DIRECTION)
if((float)ui16_PAS/(float)ui16_PAS_High<PAS_THRESHOLD){
if (PAS_act<7) {PAS_act++;}
}
else{
if (PAS_act>0) {PAS_act--;}
}
#endif
if (PAS_act>3){PAS_dir=1;} //set direction only if enough pulses in the right direction are detected.
else{PAS_dir=0;}
ui16_PAS_Counter=1;
ui16_PAS_High_Counter=1;//reset PAS Counter
ui8_PAS_Flag =0; //reset interrupt flag
....
I've updated the description of the Java tool at bitbucket now.
regards
stancecoke