diff --git a/main.c b/main.c index 2f716ae..14ade12 100644 --- a/main.c +++ b/main.c @@ -2,6 +2,9 @@ #include #include // WatchDog #include +#include + +#include "common.h" #include "Ethernet/socket.h" #include "Ethernet/wizchip_conf.h" @@ -17,10 +20,9 @@ #include "util/delay.h" -#include "modbus.h" -#include "modbus_master.h" - -#define PLC_MQTT_ENABLED 1 +#include "kraftsensor.h" +#include "taenzer.h" +#include "abzug.h" Client mqtt_client; @@ -57,12 +59,6 @@ void IO_LIBRARY_Init(void) { //wizchip_setinterruptmask(IK_SOCK_0); } -void modbus_master_init(){ - modbusSetAddress(1); //better set this to sth. - modbusInit(); - timer2_init(); // modbus tick timer -} - static void avr_init() { // Initialize device here. @@ -79,22 +75,16 @@ static void avr_init() return; } -void do_kraftsensor(){ - uint16_t m_data[4]; - char msg[64]; - - readReg(1,0,2); - if(wait_receive(2, m_data, 10)) - sprintf(msg, "n/a"); - else{ - int32_t tmp = (uint32_t)m_data[0]<<16; - tmp |= m_data[1]; - sprintf(msg, "%ld", tmp); - } +void send_abzug_speed(void){ + char msg[4]; + sprintf(msg, "%d", abzug_speed); + mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/abzug/speed", msg, strlen(msg)); -#if PLC_MQTT_ENABLED - mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/kraft", msg, strlen(msg)); -#endif + if(TCCR3B & (1<