From 30f1ec733dbe86d9bf98d3af369e0543e67adf11 Mon Sep 17 00:00:00 2001 From: Eggert Jung Date: Fri, 11 Feb 2022 18:17:02 +0100 Subject: [PATCH] uncomment homing and send position --- main.c | 8 ++++++++ taenzer.c | 25 +++++++++++++------------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/main.c b/main.c index 14ade12..e8c967a 100644 --- a/main.c +++ b/main.c @@ -244,6 +244,14 @@ int main() if(millis() - timer_modbus_poll > 1000){ timer_modbus_poll += 1000; do_kraftsensor(); +#if PLC_MQTT_ENABLED + send_abzug_speed(); + char msg[10]; + 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)); +#endif } do_notaus(); diff --git a/taenzer.c b/taenzer.c index 7c88e32..07cdfa8 100644 --- a/taenzer.c +++ b/taenzer.c @@ -8,19 +8,20 @@ taenzer_state_t taenzer_state; void do_taenzer(){ - ///* Homing */ - //if(!taenzer_state.homed){ - // set_Output(MOTOR_TAENZER_DIR, 1); // direction: up - // TCCR4B |= _BV(CS41); //TURN ON - //} - //if(read_Input(IN_TAENZER_HOME, LEVEL)){ - // TCCR4B &= ~_BV(CS41); //TURN OFF - // taenzer_state.homed = 1; - //} + /* Homing */ + if(!taenzer_state.homed){ + set_Output(MOTOR_TAENZER_DIR, 1); // direction: up + TCCR4B |= _BV(CS41); //TURN ON + } + if(read_Input(IN_TAENZER_HOME, LEVEL)){ + TCCR4B &= ~_BV(CS41); //TURN OFF + taenzer_state.homed = 1; + taenzer_state.pos = 0; + } /* Force regualtion */ - if(kraftsensor_valid /* && taenzer_state.homed */){ - if(kraftsensor_value < 0){ + if(kraftsensor_valid && taenzer_state.homed){ + if(kraftsensor_value < 9000){ set_Output(MOTOR_TAENZER_DIR, 0); // direction: down TCCR4B |= _BV(CS41); //TURN ON } @@ -38,7 +39,7 @@ void timer4_init() TCCR4A |= (1<