float Get_MainAngle(float angle)
{
? ? float a;
? ? a = fmod_custom((float)angle,(float)(2*pi));
? ? return a >= 0? a:a+2*pi;
}
void Set_PhaseVolatge(float uq,float ud,float angle)
{
? ? angle = Get_MainAngle(angle+zero_electric_angle);
? ? //帕克逆變換
? ? ualpha=ud*cos(angle)-uq*sin(angle);
? ? ubeta=uq*cos(angle)+ud*sin(angle);
? ? //克拉克逆變換
? ? ua=ualpha+volatge_supply/2;
? ? ub=(sqrt(3)*ubeta-ualpha)/2+volatge_supply/2;
? ? uc=(-ualpha-sqrt(3)*ubeta)/2+volatge_supply/2;
? ? Set_PWM(ua, ub, uc);
}
報錯如下:
d:/application/mounriver/mounriver_studio/toolchain/risc-v embedded gcc/bin/../lib/gcc/riscv-none-embed/8.2.0/../../../../riscv-none-embed/bin/ld.exe: ./User/main.o: in function `Set_PhaseVolatge':
D:\Project\MRS_project\CH32V003\CH32V003F4U6_VISION1\obj/../User/main.c:141: undefined reference to `cos'
d:/application/mounriver/mounriver_studio/toolchain/risc-v embedded gcc/bin/../lib/gcc/riscv-none-embed/8.2.0/../../../../riscv-none-embed/bin/ld.exe: D:\Project\MRS_project\CH32V003\CH32V003F4U6_VISION1\obj/../User/main.c:141: undefined reference to `sin'
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:56: CH32V003F4U6_VISION1.elf] Error 1
這樣的錯誤在程序編寫過程中無錯誤提示,一經(jīng)編譯才發(fā)現(xiàn)有錯誤,根據(jù)報告來看是沒有引用函數(shù),可是已經(jīng)引用了math.h庫,而且多次修改發(fā)現(xiàn)再帕克逆變換之前直接對angle賦值不會出現(xiàn)這樣的問題。菜菜求救,可提供完整代碼。
程序中?fmod_custom函數(shù)是自己寫的浮點數(shù)取余,經(jīng)過驗證無問題。