-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstepmotor.c
More file actions
60 lines (43 loc) · 1.31 KB
/
stepmotor.c
File metadata and controls
60 lines (43 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
Uses the RasPi GPIO ports to bit-band a stepper motor driver.
Uses three ports (defined below) to select the motor, direction,
and number of stepts.
usage:
~$ sudo ./stepmotor 0 100 1
steps motor "0" 100 steps in direction 1.
~$ sudo ./stepmotor 1 500 0
steps motor "1" 500 steps in direction 0.
Currently, the motors are determined by the pins used on the
raspberry pi to control them. These are set up in the
stepperMotorControl.h file. Right now,
Motor 0 -> Polarimeter
Motor 1 -> Absorption Analyzer
Motor 2 -> QWP
compile
~$ gcc -o stepmotor stepmotor.c -l wiringPi
*/
#include <stdio.h>
#include "interfacing/interfacing.h"
int main (int argc, char *argv[]){
int steps, dir;
int motor;
if (argc==4){
motor = atoi(argv[1]); // which steper motor
steps = atoi(argv[2]); // get steps from command line
dir = atoi(argv[3]); // get dir from command line
} else {
printf("Usage: ~$sudo ./stepmotor <motor(0,1,2)> <steps> <dir(0,1)>\n");
printf("Motor: 0->Polarimeter\n");
printf(" 1->Probe \n");
printf(" 2->Pump \n");
motor = 3;// not part of the switch statment, so nuthing happens
steps=0;
dir=0;
return 0;
}
initializeBoard();
initializeUSB1208();
stepMotor(motor,dir,steps);
closeUSB1208();
return 0;
}