class BasicWheel
{
bool forward = true;
SteppingMotor R, L;
public BasicWheel()
{
R = new SteppingMotor (GPIOPins.V2Plus_Pin_P1_33,
GPIOPins.V2Plus_Pin_P1_31, forward);
L = new SteppingMotor (GPIOPins.V2Plus_Pin_P1_32,
GPIOPins.V2Plus_Pin_P1_36, !forward);
}
public void move(double pathway, int step) // cm unit
{
SteppingMotor.TotalTime = Math.Abs(step) * (int)(pathway / SteppingMotor.oneStep + 0.5);
Console.WriteLine("Straight ahead start {0}msec", SteppingMotor.TotalTime);
R.MotorOn ();
Stopwatch stopwatch = Stopwatch.StartNew ();
R.Start(step);
L.Start (step);
while (!SteppingMotor.StopFlag);
stopwatch.Stop ();
long span = stopwatch.ElapsedTicks;
Console.WriteLine("Straight end. Time={0,7:f3}sec", span/10e6);
R.MotorOff();
Thread.Sleep(100);
}
}
|
1
2
3
4
5
6
7
8
9
10
11
12 前進、後進するメソッド
13 pathway: 距離(cm)
14 step : スピード
15
16
17
18
19
20
21
22
23
24
25
26
27
|