Prom_Roebi_0.1

Dependencies:   Farbsensor IRSensorLib PID_Control Servo mbed PixyLib

Committer:
ZHAW_Prometheus
Date:
Wed May 17 07:38:41 2017 +0000
Revision:
7:5949f408b6da
Parent:
3:017c85c4b14b
Child:
8:077d0bb213a2
Vers. 17. 05. 2017

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ZHAW_Prometheus 0:422088ad7fc5 1 #include "mbed.h"
ZHAW_Prometheus 0:422088ad7fc5 2 #include "cstdlib"
ZHAW_Prometheus 0:422088ad7fc5 3 #include "IRSensor.h"
ZHAW_Prometheus 0:422088ad7fc5 4 #include "Servo.h"
ZHAW_Prometheus 7:5949f408b6da 5 //#include "Pixy.h"
ZHAW_Prometheus 0:422088ad7fc5 6 #include "Farbauswertung.h"
ZHAW_Prometheus 1:5c44e2462a8b 7 #include "Fahren.h"
ZHAW_Prometheus 1:5c44e2462a8b 8 #include "liftAnsteuerung.h"
ZHAW_Prometheus 7:5949f408b6da 9 #include "CamAusw.h"
ZHAW_Prometheus 0:422088ad7fc5 10
ZHAW_Prometheus 0:422088ad7fc5 11 /**
ZHAW_Prometheus 0:422088ad7fc5 12 *Aus- und Eingänge initialisieren
ZHAW_Prometheus 0:422088ad7fc5 13 */
ZHAW_Prometheus 1:5c44e2462a8b 14 //Button
ZHAW_Prometheus 1:5c44e2462a8b 15 DigitalIn usrButton(USER_BUTTON);
ZHAW_Prometheus 0:422088ad7fc5 16 //IRSensoren
ZHAW_Prometheus 0:422088ad7fc5 17 DigitalOut enable(PC_1);
ZHAW_Prometheus 0:422088ad7fc5 18 DigitalOut bit0(PH_1);
ZHAW_Prometheus 0:422088ad7fc5 19 DigitalOut bit1(PC_2);
ZHAW_Prometheus 0:422088ad7fc5 20 DigitalOut bit2(PC_3);
ZHAW_Prometheus 0:422088ad7fc5 21 AnalogIn distance(PB_1);
ZHAW_Prometheus 0:422088ad7fc5 22 //Motoren
ZHAW_Prometheus 0:422088ad7fc5 23 DigitalOut enableMotorDriver(PB_2);
ZHAW_Prometheus 0:422088ad7fc5 24 PwmOut pwmLeft(PA_8);
ZHAW_Prometheus 0:422088ad7fc5 25 PwmOut pwmRight(PA_9);
ZHAW_Prometheus 0:422088ad7fc5 26 //LED's
ZHAW_Prometheus 0:422088ad7fc5 27 DigitalOut led0(PC_8);
ZHAW_Prometheus 0:422088ad7fc5 28 DigitalOut led1(PC_6);
ZHAW_Prometheus 0:422088ad7fc5 29 DigitalOut led5(PC_9);
ZHAW_Prometheus 1:5c44e2462a8b 30 DigitalOut led3(PA_7);
ZHAW_Prometheus 0:422088ad7fc5 31 //Farbauswertung
ZHAW_Prometheus 0:422088ad7fc5 32 AnalogIn SensorG(PA_0);
ZHAW_Prometheus 0:422088ad7fc5 33 AnalogIn SensorR(PA_1);
ZHAW_Prometheus 0:422088ad7fc5 34 Servo ServoAusw(PB_7);
ZHAW_Prometheus 1:5c44e2462a8b 35 Servo ServoFoerder(PC_7);
ZHAW_Prometheus 1:5c44e2462a8b 36 //Lift
ZHAW_Prometheus 1:5c44e2462a8b 37 Servo ServoLift(PA_6);
ZHAW_Prometheus 7:5949f408b6da 38 //Kamera
ZHAW_Prometheus 1:5c44e2462a8b 39
ZHAW_Prometheus 0:422088ad7fc5 40 //Serielle Ausgabe
ZHAW_Prometheus 0:422088ad7fc5 41 Serial pc(SERIAL_TX,SERIAL_RX);
ZHAW_Prometheus 0:422088ad7fc5 42
ZHAW_Prometheus 7:5949f408b6da 43 Camauswertung cam(1);
ZHAW_Prometheus 1:5c44e2462a8b 44 Farbauswertung farbauswertung(&SensorG, &SensorR, &ServoAusw);
ZHAW_Prometheus 7:5949f408b6da 45 Fahren fahren(&enable, &bit0, &bit1, &bit2, &distance, &enableMotorDriver, &pwmLeft, &pwmRight, &cam);
ZHAW_Prometheus 7:5949f408b6da 46 LiftAnsteuerung lift(100, 10, &ServoLift);
ZHAW_Prometheus 0:422088ad7fc5 47
ZHAW_Prometheus 0:422088ad7fc5 48 int main()
ZHAW_Prometheus 0:422088ad7fc5 49 {
ZHAW_Prometheus 0:422088ad7fc5 50 farbauswertung.setSerialOutput(&pc);
ZHAW_Prometheus 1:5c44e2462a8b 51 fahren.setSerialOutput(&pc);
ZHAW_Prometheus 1:5c44e2462a8b 52
ZHAW_Prometheus 1:5c44e2462a8b 53 ServoLift = 1.2f; //1.2
ZHAW_Prometheus 1:5c44e2462a8b 54 ServoFoerder = 0.1f; //0.1
ZHAW_Prometheus 1:5c44e2462a8b 55
ZHAW_Prometheus 1:5c44e2462a8b 56 fahren.fahrInit();
ZHAW_Prometheus 0:422088ad7fc5 57
ZHAW_Prometheus 0:422088ad7fc5 58 Ticker farbe;
schuema4 3:017c85c4b14b 59 farbe.attach(&farbauswertung, &Farbauswertung::auswertung, 0.01);
ZHAW_Prometheus 0:422088ad7fc5 60
ZHAW_Prometheus 1:5c44e2462a8b 61 Ticker drive;
schuema4 3:017c85c4b14b 62 drive.attach(&fahren, &Fahren::fahrRutine, 0.01);
ZHAW_Prometheus 1:5c44e2462a8b 63
ZHAW_Prometheus 7:5949f408b6da 64 Ticker elevator;
ZHAW_Prometheus 7:5949f408b6da 65 elevator.attach(&lift, &LiftAnsteuerung::steuerung, 0.01);
ZHAW_Prometheus 7:5949f408b6da 66
ZHAW_Prometheus 7:5949f408b6da 67 Ticker camausw;
ZHAW_Prometheus 7:5949f408b6da 68 camausw.attach(&cam, &Camauswertung::auswertung, 0.01);
ZHAW_Prometheus 1:5c44e2462a8b 69
ZHAW_Prometheus 0:422088ad7fc5 70 while (1) {
ZHAW_Prometheus 0:422088ad7fc5 71
schuema4 3:017c85c4b14b 72 wait(0.001);
ZHAW_Prometheus 0:422088ad7fc5 73 }
ZHAW_Prometheus 0:422088ad7fc5 74 }