I have tow question,Need to consult
1:switch (comm_step) {
case 1: curr_samp_volt = (1 << 0) || (1 << 2); break;
case 2: curr_samp_volt = (1 << 1) || (1 << 2); break;
case 3: curr_samp_volt = (1 << 1) || (1 << 2); break;
case 4: curr_samp_volt = (1 << 0) || (1 << 1); break;
case 5: curr_samp_volt = (1 << 0) || (1 << 1); break;
case 6: curr_samp_volt = (1 << 0) || (1 << 2); break;
The code above, "||" should be "|" right?
2:
filter_add_sample((float*)amp_fir_samples, amp,
AMP_FIR_TAPS_BITS, (uint32_t*)&_fir_index);
void filter_add_sample(float *buffer, float sample, int bits, uint32_t *offset) {
uint32_t cnt_mask = 0xFFFFFFFF >> (32 - bits);
buffer[*offset] = sample;
*offset += 1;
*offset &= cnt_mask;
}
In the above function, the variable amp_fir_index will keep increasing, which may exceed the maximum limit
of the array amp_fir_samples, because I did not find the variable amp_fir_index reset in the whole program,
am I correct?
1. Yes that looks like it should be | not ||.
2. It adds a sample to the buffer then moves the offset forward 1, then masks the number. So it will actually loop round.
uint32_t cnt_mask = 0xFFFFFFFF >> (32 - bits);
actually cnt_mask=0x1ffffff
*offset += 1;
*offset &= cnt_mask;
if offset =0x200 0000 then 0ffset&0x1ff ffff=0
but buffer amp_fir_samples max offset value is 128 ( static volatile float amp_fir_samples[AMP_FIR_LEN];),
so when offset >127,It adds a sample to buffer,should be not right?
Do you understand?
I think cnt_mask=0xFF>>1,thus offset loop round
Am I right?
I think you have misread the function.
In your example it is called with the 'bits' variable set to 7. So you will get:
uint32_t cnt_mask = 0xFFFFFFFF >> (32 - 7);
which makes cnt_mask = 127
I'm sorry, I misread it,
Thank you a lots
No problem, happy to help!
Hello!
Do you have the details document for the VESC software? , because to be honest, no document, the software looks very hard, a lot of places all look not to understand, that only a small part of the document is good too, I want to promote for this project there is a big help, because in China, 90% of people now just research how to use the software, but they don't understand the software architecture and principle, has been a shot in the dark, so many motors do not mached good, promotion is very slow, hope to get your help