From 24ef8ce70d5a264b663f1825521b96eb6a66fb2b Mon Sep 17 00:00:00 2001 From: Eggert Jung Date: Thu, 12 Jan 2023 18:03:57 +0100 Subject: [PATCH] add prints --- main.c | 15 ++++++++++----- spule.c | 6 +++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index c3d3e00..a3691ce 100644 --- a/main.c +++ b/main.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -89,6 +90,12 @@ void send_values(void){ itoa((250*60)/ICR5, msg, 10); mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/spule/speed", msg, strlen(msg)); + + sprintf(msg, "%d", windings); + mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/spule/windings", msg, strlen(msg)); + + sprintf(msg, "%ld", spule_trans_pos); + mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/spule/trans_pos", msg, strlen(msg)); } // send settings wich only change on buttion press @@ -96,8 +103,6 @@ void send_settings(void){ //TODO only send on change or improve performance otherwise char msg[10]; - //PORTH &= ~(1<<5); - //PORTH |= (1<<5); /* Abzug */ sprintf(msg, "%d", abzug_speed); mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/abzug/speed", msg, strlen(msg)); @@ -196,7 +201,7 @@ int main() set_Output(LED_FEHLER, OFF); - set_Output(BitPH5, ON); + set_Output(BitPH5, ON); //DEBUG #if PLC_MQTT_ENABLED send_settings(); @@ -220,7 +225,7 @@ int main() } if(millis() - timer_modbus_poll > 20){ - do_kraftsensor(); + do_kraftsensor(); // 8ms !!! timer_modbus_poll += 20; } @@ -228,7 +233,7 @@ int main() // send misc info if(millis() - timer_send_info > 200){ timer_send_info += 200; - send_values(); + send_values(); // 10ms //send_info(); // 27ms every 200ms } #endif diff --git a/spule.c b/spule.c index 90dceda..1b5d634 100644 --- a/spule.c +++ b/spule.c @@ -175,7 +175,8 @@ ISR(TIMER5_OVF_vect) { windings++; steps=0; printf("windungen: %d\t", windings); - printf("trans pos: %ld\n", taenzer_state.pos); + printf("trans pos: %ld\n", spule_trans_pos); + printf("speed %d\n", ICR1); } if(windings == windings_wakeup){ @@ -190,6 +191,7 @@ ISR(TIMER5_OVF_vect) { OCR1A = ICR1/2; set_Output(MOTOR_TRANS_DIR, TOGGLE); printf("toggle at pos: %ld\n", spule_trans_pos); + printf("speed %d\n", ICR1); } if(windings_on_layer == 1 && steps == 0){ trans_state = 2; @@ -200,12 +202,14 @@ ISR(TIMER5_OVF_vect) { trans_state = 3; TCCR1B |= _BV(CS11); printf("done\n"); + printf("speed %d\n", ICR1); } if(windings_on_layer == 21 && steps == 0){ trans_state = 4; ICR1 = 0.5*(ICR5/TRANS_ROT_FACTOR); OCR1A = ICR1/2; printf("nachlauf abbauen\n"); + printf("speed %d\n", ICR1); } //;PORTH |= (1<<5); }