DSP library error: standard deviation always 0

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

DSP library error: standard deviation always 0

805件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by djukazg on Thu Jan 15 12:52:23 MST 2015
Hi,

I have a problem with arm_std_q31 function from DSP cortex M0 library. The function always returns 0 although the numbers in the array sent to the function are totaly different. For example:
w[0]int32_t488
w[1]int32_t327
w[2]int32_t172
w[3]int32_t68
w[4]int32_t44
w[5]int32_t39
w[6]int32_t34
w[7]int32_t249
w[8]int32_t132
w[9]int32_t7

The function arm_mean_q31 works OK (returns 156 in the upper case).

Version of LPCXpresso is 7.3.0, on Linux Fedora
MCU is LPC1114

Code:
static int tmr_hx711_ready = 0;
int32_t w[10];
int32_t mw, stdw;
char str[33];
    uint32_t i = 0;
while(1){
   if(tmr_hx711_ready > 0){//read
    w[i++] = hx711_get_weight();
    tmr_hx711_ready = 0;
if(i == 10){
 arm_mean_q31 (w, 10, &mw);
arm_std_q31(w, 10, &stdw);
i = 0;
sprintf(str,"Result: %d g", mw/10);
}
    }
}


I can't find any mistake here. Have I missed something or there's error in the library?

Regards,
Djuka


0 件の賞賛
返信
3 返答(返信)

740件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by djukazg on Fri Jan 16 23:16:31 MST 2015
You're right Starblue. I've shifted the values and it works now...

Thank you all.
0 件の賞賛
返信

740件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by starblue on Fri Jan 16 02:28:17 MST 2015
Your numbers are too small.  According to the documentation the lower 8 bits are discarded:

https://www.keil.com/pack/doc/CMSIS/DSP/html/group___s_t_d.html#ga39495e74f96116178be085c9dc7742f5
0 件の賞賛
返信

740件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cfb on Fri Jan 16 00:43:47 MST 2015
sprintf(str,"Result: %d g", mw/10); ???

You are not outputting the value of stdw.
0 件の賞賛
返信