make force setpoint adjustable
This commit is contained in:
@@ -148,6 +148,8 @@ void ioHelperEdgeDetector(void);
|
||||
#define BTN_SPULENWECHSEL BitPinK0
|
||||
|
||||
#define BTN_INIT BitPinF4
|
||||
#define BTN_KRAFT_PLUS BitPinD7
|
||||
#define BTN_KRAFT_MINUS BitPinG2
|
||||
|
||||
#define IN_TAENZER_HOME BitPinF0
|
||||
#define IN_SPULE_HOME BitPinF1
|
||||
|
||||
9
main.c
9
main.c
@@ -72,7 +72,7 @@ static void avr_init()
|
||||
}
|
||||
|
||||
void send_info(void){
|
||||
char msg[6];
|
||||
char msg[10];
|
||||
sprintf(msg, "%d", abzug_speed);
|
||||
mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/abzug/speed", msg, strlen(msg));
|
||||
|
||||
@@ -86,11 +86,14 @@ void send_info(void){
|
||||
ltoa(kraftsensor_value, msg, 10);
|
||||
else
|
||||
msg[0] = '0';
|
||||
mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/kraft", msg, strlen(msg));
|
||||
mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/taenzer/pv_kraft", msg, strlen(msg));
|
||||
|
||||
int8_t temp = taenzer_state.pos / 10000;
|
||||
ltoa(temp, msg, 10);
|
||||
mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/speicher/pos", msg, strlen(msg));
|
||||
mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/taenzer/pos", msg, strlen(msg));
|
||||
|
||||
itoa(taenzer_state.force_setpoint, msg, 10);
|
||||
mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/taenzer/sp_kraft", msg, strlen(msg));
|
||||
|
||||
sprintf(msg, "%ld", millis()/1000);
|
||||
mqtt_pub(&mqtt_client, "/Filamentanlage/05_Abzug/state/uptime", msg, strlen(msg));
|
||||
|
||||
29
taenzer.c
29
taenzer.c
@@ -6,11 +6,19 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define TAENZER_KRAFT_SETPOINT 12000
|
||||
#define TAENZER_KRAFT_HYST 1000
|
||||
|
||||
|
||||
taenzer_state_t taenzer_state;
|
||||
|
||||
#define TAENZER_KRAFT_SETPOINT 12000
|
||||
#define TAENZER_KRAFT_HYST 2000
|
||||
taenzer_state_t taenzer_state = {
|
||||
.homed = 0,
|
||||
.pos = 0,
|
||||
.force_setpoint = TAENZER_KRAFT_SETPOINT,
|
||||
};
|
||||
|
||||
void send_info(void);
|
||||
void do_taenzer(){
|
||||
|
||||
/* Homing */
|
||||
@@ -24,9 +32,22 @@ void do_taenzer(){
|
||||
taenzer_state.pos = 0;
|
||||
}
|
||||
|
||||
if (read_Input(BTN_KRAFT_PLUS, RISING)) {
|
||||
taenzer_state.force_setpoint += 1000;
|
||||
#if PLC_MQTT_ENABLED
|
||||
send_info();
|
||||
#endif
|
||||
}
|
||||
if (read_Input(BTN_KRAFT_MINUS, RISING)) {
|
||||
taenzer_state.force_setpoint -= 1000;
|
||||
#if PLC_MQTT_ENABLED
|
||||
send_info();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Force regualtion */
|
||||
if(kraftsensor_valid && taenzer_state.homed){
|
||||
int16_t err = abs(kraftsensor_value - TAENZER_KRAFT_SETPOINT);
|
||||
if(kraftsensor_valid && taenzer_state.homed && taenzer_state.pos >= 0 && taenzer_state.pos < 500000){
|
||||
int16_t err = (kraftsensor_value - taenzer_state.force_setpoint);
|
||||
|
||||
if(err > 8000)
|
||||
err=8000;
|
||||
|
||||
Reference in New Issue
Block a user