Jul 4, 2011 #1 yzou_ua Member level 5 Joined Nov 5, 2008 Messages 92 Helped 1 Reputation 2 Reaction score 1 Trophy points 1,288 Activity points 1,869 After init etc., I calculate the speed in following way. Could someone help me find anything wrong here?? Buz the measured result varies time by time(when running the motor at constant speed). while(1) { if(TMR3<23000) { if(POS1CNT=0) {CntsRev=0; CntsRev+=1;} Cnts=POS1CNT+(CntsRev-1)*MaxCnt; // The total pulse number during above time period Speed_rad=2*3.14159*Cnts/ppr/TMR3; // Speed in rad/s } }
After init etc., I calculate the speed in following way. Could someone help me find anything wrong here?? Buz the measured result varies time by time(when running the motor at constant speed). while(1) { if(TMR3<23000) { if(POS1CNT=0) {CntsRev=0; CntsRev+=1;} Cnts=POS1CNT+(CntsRev-1)*MaxCnt; // The total pulse number during above time period Speed_rad=2*3.14159*Cnts/ppr/TMR3; // Speed in rad/s } }
Jul 6, 2011 #2 I Iamventure Junior Member level 3 Joined Jun 6, 2007 Messages 30 Helped 7 Reputation 14 Reaction score 5 Trophy points 1,288 Activity points 1,451 Is this step correct??? {CntsRev=0;