pwm.cpp

00001 /*
00002   PWM 出力毎の encoder 回転速度を表示するプログラム
00003   Satofumi KAMIMURA
00004   $Id$
00005 */
00006 
00007 #include "runCtrl.h"
00008 #include <stdio.h>
00009 #include <stdlib.h>
00010 
00011 
00012 int main(int argc, char *argv[]) {
00013   try {
00014     RunCtrl run;
00015     if (run.connect(argc, argv) < 0) {
00016       printf("RunCtrl::connect: %s\n", run.what());
00017       exit(1);
00018     }
00019 
00020     enum { MotorID = 0 };
00021     run.setMotorMode(MotorID, CW);
00022     for (int i = 0; i <= 255; ++i) {
00023       run.setMotorPwm(MotorID, i);
00024       VXV::Delay(50);
00025       int enc_vel = 0;
00026       run.getEncoderVel(MotorID, &enc_vel);
00027       printf("%d\t%d\n", i, enc_vel);
00028     }
00029     run.setMotorPwm(MotorID, 0);
00030 
00031   } catch (std::exception& e) {
00032     printf("exception:: %s\n", e.what());
00033   }
00034 
00035   return 0;
00036 }
00037 

Generated on Mon Apr 13 22:52:02 2009 by  doxygen 1.5.7.1