pwmCtrl.cpp

00001 /*
00002   PWM 出力を行うプログラム
00003   Satofumi KAMIMURA
00004   $Id$
00005 */
00006 
00007 #if !MONITOR
00008 #include <runCtrl.h>
00009 #else
00010 #include <mRunCtrl.h>
00011 #endif
00012 #include <vutils.h>
00013 #include <stdio.h>
00014 #include <stdlib.h>
00015 #include <ctype.h>
00016 
00017 using namespace VXV;
00018 
00019 
00020 int main(int argc, char *argv[]) {
00021   try {
00022 #if !MONITOR
00023     RunCtrl run;
00024 #else
00025     mRunCtrl run;
00026     vmonitor::show();
00027 #endif
00028     if (run.connect(argc, argv) < 0) {
00029       printf("RunCtrl::connect: %s\n", run.what());
00030       exit(1);
00031     }
00032 
00033     for (int i = 0; i < 2; ++i) {
00034       run.setMotorMode(i, CW);
00035     }
00036 
00037     // q, Q が入力されたら停止して終了
00038     unsigned char duty = 0;
00039     int inputed = 0;
00040 
00041     while (1) {
00042       scanf("%d", &inputed);
00043       if ((inputed >= 0) && (inputed <= 255)) {
00044         duty = inputed;
00045         unsigned char duty_array[2] = { duty, duty };
00046         for (int i = 0; i < 2; ++i) {
00047           run.setMotorPwm(i, duty_array, 2);
00048         }
00049 
00050       } else if (inputed < 0) {
00051         break;
00052       }
00053     }
00054     run.stop();
00055 
00056   } catch (std::exception& e) {
00057     printf("exception: %s\n", e.what());
00058   }
00059   return 0;
00060 }
00061 

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