Skip to content

Conversation

at-wat
Copy link
Member

@at-wat at-wat commented Sep 4, 2019

fix #71
fix #38

@at-wat at-wat self-assigned this Sep 4, 2019
@at-wat
Copy link
Member Author

at-wat commented Sep 5, 2019

  • calculate rely-hall velocity threshold from params

  • interrupt interval (100us at default) and hall signal delay should be less than 0.5%(= 1.8deg) of hall sinal interval (e.g. 3000rpm = 50Hz -> 20ms)
    • hall sinal interval [cycle]: enc_rev [cnt] / vel [cnt/cycle]
    • interrupt interval [cycle]: control_cycle [ms] / ((48000 [kHz] / 2) / PWM_resolution)
interrupt interval [cycle] < hall sinal edge interval [cycle]
control_cycle [ms] / ((48000 [kHz] / 2) / PWM_resolution) < 0.005 * enc_rev [cnt] / vel [cnt/cycle]
vel < 0.005 * enc_rev [cnt] * ((48000 [kHz] / 2) / PWM_resolution) / control_cycle [ms]
vel < 0.005 * enc_rev [cnt] * 48000 [kHz] / (2 * PWM_resolution * control_cycle [ms])

@at-wat
Copy link
Member Author

at-wat commented Sep 6, 2019

@seiga-k could you take a look this and also #73, #75, #76?

@seiga-k
Copy link
Collaborator

seiga-k commented Sep 10, 2019

About #73

tfrog-motordriver/controlPWM.c

I feel const int tan is not good naming. How about const int tan_th or something?

Other

LGTM

@seiga-k
Copy link
Collaborator

seiga-k commented Sep 10, 2019

About #75

LGTM

@seiga-k
Copy link
Collaborator

seiga-k commented Sep 10, 2019

About #76

tfrog-motordriver/controlPWM.c

Is arm-gcc compiler promise a behavior of compile a modulo to less calculation method?

hall_pos = hall_pos % ENC0_BUF_MAX;

You limit ENC0_BUF_MAX as 2^n as bellow in tfrog-motordriver/controlVelocity.h.

// ENC0_BUF_MAX must be 2^n to reduce computation cost.
#define ENC0_BUF_MAX 64

So, how about like this?

const int enc0_buf_mask = ENC0_BUF_MAX - 1;
hall_pos &= enc0_buf_mask;

@at-wat
Copy link
Member Author

at-wat commented Sep 11, 2019

Is arm-gcc compiler promise a behavior of compile a modulo to less calculation method?

I don't think bit mask is required as gcc don't use real modulo operation for immediate value divider, even if it is compiled with -O0.
I have added static assert to ensure it is power of two.

@at-wat at-wat merged commit 4862d17 into master Sep 11, 2019
@at-wat at-wat deleted the add-hall-signal-delay-compensation branch September 11, 2019 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hall signal delay compensation Improve hall signal filtering
2 participants