|
|
|
@ -76,7 +76,7 @@ static void avr_init()
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void send_abzug_speed(void){
|
|
|
|
void send_info(void){
|
|
|
|
char msg[4];
|
|
|
|
char msg[4];
|
|
|
|
sprintf(msg, "%d", abzug_speed);
|
|
|
|
sprintf(msg, "%d", abzug_speed);
|
|
|
|
mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/abzug/speed", msg, strlen(msg));
|
|
|
|
mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/abzug/speed", msg, strlen(msg));
|
|
|
|
@ -86,8 +86,19 @@ void send_abzug_speed(void){
|
|
|
|
else
|
|
|
|
else
|
|
|
|
sprintf(msg, "False");
|
|
|
|
sprintf(msg, "False");
|
|
|
|
mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/abzug/onoff", msg, strlen(msg));
|
|
|
|
mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/abzug/onoff", msg, strlen(msg));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ltoa(kraftsensor_value, msg, 10);
|
|
|
|
|
|
|
|
mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/kraft", msg, strlen(msg));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ltoa(taenzer_state.pos, msg, 10);
|
|
|
|
|
|
|
|
mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/speicher/pos", msg, strlen(msg));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sprintf(msg, "%ld", millis()/1000);
|
|
|
|
|
|
|
|
mqtt_pub(&mqtt_client, "/Filamentanlage/04_Messmodul/state/uptime", msg, strlen(msg));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// INIT MCU
|
|
|
|
// INIT MCU
|
|
|
|
@ -150,7 +161,7 @@ int main()
|
|
|
|
ioHelperSetBit(outStatesBlinking, LED_PLC_OK, 1);
|
|
|
|
ioHelperSetBit(outStatesBlinking, LED_PLC_OK, 1);
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t timer_blink_outs = millis();
|
|
|
|
uint32_t timer_blink_outs = millis();
|
|
|
|
uint32_t timer_send_uptime = millis();
|
|
|
|
uint32_t timer_send_info = millis();
|
|
|
|
uint32_t timer_modbus_poll = millis();
|
|
|
|
uint32_t timer_modbus_poll = millis();
|
|
|
|
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
while(1)
|
|
|
|
@ -159,7 +170,7 @@ int main()
|
|
|
|
|
|
|
|
|
|
|
|
#if PLC_MQTT_ENABLED
|
|
|
|
#if PLC_MQTT_ENABLED
|
|
|
|
if(millis() < 10)
|
|
|
|
if(millis() < 10)
|
|
|
|
send_abzug_speed();
|
|
|
|
send_info();
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
ioHelperReadPins();
|
|
|
|
ioHelperReadPins();
|
|
|
|
@ -175,27 +186,18 @@ int main()
|
|
|
|
timer_blink_outs = millis();
|
|
|
|
timer_blink_outs = millis();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if PLC_MQTT_ENABLED
|
|
|
|
|
|
|
|
// send misc info
|
|
|
|
|
|
|
|
//if(millis() - timer_send_uptime > 5000){
|
|
|
|
|
|
|
|
// timer_send_uptime += 5000;
|
|
|
|
|
|
|
|
// char msg[64];
|
|
|
|
|
|
|
|
// sprintf(msg, "%ld", millis()/1000);
|
|
|
|
|
|
|
|
// mqtt_pub(&mqtt_client, "/Filamentanlage/04_Messmodul/state/uptime", msg, strlen(msg));
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if(millis() - timer_modbus_poll > 200){
|
|
|
|
if(millis() - timer_modbus_poll > 200){
|
|
|
|
timer_modbus_poll += 200;
|
|
|
|
timer_modbus_poll += 200;
|
|
|
|
do_kraftsensor();
|
|
|
|
do_kraftsensor();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if PLC_MQTT_ENABLED
|
|
|
|
#if PLC_MQTT_ENABLED
|
|
|
|
send_abzug_speed();
|
|
|
|
// send misc info
|
|
|
|
char msg[10];
|
|
|
|
if(millis() - timer_send_info > 200){
|
|
|
|
ltoa(kraftsensor_value, msg, 10);
|
|
|
|
timer_send_info += 200;
|
|
|
|
mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/kraft", msg, strlen(msg));
|
|
|
|
send_info();
|
|
|
|
ltoa(taenzer_state.pos, msg, 10);
|
|
|
|
|
|
|
|
mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/speicher/pos", msg, strlen(msg));
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
do_notaus();
|
|
|
|
do_notaus();
|
|
|
|
do_abzug();
|
|
|
|
do_abzug();
|
|
|
|
|