-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbipolar motor test
65 lines (54 loc) · 1.53 KB
/
bipolar motor test
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
60
61
62
63
64
65
#ifndef BIPOLAR_MOTOR_H_
#define BIPOLAR_MOTOR_H_
#define BIPOLAR P5
#define A1 BIT0
#define AP1 BIT1
#define B1 BIT2
#define BP1 BIT3
int count, logicCycle;
void tachometer_setup();
void tachometer_logic();
#endif /* BIPOLAR_MOTOR_H_ */
-------------------------------------------------------------------------------------------------------------------------------------
#include "msp.h"
#include "bipolar_motor.h"
#include "SysTick.h"
#include "stdio.h"
uint8_t stepper_logic[4] = { 0x06, // Step 1 - 0 1 1 0
0x05, // Step 2 - 0 1 0 1
0x09, // Step 3 - 1 0 0 1
0x0A}; // Step 4 - 1 0 1 0
void tachometer_logic(){
switch(count){
case 0:
printf("reset\n");
break;
case 1:
printf("case 1\n");
BIPOLAR->OUT |= (B1 | A1);
BIPOLAR->OUT &= ~(BP1 | AP1);
break;
case 2:
printf("case 2\n");
BIPOLAR->OUT |= (B1 | AP1);
BIPOLAR->OUT &= ~(BP1 | A1);
break;
case 3:
printf("case 3\n");
BIPOLAR->OUT |= (BP1 | AP1);
BIPOLAR->OUT &= ~(B1 | A1);
break;
case 4:
printf("case 4\n");
BIPOLAR->OUT |= (BP1 | A1);
BIPOLAR->OUT &= ~(B1 | AP1);
break;
}
logicCycle++;
}
void tachometer_setup(){
BIPOLAR->SEL0 &= ~(BP1 | B1 | A1 | AP1);
BIPOLAR->SEL1 &= ~(BP1 | B1 | A1 | AP1);
BIPOLAR->DIR |= (BP1 | B1 | A1 | AP1);
BIPOLAR->OUT &= ~(BP1 | B1 | A1 | AP1);
}