|
|
|
|
@ -112,39 +112,6 @@ void do_notaus(){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//void do_notaus(){
|
|
|
|
|
// if(read_Input(IN_NOTAUS_ANLAGE, LEVEL) || read_Input(IN_NOTAUS_SCHRANK, LEVEL)){ // NOTAUS
|
|
|
|
|
// set_Output(LED_GRN_NOTAUS_SCHRANK, OFF); // disable green lamps
|
|
|
|
|
// set_Output(LED_GRN_NOTAUS_ANLAGE, OFF);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if(read_Input(IN_NOTAUS_ANLAGE, LEVEL) && read_Input(IN_NOTAUS_SCHRANK, LEVEL)){ // both activated
|
|
|
|
|
// set_Output(LED_ROT_NOTAUS_ANLAGE, BLINK);
|
|
|
|
|
// set_Output(LED_ROT_NOTAUS_SCHRANK, BLINK);
|
|
|
|
|
// }
|
|
|
|
|
// else if(read_Input(IN_NOTAUS_ANLAGE, LEVEL)){ // top one activated
|
|
|
|
|
// set_Output(LED_ROT_NOTAUS_ANLAGE, BLINK);
|
|
|
|
|
// set_Output(LED_ROT_NOTAUS_SCHRANK, ON);
|
|
|
|
|
// }
|
|
|
|
|
// else if(read_Input(IN_NOTAUS_SCHRANK, LEVEL)){ // bottom one activated
|
|
|
|
|
// set_Output(LED_ROT_NOTAUS_SCHRANK, BLINK);
|
|
|
|
|
// set_Output(LED_ROT_NOTAUS_ANLAGE, ON);
|
|
|
|
|
// }
|
|
|
|
|
// else{ // none activated
|
|
|
|
|
// set_Output(LED_ROT_NOTAUS_SCHRANK, OFF);
|
|
|
|
|
// set_Output(LED_ROT_NOTAUS_ANLAGE, OFF);
|
|
|
|
|
// if(!read_Input(IN_ANLAGE_EIN_INV, LEVEL)){
|
|
|
|
|
// set_Output(LED_GRN_NOTAUS_ANLAGE, ON);
|
|
|
|
|
// set_Output(LED_GRN_NOTAUS_SCHRANK, ON);
|
|
|
|
|
// }
|
|
|
|
|
// else{
|
|
|
|
|
// set_Output(LED_GRN_NOTAUS_ANLAGE, ON);
|
|
|
|
|
// set_Output(LED_GRN_NOTAUS_SCHRANK, ON);
|
|
|
|
|
// set_Output(LED_ROT_NOTAUS_ANLAGE, ON);
|
|
|
|
|
// set_Output(LED_ROT_NOTAUS_SCHRANK, ON);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
void send_temperatures(void){
|
|
|
|
|
for(uint8_t i=0; i<sizeof(ADC_reading)/sizeof(ADC_reading[0]);i++){
|
|
|
|
|
@ -201,28 +168,19 @@ int main()
|
|
|
|
|
printf("--MQTT Connected ERROR: %ld\r\n", mqtt_rc);
|
|
|
|
|
while(1); //Reboot the board
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//// Subscribe to all topics
|
|
|
|
|
//char SubString[] = "/Filamentanlage/02_Wasserbecken/#";
|
|
|
|
|
////char SubString[] = "/Filamentanlage/03_Wasserbecken/#";
|
|
|
|
|
//mqtt_rc = MQTTSubscribe(&mqtt_client, SubString, QOS0, messageArrived);
|
|
|
|
|
//printf("Subscribed (%s) %ld\r\n", SubString, mqtt_rc);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ioHelperSetBit(outStatesBlinking, LED_PLC_OK, 1);
|
|
|
|
|
//ioHelperSetBit(outStatesBlinking, OUT_VENTIL_ABLASS, 1);
|
|
|
|
|
//ioHelperSetBit(outStatesBlinking, OUT_VENTIL_PUMPE, 1);
|
|
|
|
|
|
|
|
|
|
set_Output(LED_PLC_OK, BLINK);
|
|
|
|
|
|
|
|
|
|
uint32_t timer_blink_outs = millis();
|
|
|
|
|
uint32_t timer_send_uptime = millis();
|
|
|
|
|
uint32_t timer_send_temps = millis();
|
|
|
|
|
uint32_t timer_gtf_comm = millis();
|
|
|
|
|
|
|
|
|
|
printf("anlage: %x\n\r", read_Input(IN_ANLAGE_EIN_INV, LEVEL));
|
|
|
|
|
send_value(&mqtt_client, "/Filamentanlage/02_Wasserbecken/connected", 1);
|
|
|
|
|
send_value(&mqtt_client, "/Filamentanlage/02_Wasserbecken/state/pumpe_warm", -1);
|
|
|
|
|
|
|
|
|
|
send_value(&mqtt_client, "/Filamentanlage/02_Wasserbecken/state/pumpe_warm", 0);
|
|
|
|
|
send_value(&mqtt_client, "/Filamentanlage/02_Wasserbecken/state/heizung", 0);
|
|
|
|
|
send_value_fl(&mqtt_client, "/Filamentanlage/02_Wasserbecken/state/heizung_sp", heizung_setpoint, 0);
|
|
|
|
|
|
|
|
|
|
gtf_init(5);
|
|
|
|
|
gtf_init(6);
|
|
|
|
|
@ -248,14 +206,6 @@ int main()
|
|
|
|
|
if(millis() - timer_send_temps > 5000){
|
|
|
|
|
timer_send_temps = millis();
|
|
|
|
|
send_temperatures();
|
|
|
|
|
//printf("gefran firm: 0x%02X\n", gtf_firmware_version(5));
|
|
|
|
|
printf("gefran 5 OuP: 0x%02X\n", gtf_read_register(5, GTF_OuP));
|
|
|
|
|
printf("gefran 6 OuP: 0x%02X\n", gtf_read_register(6, GTF_OuP));
|
|
|
|
|
printf("gefran 7 OuP: 0x%02X\n", gtf_read_register(7, GTF_OuP));
|
|
|
|
|
//printf("gefran stat3: 0x%02X\n", gtf_read_register(5, 117));
|
|
|
|
|
////printf("gefran stell: 0x%02X\n", gtf_read_register(5, 56));
|
|
|
|
|
////printf("gefran disp: 0x%02X\n", gtf_read_register(5, 0));
|
|
|
|
|
//printf("gefran coil: 0x%02X\n", gtf_read_coil(5, 0));
|
|
|
|
|
|
|
|
|
|
//send_value(&mqtt_client, "/Filamentanlage/02_Wasserbecken/state/gtf5_power", gtf_read_register(5, GTF_POWER));
|
|
|
|
|
|
|
|
|
|
@ -271,6 +221,11 @@ int main()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(millis() - timer_gtf_comm > 200){
|
|
|
|
|
timer_gtf_comm = millis();
|
|
|
|
|
comm_heizung();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// send misc info
|
|
|
|
|
if(millis() - timer_send_uptime > 5000){
|
|
|
|
|
timer_send_uptime = millis();
|
|
|
|
|
@ -281,12 +236,14 @@ int main()
|
|
|
|
|
do_notaus();
|
|
|
|
|
do_heizung();
|
|
|
|
|
|
|
|
|
|
#if PLC_MQTT_ENABLED
|
|
|
|
|
ioHelperSetBit(outStates, LED_BUS_OK, 1);
|
|
|
|
|
ioHelperSetOuts();
|
|
|
|
|
#if PLC_MQTT_ENABLED
|
|
|
|
|
MQTTYield(&mqtt_client, 10); //blocking call
|
|
|
|
|
ioHelperSetBit(outStates, LED_BUS_OK, 0);
|
|
|
|
|
#else
|
|
|
|
|
_delay_ms(1);
|
|
|
|
|
#endif
|
|
|
|
|
ioHelperSetBit(outStates, LED_BUS_OK, 0);
|
|
|
|
|
ioHelperSetOuts();
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
|