Version1

Dependencies:   LCD_i2c_GSOE VirtuelleHardware

Committer:
jack1930
Date:
Mon Feb 28 12:16:29 2022 +0000
Revision:
0:54ac54d090cf
Version1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jack1930 0:54ac54d090cf 1 /* mbed Microcontroller Library
jack1930 0:54ac54d090cf 2 * Copyright (c) 2019 ARM Limited
jack1930 0:54ac54d090cf 3 * SPDX-License-Identifier: Apache-2.0
jack1930 0:54ac54d090cf 4 */
jack1930 0:54ac54d090cf 5
jack1930 0:54ac54d090cf 6 #include "mbed.h"
jack1930 0:54ac54d090cf 7 #include "platform/mbed_thread.h"
jack1930 0:54ac54d090cf 8 #include "LCD.h"
jack1930 0:54ac54d090cf 9 #include "string"
jack1930 0:54ac54d090cf 10
jack1930 0:54ac54d090cf 11 #include "VH.h"
jack1930 0:54ac54d090cf 12
jack1930 0:54ac54d090cf 13 VH myVH;
jack1930 0:54ac54d090cf 14
jack1930 0:54ac54d090cf 15
jack1930 0:54ac54d090cf 16
jack1930 0:54ac54d090cf 17 PortOut Klappen(PortC,0b11);
jack1930 0:54ac54d090cf 18 #define Stellung1 0
jack1930 0:54ac54d090cf 19 #define Stellung2 1
jack1930 0:54ac54d090cf 20 #define Stellung3 2
jack1930 0:54ac54d090cf 21
jack1930 0:54ac54d090cf 22
jack1930 0:54ac54d090cf 23 DigitalOut FlaschenbandStart(PC_2);
jack1930 0:54ac54d090cf 24 DigitalOut KistenbandStart(PC_3);
jack1930 0:54ac54d090cf 25 DigitalOut GreiferStarten (PC_6);
jack1930 0:54ac54d090cf 26
jack1930 0:54ac54d090cf 27 DigitalIn Flasche1Sensor(PB_0);
jack1930 0:54ac54d090cf 28 DigitalIn Flasche2Sensor(PB_1);
jack1930 0:54ac54d090cf 29 DigitalIn Flasche3Sensor(PB_2);
jack1930 0:54ac54d090cf 30 DigitalIn Kiste1Sensor(PB_3);
jack1930 0:54ac54d090cf 31 DigitalIn Kiste2Sensor(PB_4);
jack1930 0:54ac54d090cf 32 DigitalIn Kiste3Sensor(PB_5);
jack1930 0:54ac54d090cf 33 DigitalIn GreiferFertig(PB_6);
jack1930 0:54ac54d090cf 34 DigitalIn verbunden(PB_7);
jack1930 0:54ac54d090cf 35
jack1930 0:54ac54d090cf 36
jack1930 0:54ac54d090cf 37
jack1930 0:54ac54d090cf 38 lcd mylcd;
jack1930 0:54ac54d090cf 39
jack1930 0:54ac54d090cf 40 void textzeile2(char* text)
jack1930 0:54ac54d090cf 41 {
jack1930 0:54ac54d090cf 42 mylcd.cursorpos(0);
jack1930 0:54ac54d090cf 43 mylcd.printf("%s",text);
jack1930 0:54ac54d090cf 44 }
jack1930 0:54ac54d090cf 45
jack1930 0:54ac54d090cf 46 void dualaus3(unsigned char x)
jack1930 0:54ac54d090cf 47 {
jack1930 0:54ac54d090cf 48 mylcd.cursorpos(0x40);
jack1930 0:54ac54d090cf 49 for (int i=0;i<8;i++)
jack1930 0:54ac54d090cf 50 mylcd.printf("%d",(x>>(7-i))&1);
jack1930 0:54ac54d090cf 51 }
jack1930 0:54ac54d090cf 52
jack1930 0:54ac54d090cf 53 int main()
jack1930 0:54ac54d090cf 54 {
jack1930 0:54ac54d090cf 55
jack1930 0:54ac54d090cf 56 mylcd.clear();
jack1930 0:54ac54d090cf 57 Flasche1Sensor.mode(PullUp);
jack1930 0:54ac54d090cf 58 Flasche2Sensor.mode(PullUp);
jack1930 0:54ac54d090cf 59 Flasche3Sensor.mode(PullUp);
jack1930 0:54ac54d090cf 60 Kiste1Sensor.mode(PullUp);
jack1930 0:54ac54d090cf 61 Kiste2Sensor.mode(PullUp);
jack1930 0:54ac54d090cf 62 Kiste3Sensor.mode(PullUp);;
jack1930 0:54ac54d090cf 63 GreiferFertig.mode(PullUp);;
jack1930 0:54ac54d090cf 64 verbunden.mode(PullUp);
jack1930 0:54ac54d090cf 65
jack1930 0:54ac54d090cf 66 FlaschenbandStart=1;
jack1930 0:54ac54d090cf 67 KistenbandStart=1;
jack1930 0:54ac54d090cf 68 GreiferStarten=1;
jack1930 0:54ac54d090cf 69
jack1930 0:54ac54d090cf 70
jack1930 0:54ac54d090cf 71 while (true) {
jack1930 0:54ac54d090cf 72 while(verbunden==1) {dualaus3(GPIOB->IDR&0xFF);textzeile2((char*)"Warten verbunden ");}
jack1930 0:54ac54d090cf 73 while(1)
jack1930 0:54ac54d090cf 74 {
jack1930 0:54ac54d090cf 75 Klappen=Stellung1;
jack1930 0:54ac54d090cf 76 FlaschenbandStart=0;
jack1930 0:54ac54d090cf 77
jack1930 0:54ac54d090cf 78 while (Flasche1Sensor==1) {dualaus3(GPIOB->IDR&0xFF);textzeile2((char*)"Warten Flasche1 ");}
jack1930 0:54ac54d090cf 79 Klappen=Stellung2;
jack1930 0:54ac54d090cf 80 while (Flasche2Sensor==1){dualaus3(GPIOB->IDR&0xFF); textzeile2((char*)"Warten Flasche2 ");}
jack1930 0:54ac54d090cf 81 /*Klappen=Stellung3;
jack1930 0:54ac54d090cf 82 while (Flasche3Sensor==1){dualaus3(GPIOB->IDR&0xFF); textzeile2((char*)"Warten auf Flasche3 ");}
jack1930 0:54ac54d090cf 83 Klappen = Stellung1;
jack1930 0:54ac54d090cf 84 FlaschenbandStart=1;
jack1930 0:54ac54d090cf 85 textzeile2("Flaschenband gestoppt ");
jack1930 0:54ac54d090cf 86 KistenbandStart=0;
jack1930 0:54ac54d090cf 87 while (Kiste1Sensor==1){dualaus3(GPIOB->IDR&0xFF); textzeile2("Warten auf Kiste1 ");}
jack1930 0:54ac54d090cf 88 KistenbandStart=1;
jack1930 0:54ac54d090cf 89 GreiferStarten=0;
jack1930 0:54ac54d090cf 90 HAL_Delay(200);
jack1930 0:54ac54d090cf 91 GreiferStarten=1;
jack1930 0:54ac54d090cf 92 while(GreiferFertig==1) {dualaus3(GPIOB->IDR&0xFF); textzeile2("Warten auf Greifer ");}
jack1930 0:54ac54d090cf 93 FlaschenbandStart=0;
jack1930 0:54ac54d090cf 94 while (Flasche1Sensor==1) {dualaus3(GPIOB->IDR&0xFF); textzeile2("Warten auf Flasche1 ");}
jack1930 0:54ac54d090cf 95 Klappen= Stellung2;
jack1930 0:54ac54d090cf 96 while (Flasche2Sensor==1) {dualaus3(GPIOB->IDR&0xFF); textzeile2("Warten auf Flasche2 ");}
jack1930 0:54ac54d090cf 97 Klappen=Stellung3;
jack1930 0:54ac54d090cf 98 while (Flasche3Sensor==1) {dualaus3(GPIOB->IDR&0xFF); textzeile2("Warten auf Flasche3 ");}
jack1930 0:54ac54d090cf 99 Klappen=Stellung1;
jack1930 0:54ac54d090cf 100 FlaschenbandStart=1;
jack1930 0:54ac54d090cf 101 textzeile2("Flaschenband gestoppt ");
jack1930 0:54ac54d090cf 102 KistenbandStart=0;
jack1930 0:54ac54d090cf 103 while (Kiste2Sensor==1){dualaus3(GPIOB->IDR&0xFF); textzeile2("Warten auf Kiste2 ");}
jack1930 0:54ac54d090cf 104 KistenbandStart=1;
jack1930 0:54ac54d090cf 105 GreiferStarten=0;
jack1930 0:54ac54d090cf 106 HAL_Delay(200);
jack1930 0:54ac54d090cf 107 GreiferStarten=1;
jack1930 0:54ac54d090cf 108 while(GreiferFertig==1) {dualaus3(GPIOB->IDR&0xFF); textzeile2("Warten auf Greifer ");}
jack1930 0:54ac54d090cf 109 FlaschenbandStart=0;
jack1930 0:54ac54d090cf 110 while (Flasche1Sensor==1) textzeile2("Warten auf Flasche1 ");
jack1930 0:54ac54d090cf 111 Klappen=Stellung2;
jack1930 0:54ac54d090cf 112 while (Flasche2Sensor==1) textzeile2("Warten auf Flasche2 ");
jack1930 0:54ac54d090cf 113 Klappen=Stellung3;
jack1930 0:54ac54d090cf 114 while (Flasche3Sensor==1) textzeile2("Warten auf Flasche3 ");
jack1930 0:54ac54d090cf 115 Klappen=Stellung1;
jack1930 0:54ac54d090cf 116 FlaschenbandStart=1;
jack1930 0:54ac54d090cf 117 textzeile2("Flaschenband gestoppt ");
jack1930 0:54ac54d090cf 118 KistenbandStart=0;
jack1930 0:54ac54d090cf 119 while (Kiste3Sensor==1)textzeile2("Warten auf Kiste3 ");
jack1930 0:54ac54d090cf 120 KistenbandStart=1;
jack1930 0:54ac54d090cf 121 GreiferStarten=0;
jack1930 0:54ac54d090cf 122 HAL_Delay(200);
jack1930 0:54ac54d090cf 123 GreiferStarten=1;
jack1930 0:54ac54d090cf 124 while(GreiferFertig==1) textzeile2("Warten auf Greifer ");
jack1930 0:54ac54d090cf 125 KistenbandStart=0;
jack1930 0:54ac54d090cf 126 HAL_Delay(3000);
jack1930 0:54ac54d090cf 127 KistenbandStart=1;
jack1930 0:54ac54d090cf 128 */
jack1930 0:54ac54d090cf 129 }
jack1930 0:54ac54d090cf 130
jack1930 0:54ac54d090cf 131 }
jack1930 0:54ac54d090cf 132 }