Keegan Hu
/
finalwarehouse
ddd
Fork of whouse by
main.cpp@3:09f6061e6e5d, 2018-05-11 (annotated)
- Committer:
- glintligo
- Date:
- Fri May 11 10:42:09 2018 +0000
- Revision:
- 3:09f6061e6e5d
- Parent:
- 2:ecf401a37aa3
- Child:
- 4:d66b6f331b74
???
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Bilybill | 0:2e00b81c9137 | 1 | #include "mbed.h" |
Bilybill | 0:2e00b81c9137 | 2 | #include "Stepper_motor.h" |
Bilybill | 0:2e00b81c9137 | 3 | #include "robo.h" |
Bilybill | 0:2e00b81c9137 | 4 | Serial Info(PB_10,PB_11); |
Bilybill | 0:2e00b81c9137 | 5 | Ticker t1; |
glintligo | 3:09f6061e6e5d | 6 | void serial_ticker();//蓝牙串口中断函数 |
glintligo | 3:09f6061e6e5d | 7 | // puma black |
glintligo | 2:ecf401a37aa3 | 8 | /*Stepper_motor s1(PB_9,PB_0,PB_7,PA_11,10,16,1); |
Bilybill | 0:2e00b81c9137 | 9 | Stepper_motor s2(PB_6,PA_7,PB_4,PA_15,10,16,1); |
Bilybill | 0:2e00b81c9137 | 10 | Stepper_motor s3(PB_3,PA_6,PA_12,PB_1,10,16,1); |
glintligo | 2:ecf401a37aa3 | 11 | */ |
glintligo | 2:ecf401a37aa3 | 12 | // en step dir button 减速比 细分数 初始方向 |
glintligo | 3:09f6061e6e5d | 13 | Stepper_motor s1(PA_6,PC_5,PC_4,PB_14,10,16,0);//x puma white |
glintligo | 2:ecf401a37aa3 | 14 | Stepper_motor s2(PA_2,PA_5,PA_4,PC_6,10,16,1);//y |
glintligo | 2:ecf401a37aa3 | 15 | Stepper_motor s3(PC_13,PC_3,PC_2,PB_15,10,16,0);//z |
glintligo | 3:09f6061e6e5d | 16 | //PwmOut pwm2(PA_1); |
glintligo | 3:09f6061e6e5d | 17 | //DigitalOut button(PA_0); |
glintligo | 2:ecf401a37aa3 | 18 | |
glintligo | 3:09f6061e6e5d | 19 | float moterXdeg, moterYdeg, moterZdeg; |
Bilybill | 0:2e00b81c9137 | 20 | int main() |
glintligo | 3:09f6061e6e5d | 21 | { |
glintligo | 3:09f6061e6e5d | 22 | {//初始化 |
glintligo | 3:09f6061e6e5d | 23 | Info.attach(&serial_ticker); |
glintligo | 3:09f6061e6e5d | 24 | s1.Init(); |
glintligo | 3:09f6061e6e5d | 25 | wait(5); |
glintligo | 3:09f6061e6e5d | 26 | s2.Init(); |
glintligo | 3:09f6061e6e5d | 27 | wait(5); |
glintligo | 3:09f6061e6e5d | 28 | s3.Init(); |
glintligo | 3:09f6061e6e5d | 29 | wait(5); |
glintligo | 3:09f6061e6e5d | 30 | } |
glintligo | 3:09f6061e6e5d | 31 | |
glintligo | 3:09f6061e6e5d | 32 | {//计算电机角度 |
glintligo | 3:09f6061e6e5d | 33 | moterXdeg = 1; |
glintligo | 3:09f6061e6e5d | 34 | moterYdeg = 2; |
glintligo | 3:09f6061e6e5d | 35 | moterZdeg = 3; |
glintligo | 3:09f6061e6e5d | 36 | //Info.printf("moterXdeg:%f moterYdeg:%f moterZdeg:%f\n",moterXdeg, moterYdeg,moterZdeg); |
glintligo | 3:09f6061e6e5d | 37 | } |
glintligo | 3:09f6061e6e5d | 38 | |
glintligo | 3:09f6061e6e5d | 39 | { //运动 |
glintligo | 3:09f6061e6e5d | 40 | /*若转动的角度为-1 则会一直转,此时rec_rate需大于0 |
glintligo | 3:09f6061e6e5d | 41 | * 除此之外,若转动角度或转速小于0,则电机反转 |
glintligo | 3:09f6061e6e5d | 42 | * 如在电机尚未停止前再次调用该函数,则会立刻开始新的电机运动 |
glintligo | 3:09f6061e6e5d | 43 | */ |
glintligo | 3:09f6061e6e5d | 44 | s1.Config(5,moterXdeg); |
glintligo | 3:09f6061e6e5d | 45 | //wait(5); |
glintligo | 3:09f6061e6e5d | 46 | //如果运动出现bug,可将上方注释去掉 |
glintligo | 3:09f6061e6e5d | 47 | s2.Config(5,moterYdeg); |
glintligo | 3:09f6061e6e5d | 48 | //wait(5); |
glintligo | 3:09f6061e6e5d | 49 | s3.Config(5,moterZdeg); |
glintligo | 3:09f6061e6e5d | 50 | //wait(5); |
glintligo | 3:09f6061e6e5d | 51 | } |
glintligo | 2:ecf401a37aa3 | 52 | while(1) |
glintligo | 2:ecf401a37aa3 | 53 | { |
glintligo | 2:ecf401a37aa3 | 54 | |
glintligo | 3:09f6061e6e5d | 55 | |
glintligo | 3:09f6061e6e5d | 56 | } |
Bilybill | 0:2e00b81c9137 | 57 | } |
glintligo | 3:09f6061e6e5d | 58 | |
glintligo | 3:09f6061e6e5d | 59 | void serial_ticker() |
glintligo | 3:09f6061e6e5d | 60 | { |
glintligo | 3:09f6061e6e5d | 61 | |
glintligo | 3:09f6061e6e5d | 62 | } |