Erste version der Software für der Prototyp

Committer:
borlanic
Date:
Fri Mar 30 14:07:05 2018 +0000
Revision:
4:75df35ef4fb6
Parent:
2:3f836b662104
commentar

Who changed what in which revision?

UserRevisionLine numberNew contents of line
borlanic 0:380207fcb5c1 1 #include "mbed.h"
borlanic 0:380207fcb5c1 2 #include "EncoderCounter.h"
borlanic 0:380207fcb5c1 3 #include "IMU.h"
borlanic 0:380207fcb5c1 4 #include "Controller.h"
borlanic 0:380207fcb5c1 5
borlanic 1:d5c5bb30ac90 6 // create miscellaneous periphery objects
borlanic 1:d5c5bb30ac90 7 DigitalOut led1(PB_13);
borlanic 1:d5c5bb30ac90 8 DigitalOut led2(PC_8);
borlanic 1:d5c5bb30ac90 9 DigitalOut led3(PC_9);
borlanic 1:d5c5bb30ac90 10 DigitalOut led4(PC_0);
borlanic 1:d5c5bb30ac90 11 DigitalOut led5(PC_1);
borlanic 1:d5c5bb30ac90 12 DigitalOut led6(PH_1);
borlanic 1:d5c5bb30ac90 13 DigitalOut led7(PC_2);
borlanic 1:d5c5bb30ac90 14 DigitalOut led8(PC_3);
borlanic 1:d5c5bb30ac90 15 DigitalOut led9(PB_0);
borlanic 1:d5c5bb30ac90 16
borlanic 1:d5c5bb30ac90 17 DigitalIn user_button(USER_BUTTON);
borlanic 1:d5c5bb30ac90 18 //DigitalIn reset_button(NRST);
borlanic 1:d5c5bb30ac90 19
borlanic 1:d5c5bb30ac90 20 // create IMU comunication objects
borlanic 1:d5c5bb30ac90 21 SPI spi(PC_12, PC_11, PC_10); // mosi, miso, sclk
borlanic 1:d5c5bb30ac90 22 DigitalOut csAG(PA_15);
borlanic 1:d5c5bb30ac90 23 DigitalOut csM(PD_2);
borlanic 0:380207fcb5c1 24
borlanic 0:380207fcb5c1 25 // create motor control objects
borlanic 1:d5c5bb30ac90 26 DigitalOut enable1(PB_1);
borlanic 1:d5c5bb30ac90 27 DigitalOut enable2(PB_2);
borlanic 1:d5c5bb30ac90 28 DigitalOut enable3(PB_3);
borlanic 1:d5c5bb30ac90 29
borlanic 1:d5c5bb30ac90 30 PwmOut pwm1(PA_8);
borlanic 1:d5c5bb30ac90 31 PwmOut pwm2(PA_9);
borlanic 1:d5c5bb30ac90 32 PwmOut pwm3(PA_10);
borlanic 1:d5c5bb30ac90 33
borlanic 2:3f836b662104 34 AnalogIn M1_AOUT1(PB_4);
borlanic 2:3f836b662104 35 AnalogIn M1_AOUT2(PB_5);
borlanic 2:3f836b662104 36 DigitalIn M1_DIO3(PB_12);
borlanic 2:3f836b662104 37 DigitalIn M1_DIO4(PC_7);
borlanic 2:3f836b662104 38
borlanic 2:3f836b662104 39 AnalogIn M2_AOUT1(PB_14);
borlanic 2:3f836b662104 40 AnalogIn M2_AOUT2(PB_15);
borlanic 2:3f836b662104 41 DigitalIn M2_DIO3(PA_4);
borlanic 2:3f836b662104 42 DigitalIn M2_DIO4(PA_5);
borlanic 2:3f836b662104 43
borlanic 2:3f836b662104 44 AnalogIn M3_AOUT1(PA_7);
borlanic 2:3f836b662104 45 AnalogIn M3_AOUT2(PA_11);
borlanic 2:3f836b662104 46 DigitalIn M3_DIO3(PA_12);
borlanic 2:3f836b662104 47 DigitalIn M3_DIO4(PC_4);
borlanic 2:3f836b662104 48
borlanic 1:d5c5bb30ac90 49 // crete Encoder read objects
borlanic 2:3f836b662104 50 EncoderCounter counter1(PA_6, PC_7);
borlanic 2:3f836b662104 51 EncoderCounter counter2(PB_6, PB_7);
borlanic 2:3f836b662104 52 EncoderCounter counter3(PA_1, PA_0);
borlanic 0:380207fcb5c1 53
borlanic 0:380207fcb5c1 54 // create distance sensor objects
borlanic 0:380207fcb5c1 55
borlanic 0:380207fcb5c1 56 // create robot controller objects
borlanic 0:380207fcb5c1 57
borlanic 0:380207fcb5c1 58 // create serial comunication objects, bluetooth/wifi
borlanic 0:380207fcb5c1 59
borlanic 0:380207fcb5c1 60 // enter main loop
borlanic 0:380207fcb5c1 61 int main()
borlanic 0:380207fcb5c1 62 {
borlanic 0:380207fcb5c1 63 // instance objects
borlanic 0:380207fcb5c1 64
borlanic 0:380207fcb5c1 65 //IMU
borlanic 1:d5c5bb30ac90 66 IMU imu(spi, csAG, csM);
borlanic 0:380207fcb5c1 67 //controller
borlanic 1:d5c5bb30ac90 68 Controller controller(pwm1,pwm2,pwm3,counter1,counter2,counter3,imu);
borlanic 0:380207fcb5c1 69 //stateMachine
borlanic 0:380207fcb5c1 70
borlanic 0:380207fcb5c1 71 while (true) {
borlanic 1:d5c5bb30ac90 72
borlanic 0:380207fcb5c1 73 //printf tests
borlanic 1:d5c5bb30ac90 74
borlanic 0:380207fcb5c1 75 led1 = !led1;
borlanic 0:380207fcb5c1 76 wait(0.5);
borlanic 0:380207fcb5c1 77 }
borlanic 0:380207fcb5c1 78 }