main.c aktualisiert
This commit is contained in:
parent
54aeabad73
commit
a706146744
52
main.c
52
main.c
@ -37,14 +37,12 @@ NexEventObj fuellstandText;
|
|||||||
|
|
||||||
//---------------------Variablen------------------------
|
//---------------------Variablen------------------------
|
||||||
|
|
||||||
volatile unsigned long* Switch[8] ={&Switch0, &Switch1, &Switch2, &Switch3, &Switch4, &Switch5, &Switch6, &Switch7};
|
|
||||||
|
|
||||||
#define SOLLWERT 0x7F // 127d
|
#define SOLLWERT 0x7F // 127d
|
||||||
#define GAP 0x5F // 95d
|
#define GAP 0x5F // 95d
|
||||||
#define NACHLAUF 0x5
|
#define NACHLAUF 0x5
|
||||||
|
|
||||||
|
volatile unsigned long* Switch[8] ={&Switch0, &Switch1, &Switch2, &Switch3, &Switch4, &Switch5, &Switch6, &Switch7};
|
||||||
int nachlaufOffset = 0;
|
int nachlaufOffset = 0;
|
||||||
char buffer[24]; // ka ob wir die benutzen, zu faul zum Suchen
|
|
||||||
|
|
||||||
//------------------------------------------------------
|
//------------------------------------------------------
|
||||||
|
|
||||||
@ -59,24 +57,16 @@ void PortConfig(void)
|
|||||||
RCC -> APB2ENR |= RCC_APB2ENR_IOPBEN; //Takt für Port B aktivieren
|
RCC -> APB2ENR |= RCC_APB2ENR_IOPBEN; //Takt für Port B aktivieren
|
||||||
RCC -> APB2ENR |= RCC_APB2ENR_IOPAEN; //Takt für Port A aktivieren
|
RCC -> APB2ENR |= RCC_APB2ENR_IOPAEN; //Takt für Port A aktivieren
|
||||||
|
|
||||||
GPIOC -> CRL &= 0x00000000;
|
|
||||||
GPIOC -> CRL = 0x22222222;
|
|
||||||
GPIOC -> CRH = 0x22222222;
|
|
||||||
|
|
||||||
GPIOB -> CRL &= 0x00000000;
|
GPIOB -> CRL &= 0x00000000;
|
||||||
GPIOB -> CRL = 0x22222222;
|
GPIOB -> CRL = 0x22222222;
|
||||||
|
GPIOB -> CRH &= 0x00000000;
|
||||||
|
GPIOB -> CRH |= 0x88880000;
|
||||||
|
|
||||||
GPIOA -> CRL &= 0x00000000;
|
GPIOA -> CRL &= 0x00000000;
|
||||||
GPIOA -> CRL = 0x22222222;
|
GPIOA -> CRL = 0x22222222;
|
||||||
|
|
||||||
//----- Inputs ------
|
|
||||||
|
|
||||||
GPIOA -> CRH &= 0x00000000;
|
GPIOA -> CRH &= 0x00000000;
|
||||||
GPIOA -> CRH |= 0x00088000;
|
GPIOA -> CRH |= 0x00088000;
|
||||||
|
|
||||||
GPIOB -> CRH &= 0x00000000;
|
|
||||||
GPIOB -> CRH |= 0x88880000;
|
|
||||||
|
|
||||||
GPIOC -> CRL &= 0x00000000;
|
GPIOC -> CRL &= 0x00000000;
|
||||||
GPIOC -> CRL |= 0x28222222;
|
GPIOC -> CRL |= 0x28222222;
|
||||||
GPIOC -> CRH &= 0x00000000;
|
GPIOC -> CRH &= 0x00000000;
|
||||||
@ -169,7 +159,6 @@ void configProgressBar(void)
|
|||||||
pumpeInd.pushhandler = NULL;
|
pumpeInd.pushhandler = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void configTextFields(void)
|
void configTextFields(void)
|
||||||
{
|
{
|
||||||
fuellstandText.pid = 0;
|
fuellstandText.pid = 0;
|
||||||
@ -203,13 +192,13 @@ void leerBlasen(int8_t state)
|
|||||||
{
|
{
|
||||||
NexProgressBar_setValue(&leerInd, 100);
|
NexProgressBar_setValue(&leerInd, 100);
|
||||||
LEERBLASEN = 1;
|
LEERBLASEN = 1;
|
||||||
uart2_putString("Leerblasventil geoeffnet!\r\n");
|
//uart2_putString("Leerblasventil geoeffnet!\r\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NexProgressBar_setValue(&leerInd, 0);
|
NexProgressBar_setValue(&leerInd, 0);
|
||||||
LEERBLASEN = 0;
|
LEERBLASEN = 0;
|
||||||
uart2_putString("Leerblasventil geschlossen!\r\n");
|
//uart2_putString("Leerblasventil geschlossen!\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -221,13 +210,13 @@ void fein(int8_t state)
|
|||||||
{
|
{
|
||||||
NexProgressBar_setValue(&feinInd, 100);
|
NexProgressBar_setValue(&feinInd, 100);
|
||||||
FEIN = 1;
|
FEIN = 1;
|
||||||
uart2_putString("Feinventil geoeffnet!\r\n");
|
//uart2_putString("Feinventil geoeffnet!\r\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NexProgressBar_setValue(&feinInd, 0);
|
NexProgressBar_setValue(&feinInd, 0);
|
||||||
FEIN = 0;
|
FEIN = 0;
|
||||||
uart2_putString("Feinventil geschlossen!\r\n");
|
//uart2_putString("Feinventil geschlossen!\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -239,13 +228,13 @@ void grob(int8_t state)
|
|||||||
{
|
{
|
||||||
NexProgressBar_setValue(&grobInd, 100);
|
NexProgressBar_setValue(&grobInd, 100);
|
||||||
GROB = 1;
|
GROB = 1;
|
||||||
uart2_putString("Grobventil geoeffnet!\r\n");
|
//uart2_putString("Grobventil geoeffnet!\r\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NexProgressBar_setValue(&grobInd, 0);
|
NexProgressBar_setValue(&grobInd, 0);
|
||||||
GROB = 0;
|
GROB = 0;
|
||||||
uart2_putString("Grobventil geoeffnet!\r\n");
|
//uart2_putString("Grobventil geoeffnet!\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -257,13 +246,13 @@ void pumpe(int8_t state)
|
|||||||
{
|
{
|
||||||
NexProgressBar_setValue(&pumpeInd, 100);
|
NexProgressBar_setValue(&pumpeInd, 100);
|
||||||
PUMPE = 1;
|
PUMPE = 1;
|
||||||
uart2_putString("Pumpe eingeschaltet!\r\n");
|
//uart2_putString("Pumpe eingeschaltet!\r\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NexProgressBar_setValue(&pumpeInd, 0);
|
NexProgressBar_setValue(&pumpeInd, 0);
|
||||||
PUMPE = 0;
|
PUMPE = 0;
|
||||||
uart2_putString("Pumpe ausgeschaltet!\r\n");
|
//uart2_putString("Pumpe ausgeschaltet!\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -274,12 +263,12 @@ void fuellstand(int8_t value)
|
|||||||
if(value >= 0 && value <= 100)
|
if(value >= 0 && value <= 100)
|
||||||
{
|
{
|
||||||
NexProgressBar_setValue(&fuellstandInd, value);
|
NexProgressBar_setValue(&fuellstandInd, value);
|
||||||
uart2_putString("Fuellstand geaendert!\r\n");
|
//uart2_putString("Fuellstand geaendert!\r\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NexProgressBar_setValue(&fuellstandInd, 0);
|
NexProgressBar_setValue(&fuellstandInd, 0);
|
||||||
uart2_putString("Uengueltiger Fuellstandswert!\r\n");
|
//uart2_putString("Uengueltiger Fuellstandswert!\r\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,8 +323,8 @@ int main(void)
|
|||||||
pumpe(0);
|
pumpe(0);
|
||||||
wait_sys_ms(20);
|
wait_sys_ms(20);
|
||||||
|
|
||||||
bool leerGeblasen = 0;
|
bool leerGeblasen = false;
|
||||||
bool leitungBenutzt = 0;
|
bool leitungBenutzt = false;
|
||||||
|
|
||||||
uart2_putString("Dosieranlage V01\r\n");
|
uart2_putString("Dosieranlage V01\r\n");
|
||||||
|
|
||||||
@ -346,10 +335,9 @@ int main(void)
|
|||||||
uint8_t istWert = SwitchesToInt();
|
uint8_t istWert = SwitchesToInt();
|
||||||
uint16_t effektiverWert = istWert + nachlaufOffset;
|
uint16_t effektiverWert = istWert + nachlaufOffset;
|
||||||
|
|
||||||
|
|
||||||
if(*Switch[7] == 0)
|
if(*Switch[7] == 0)
|
||||||
{
|
{
|
||||||
leerGeblasen = 1;
|
leerGeblasen = true;
|
||||||
leitungBenutzt = false;
|
leitungBenutzt = false;
|
||||||
|
|
||||||
pumpe(1);
|
pumpe(1);
|
||||||
@ -383,17 +371,17 @@ int main(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(leerGeblasen == 1)
|
if(leerGeblasen)
|
||||||
{
|
{
|
||||||
pumpe(0);
|
pumpe(0);
|
||||||
grob(0);
|
grob(0);
|
||||||
fein(0);
|
fein(0);
|
||||||
|
|
||||||
leerBlasen(1);
|
leerBlasen(1);
|
||||||
|
|
||||||
if(leitungBenutzt)
|
if(leitungBenutzt)
|
||||||
{
|
{
|
||||||
int time = 3000 / NACHLAUF;
|
int time = 3000 / NACHLAUF;
|
||||||
|
|
||||||
uint8_t i = 0;
|
uint8_t i = 0;
|
||||||
for(i = 0; i < NACHLAUF; i++)
|
for(i = 0; i < NACHLAUF; i++)
|
||||||
{
|
{
|
||||||
@ -408,8 +396,10 @@ int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
leerBlasen(0);
|
leerBlasen(0);
|
||||||
leerGeblasen = 0;
|
leerGeblasen = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user