• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
  • slider image 488
  • slider image 491
:::

論壇索引


Board index » All Posts (阿膀)




求救 這個程式 debug 哪裡錯 看不懂
#1
新會員
新會員


/*position analysis of a four bar linkage*/
#include<math.h>
#include<stdio.h>
#define pi 3.141592654
main()
{
double r1,r2,r3,r4,r3p;
double t2,t3,t4,dt2,dt3,dt4;
double lower,upper,step,e;
double e1,e2;
double temp,xc,yc;
nt i,flag=0;
r1=6.0;
r2=2.0;
r3=5.0;
r4=5.0;
r3p=2.5;
t3=70*pi/180;
t4=120*pi/180;
lower=0;
upper=360;
step=5;
e=0.01*pi/180;
printf("theta2 theta3 theta4 Xc Yc\n");
printf("==============================\n");
for(i=lower;i<=upper;i+=step)
{
flag=0;
t2=i*pi/180;
do
{
e1=r2*cos(t2)+r3*cos(t3)-r4*cos(t4)-r1;
e2=r2*sin(t2)+r3*sin(t3)-r4*sin(t4);
temp=r3*r4(sin(t3)*cos(t4)-cos(t3)*sin(t4));
dt3=(e1*r4*cos(t4)+e2*r4*sin(t4))/temp;
dt4=(e1*r3*cos(t3)+e2*r3*sin(t3))/temp;
t3+=dt3;
t4+=dt4;
if(fabs(dt3)<e && fabs(dt4)<e)
flag=1;
}
while(flag==0)
xc=r2*cos(t2)+r3p*cos(t3);
yc=r2*sin(t2)+r3p*sin(t3);
printf("%7.1f %7.3f %7.3f %7.3f %7.3f/n",t2*180/pi,t3*180/pi,t4*180/pi,xc,yc);
}
printf("===============================================")
}

發表於: 2007/1/5 21:17
頂部


Re: 新手請教前輩們
#2
新會員
新會員


我是要用來抓取ON 的時間 那TOTAL TIME是20ms 是固定的
所以只需要抓取上升和下降的時間一減後就知道on的時間 也應該可以算出duty-cycle囉 那請教 一下 capture範例 有哪些
我手上是參考全華那本施慶隆寫的pic16f87x微控制器實習
但是 新手上路 大部份都看不太懂 現在還繼續看 timer的三種工能 計時 捕捉 比較 不知道在程式中 設定要怎麼寫 在書上的8-3 寫的 真的是看不太懂

發表於: 2006/12/28 17:57
頂部


新手請教前輩們
#3
新會員
新會員


看了一些範例 想試寫看看 目前手上有pic16f877 想利用他上面的timer 3組 來抓取4個pwm輸入訊號 不知道該從何下手 看到都是做pwm輸出 有一些粗淺的想法利用pwm上升緣來觸發timer開始計時 到下降再觸發中斷 計時結束 但是卻不知道要怎麼來撰寫 希望有經驗的先進們 指教一下

發表於: 2006/12/27 21:14
頂部






:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------