主题:controlSUITE中讨论的其他部件
大家好,
我目前正在处理电机控制应用程序。 我想用模糊神经网络控制器替换PI控制器。 在每个中断中,我需要执行3个矩阵乘法并使用tanhf()来计算结果。
在代码中,我将元素乘以元素,并使用math.lib中的tanhf()。 但中断无法在0.1 ms内完成。 我是否有任何方法可以优化代码或需要更改为更好的微芯片?
谢谢
杨孙
// match_multiply(*W1,inputlayer, hiddenlayer1,6,5);
P=&W1[0][0];
Q=&inputlayer[0];
hiddenlayer1[0]=*p** q +*(p+1)**(q+1)+*(p+2)**(p+2)**(q+3)+*(p+3)+*(p+4)**(q+4);
hiddenlayer1[1]=*(p+5)** q +*(p+6)**(q+1)+*(p+7)**(q+2)+*(p+8)**(q+3)+*(p+9)**(q+4);
hiddenlayer1[2]=*(p+10)** q +*(p+11)**(q+1)+*(p+12)**(q+2)+*(p+13)**(q+3)+*(p+14)**(q+4);
hiddenlayer1[3]=*(p+15)** q +*(p+16)**(q+1)+*(p+17)**(q+2)+*(p+18)**(q+3)+*(p+19)**(q+4);
hiddenlayer1[4]=*(p+20)** q +*(p+21)**(q+1)+*(p+22)**(q+2)+*(p+23)**(q+3)+*(p+24)**(q+4);
hiddenlayer1[5]=*(p+25)** q +*(p+26)**(q+1)+*(p+27)**(q+2)+*(p+28)**(q+3)+*(p+29)**(q+4);
hiddenlayer1[0]=(float)tanhf(hiddenlayer1[0]);
hiddenlayer1[1]=(float)tanhf(hiddenlayer1[1]);
hiddenlayer1[2]=(float)tanhf(hiddenlayer1[2]);
hiddenlayer1[3]=(float)tanhf(hiddenlayer1[3]);
hiddenlayer1[4]=(float)tanhf(hiddenlayer1[4]);
hiddenlayer1[5]=(float)tanhf(hiddenlayer1[5]);
//第二个隐藏图层
//match_multiply(*W2, hiddenlayer1, hiddenlayer2,6,7);
P=&W2[0][0];
q=&hiddenlayer1[0];
hiddenlayer2[0]=*p** q +*(p+1)**(q+1)+*(p+2)**(p+3)**(q+3)+*(p+4)**(q+4)+*(p+5)**(q+5)+*(p+6)**
hiddenlayer2[1]=*(p+7)** q +*(p+8)**(q+1)+*(p+9)**(q+2)+*(p+10)**(q+3)+*(p+11)**(q+4)+*(p+12)**(q+5)+*(p+13);
hiddenlayer2[2]=*(p+14)** q +*(p+15)**(q+1)+*(p+16)**(q+2)+*(p+17)**(q+3)+*(p+18)**(q+4)+*(p+19)**(q+5)+*(p+20);
hiddenlayer2[3]=*(p+21)** q +*(p+22)**(q+1)+*(p+23)**(q+2)+*(p+24)**(q+3)+*(p+25)**(q+4)+*(p+26)**(q+5)+*(p+27);
hiddenlayer2[4]=*(p+28)** q +*(p+29)**(q+1)+*(p+30)**(q+2)+*(p+31)**(q+3)+*(p+32)**(q+4)+*(p+33)**(q+5)+*(p+34);
hiddenlayer2[5]=*(p+35)** q +*(p+36)**(q+1)+*(p+37)**(q+2)+*(p+38)**(q+3)+*(p+39)**(q+4)+*(p+40)**(q+5)+*(p+41);
hiddenlayer2[0]=(float)tanhf(hiddenlayer2[0]);
hiddenlayer2[1]=(float)tanhf(hiddenlayer2[1]);
hiddenlayer2[2]=(float)tanhf(hiddenlayer2[2]);
hiddenlayer2[3]=(float)tanhf(hiddenlayer2[3]);
hiddenlayer2[4]=(float)tanhf(hiddenlayer2[4]);
hiddenlayer2[5]=(float)tanhf(hiddenlayer2[5]);
//第三个隐藏图层
P=&W3[0][0];
q=&hiddenlayer2[0];
outputlayer [0]=* p** q +*(p+1)**(q+1)+*(p+2)**(q+2)+*(p+3)**(q+3)+*(p+4)**(q+4)+*(p+5)**(q+5)+*(p+6)**(q+6);
outputlayer [1]=*(p+7)** q +*(p+8)**(q+1)+*(p+9)**(q+2)+*(p+10)**(q+3)+*(p+11)**(q+4)+*(p+12)**(q+5)+*(p+13)**(p+13);
25.7196.4229万9223366</xmt-block>922.3366万 ;
25.7196.4229万9223366</xmt-block>922.3366万 ;