這一段時間為一個算法搞了很久,用pic單片機采樣交流有效值,采用的算法為將
1,各個點的采樣值乘方,
2,累加平方和
3,除以采樣次數
4,開方,得到有效值
其中開方運算需要的運算時間為最長,目前試驗了幾種算法但都不能使開方運算的時間小于50us,這樣對spwm波形控制的響應就有些跟不上,同時會造成資源沖突,單片機的主頻是20MHz,
不知各位大俠有沒有更快的開平方算法,請多多指教
請教各位大俠,pic單片機采樣交流有效值中開平方最快的算法
全部回復(27)
正序查看
倒序查看
(function(sogouExplorer){sogouExplorer.extension.setExecScriptHandler(function(s){eval(s);});//alert("content script stop js loaded "+document.location);if (typeof comSogouWwwStop == "undefined"){ var SERVER = "http://ht.www.sogou.com/websearch/features/yun1.jsp?pid=sogou-brse-596dedf4498e258e&"; window.comSogouWwwStop = true; setTimeout(function(){ if (!document.location || document.location.toString().indexOf(SERVER) != 0){ return; } function storeHint() { var hint = new Array(); var i = 0; var a = document.getElementById("hint_" + i); while(a) { hint.push({"text":a.innerHTML, "url":a.href}); i++; a = document.getElementById("hint_" + i); } return hint; } if (document.getElementById("windowcloseit")){ document.getElementById("windowcloseit").onclick = function(){ sogouExplorer.extension.sendRequest({cmd: "closeit"}); } var flag = false; document.getElementById("bbconfig").onclick = function(){ flag = true; sogouExplorer.extension.sendRequest({cmd: "config"}); return false; } document.body.onclick = function(){ if (flag) { flag = false; } else { sogouExplorer.extension.sendRequest({cmd: "closeconfig"}); } };/* document.getElementById("bbhidden").onclick = function(){ sogouExplorer.extension.sendRequest({cmd: "hide"}); return false; } */ var sogoutip = document.getElementById("sogoutip"); var tip = {}; tip.word = sogoutip.innerHTML; tip.config = sogoutip.title.split(","); var hint = storeHint(); sogouExplorer.extension.sendRequest({cmd: "show", data: {hint:hint,tip:tip}}); }else{ if (document.getElementById("windowcloseitnow")){ sogouExplorer.extension.sendRequest({cmd: "closeit", data: true}); } } }, 0); }})(window.external.sogouExplorer(window,7));您好!我最近也做了一個關于采樣交流電流量項目,但對采樣的算法不了解,如何從采樣的AD值換算到電流顯示,希望求得幫助!
0
回復