Compare commits
54 Commits
b31b5cd6c4
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 5bc9206bc0 | |||
| e010d1de02 | |||
| 5a08029bad | |||
| 3e410de064 | |||
| dcc9ef6801 | |||
| ee7194d439 | |||
| 1bc44a8dc8 | |||
| aca293eb6a | |||
| 88ba988c1e | |||
| 705dcaa9a9 | |||
| d4533ea54c | |||
| 2563626def | |||
| bff7daff82 | |||
| d1f32f1719 | |||
| 2afb5fa266 | |||
| 75a1f05dc8 | |||
| 7a077b4879 | |||
| 3fe31f6bf0 | |||
| 4df758ccf1 | |||
| b12a416110 | |||
| 897bb59e01 | |||
| 5685eebe2c | |||
| f2ed9c9724 | |||
| db17fbc1d9 | |||
| 451cd9bc68 | |||
| f8d788d92e | |||
| b1ceb7c913 | |||
| ac2180b041 | |||
| 729bf18aec | |||
| 6013acc226 | |||
| 945e088667 | |||
| 8269b5112f | |||
| 582bdec6c5 | |||
| 74c7746142 | |||
| 1a1f228b69 | |||
| a099481b3e | |||
| ffce232d47 | |||
| 87d012086b | |||
| 7456e7f02a | |||
| 9dbe3e1f5d | |||
| c8d8118d98 | |||
| 4b093e86de | |||
| 083767f626 | |||
| b081c33748 | |||
| eae3d4bae1 | |||
| 5531952667 | |||
| 48d347fb06 | |||
| be2a4a8c24 | |||
| 8efc607e03 | |||
| 6e717027c6 | |||
| 8686a8ef19 | |||
| deb7f54bfb | |||
| 678357b838 | |||
| bcb45f3174 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
.venv/
|
.venv/
|
||||||
|
*.csv
|
||||||
91
Beispiel Kennlinien/01_sinus.txt
Normal file
91
Beispiel Kennlinien/01_sinus.txt
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
0;10.0
|
||||||
|
1;10.7
|
||||||
|
2;11.4
|
||||||
|
3;12.0
|
||||||
|
4;12.6
|
||||||
|
5;13.2
|
||||||
|
6;13.7
|
||||||
|
7;14.1
|
||||||
|
8;14.5
|
||||||
|
9;14.8
|
||||||
|
10;14.9
|
||||||
|
11;15.0
|
||||||
|
12;15.0
|
||||||
|
13;14.9
|
||||||
|
14;14.6
|
||||||
|
15;14.3
|
||||||
|
16;13.9
|
||||||
|
17;13.5
|
||||||
|
18;12.9
|
||||||
|
19;12.3
|
||||||
|
20;11.7
|
||||||
|
21;11.0
|
||||||
|
22;10.3
|
||||||
|
23;9.7
|
||||||
|
24;9.0
|
||||||
|
25;8.3
|
||||||
|
26;7.7
|
||||||
|
27;7.1
|
||||||
|
28;6.5
|
||||||
|
29;6.1
|
||||||
|
30;5.7
|
||||||
|
31;5.4
|
||||||
|
32;5.1
|
||||||
|
33;5.0
|
||||||
|
34;5.0
|
||||||
|
35;5.1
|
||||||
|
36;5.2
|
||||||
|
37;5.5
|
||||||
|
38;5.9
|
||||||
|
39;6.3
|
||||||
|
40;6.8
|
||||||
|
41;7.4
|
||||||
|
42;8.0
|
||||||
|
43;8.6
|
||||||
|
44;9.3
|
||||||
|
45;10.0
|
||||||
|
46;10.7
|
||||||
|
47;11.4
|
||||||
|
48;12.0
|
||||||
|
49;12.6
|
||||||
|
50;13.2
|
||||||
|
51;13.7
|
||||||
|
52;14.1
|
||||||
|
53;14.5
|
||||||
|
54;14.8
|
||||||
|
55;14.9
|
||||||
|
56;15.0
|
||||||
|
57;15.0
|
||||||
|
58;14.9
|
||||||
|
59;14.6
|
||||||
|
60;14.3
|
||||||
|
61;13.9
|
||||||
|
62;13.5
|
||||||
|
63;12.9
|
||||||
|
64;12.3
|
||||||
|
65;11.7
|
||||||
|
66;11.0
|
||||||
|
67;10.3
|
||||||
|
68;9.7
|
||||||
|
69;9.0
|
||||||
|
70;8.3
|
||||||
|
71;7.7
|
||||||
|
72;7.1
|
||||||
|
73;6.5
|
||||||
|
74;6.1
|
||||||
|
75;5.7
|
||||||
|
76;5.4
|
||||||
|
77;5.1
|
||||||
|
78;5.0
|
||||||
|
79;5.0
|
||||||
|
80;5.1
|
||||||
|
81;5.2
|
||||||
|
82;5.5
|
||||||
|
83;5.9
|
||||||
|
84;6.3
|
||||||
|
85;6.8
|
||||||
|
86;7.4
|
||||||
|
87;8.0
|
||||||
|
88;8.6
|
||||||
|
89;9.3
|
||||||
|
90;10.0
|
||||||
30
Beispiel Kennlinien/02_sprungantworten.txt
Normal file
30
Beispiel Kennlinien/02_sprungantworten.txt
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
0;0
|
||||||
|
4.9;0
|
||||||
|
5;5
|
||||||
|
9.9;5
|
||||||
|
10;7
|
||||||
|
14.9;7
|
||||||
|
15;10
|
||||||
|
19.9;10
|
||||||
|
20;12
|
||||||
|
24.9;12
|
||||||
|
25;15
|
||||||
|
29.9;15
|
||||||
|
30;17
|
||||||
|
34.9;17
|
||||||
|
35;15
|
||||||
|
39.9;15
|
||||||
|
40;12
|
||||||
|
44.9;12
|
||||||
|
45;10
|
||||||
|
49.9;10
|
||||||
|
50;7
|
||||||
|
54.9;7
|
||||||
|
55;5
|
||||||
|
59.9;5
|
||||||
|
60;0
|
||||||
|
69.9;0
|
||||||
|
70;15
|
||||||
|
79.9;15
|
||||||
|
80;0
|
||||||
|
90;0
|
||||||
@@ -1 +1,5 @@
|
|||||||
# GUI zur T2000
|
# GUI zur T2000
|
||||||
|
## Installation unter Linux
|
||||||
|
~~~
|
||||||
|
curl -s https://gitea.msb24.duckdns.org/musabe24/t2000_gui/raw/branch/main/installer.sh | bash
|
||||||
|
~~~
|
||||||
15
conf.txt
15
conf.txt
@@ -1,15 +1,10 @@
|
|||||||
227C-024-15 PID_Regler 1{
|
227C-024-15{
|
||||||
Kp:0.068
|
|
||||||
Ki:0.03
|
|
||||||
Kd:0.00
|
|
||||||
}
|
|
||||||
227C-024-15 PID_Regler 2{
|
|
||||||
Kp:0.11
|
Kp:0.11
|
||||||
Ki:0.08
|
Ki:0.09
|
||||||
Kd:0.00
|
Kd:0.00
|
||||||
}
|
}
|
||||||
227C-024-15 I-Regler{
|
328CS-024-10{
|
||||||
Kp:0.00
|
Kp:0.3
|
||||||
Ki:0.02
|
Ki:1.0
|
||||||
Kd:0.00
|
Kd:0.00
|
||||||
}
|
}
|
||||||
7
installer.sh
Normal file
7
installer.sh
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
sudo apt-get install python3-tk -y
|
||||||
|
cd ~
|
||||||
|
git clone https://gitea.msb24.duckdns.org/musabe24/t2000_gui.git
|
||||||
|
cd t2000_gui
|
||||||
|
python3 -m venv .venv
|
||||||
|
.venv/bin/pip install -r requirements.txt
|
||||||
168
main.py
168
main.py
@@ -1,5 +1,5 @@
|
|||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from tkinter import ttk, messagebox
|
from tkinter import ttk, messagebox, PhotoImage, simpledialog
|
||||||
import customtkinter
|
import customtkinter
|
||||||
customtkinter.set_appearance_mode("light")
|
customtkinter.set_appearance_mode("light")
|
||||||
customtkinter.set_default_color_theme("blue")
|
customtkinter.set_default_color_theme("blue")
|
||||||
@@ -11,6 +11,8 @@ import threading
|
|||||||
import time
|
import time
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import csv
|
import csv
|
||||||
|
import os
|
||||||
|
from PIL import Image, ImageTk
|
||||||
|
|
||||||
class ArduinoGUI:
|
class ArduinoGUI:
|
||||||
def __init__(self, root):
|
def __init__(self, root):
|
||||||
@@ -19,6 +21,8 @@ class ArduinoGUI:
|
|||||||
self.root.title("PRG 342 GUI")
|
self.root.title("PRG 342 GUI")
|
||||||
self.root.attributes('-fullscreen', True) # Setzt das Fenster in den Vollbildmodus
|
self.root.attributes('-fullscreen', True) # Setzt das Fenster in den Vollbildmodus
|
||||||
|
|
||||||
|
self.ser = None
|
||||||
|
|
||||||
self.arduino = None
|
self.arduino = None
|
||||||
self.ports = list(serial.tools.list_ports.comports())
|
self.ports = list(serial.tools.list_ports.comports())
|
||||||
self.running = True
|
self.running = True
|
||||||
@@ -78,75 +82,88 @@ class ArduinoGUI:
|
|||||||
|
|
||||||
def create_widgets(self):
|
def create_widgets(self):
|
||||||
|
|
||||||
|
# Laden und Skalieren des Logos
|
||||||
|
original_image = Image.open("src/logo1.png")
|
||||||
|
resized_image = original_image.resize((500, 121), Image.LANCZOS) # Passen Sie die Größe (200, 100) nach Bedarf an
|
||||||
|
self.logo_image = ImageTk.PhotoImage(resized_image)
|
||||||
|
# Logo anstelle des Platzhalters
|
||||||
|
self.logo_label = customtkinter.CTkLabel(self.root, image=self.logo_image, text="")
|
||||||
|
self.logo_label.image = self.logo_image # Referenz behalten, um Garbage Collection zu verhindern
|
||||||
|
self.logo_label.grid(row=0, column=0, columnspan=3, padx=(10, 5), pady=(10, 0), sticky="w")
|
||||||
|
|
||||||
|
# Placeholer
|
||||||
|
self.placeholer = customtkinter.CTkLabel(self.root, text="")
|
||||||
|
self.placeholer.grid(row=1, column=0, padx=(10, 5), pady=(10, 0), sticky="w")
|
||||||
|
|
||||||
# Labels and ComboBox for Stellantriebstyp
|
# Labels and ComboBox for Stellantriebstyp
|
||||||
self.stellantriebstyp_label = customtkinter.CTkLabel(self.root, text="Stellantriebstyp:", font=self.my_font)
|
self.stellantriebstyp_label = customtkinter.CTkLabel(self.root, text="Stellantriebstyp:", font=self.my_font)
|
||||||
self.stellantriebstyp_label.grid(row=0, column=0, padx=(10, 5), pady=(10, 0), sticky="w")
|
self.stellantriebstyp_label.grid(row=3, column=0, padx=(10, 5), pady=(10, 0), sticky="w")
|
||||||
|
|
||||||
self.config_combobox_value = customtkinter.StringVar()
|
self.config_combobox_value = customtkinter.StringVar()
|
||||||
self.config_combobox = customtkinter.CTkComboBox(self.root, variable=self.config_combobox_value, state="readonly", font=self.my_font)
|
self.config_combobox = customtkinter.CTkComboBox(self.root, variable=self.config_combobox_value, state="readonly", font=self.my_font)
|
||||||
self.config_combobox.grid(row=0, column=1, columnspan=1, padx=(0, 10), pady=(10, 0), sticky="ew")
|
self.config_combobox.grid(row=3, column=1, columnspan=1, padx=(0, 10), pady=(10, 0), sticky="ew")
|
||||||
#self.config_combobox.bind("<<ComboboxSelected>>", self.on_config_selected)
|
#self.config_combobox.bind("<<ComboboxSelected>>", self.on_config_selected)
|
||||||
|
|
||||||
# Setzen Button für Stellantriebstyp
|
# Setzen Button für Stellantriebstyp
|
||||||
self.set_pid_button = customtkinter.CTkButton(self.root, text="Setzen", command=self.set_pid_parameters, font=self.my_font)
|
self.set_pid_button = customtkinter.CTkButton(self.root, text="Setzen", command=self.set_pid_parameters, font=self.my_font)
|
||||||
self.set_pid_button.grid(row=0, column=2, padx=(0, 10), pady=(10, 0), sticky="ew")
|
self.set_pid_button.grid(row=3, column=2, padx=(0, 10), pady=(10, 0), sticky="ew")
|
||||||
|
|
||||||
# Labels and ComboBox for COM Port
|
# Labels and ComboBox for COM Port
|
||||||
self.com_label = customtkinter.CTkLabel(self.root, text="COM Port:", font=self.my_font)
|
self.com_label = customtkinter.CTkLabel(self.root, text="COM Port:", font=self.my_font)
|
||||||
self.com_label.grid(row=1, column=0, padx=(10, 5), pady=(10, 0), sticky="w")
|
self.com_label.grid(row=2, column=0, padx=(10, 5), pady=(10, 0), sticky="w")
|
||||||
|
|
||||||
self.combobox_value = customtkinter.StringVar()
|
self.combobox_value = customtkinter.StringVar()
|
||||||
self.combobox = customtkinter.CTkComboBox(self.root, variable=self.combobox_value, font=self.my_font)
|
self.combobox = customtkinter.CTkComboBox(self.root, variable=self.combobox_value, font=self.my_font)
|
||||||
self.combobox.configure(values=[port.device for port in self.ports])
|
self.combobox.configure(values=[port.device for port in self.ports])
|
||||||
self.combobox.grid(row=1, column=1, padx=(0, 10), pady=(10, 0), sticky="ew")
|
self.combobox.grid(row=2, column=1, padx=(0, 10), pady=(10, 0), sticky="ew")
|
||||||
|
|
||||||
self.connect_button = customtkinter.CTkButton(self.root, text="Verbinden", command=self.connect_arduino, font=self.my_font)
|
self.connect_button = customtkinter.CTkButton(self.root, text="Verbinden", command=self.connect_arduino, font=self.my_font)
|
||||||
self.connect_button.grid(row=1, column=2, padx=(0, 10), pady=(10, 0), sticky="ew")
|
self.connect_button.grid(row=2, column=2, padx=(0, 10), pady=(10, 0), sticky="ew")
|
||||||
|
|
||||||
# Setpoint entry
|
# Setpoint entry
|
||||||
self.setpoint_label = customtkinter.CTkLabel(self.root, text="Sollwerteingabe in Nm:", font=self.my_font)
|
self.setpoint_label = customtkinter.CTkLabel(self.root, text="Sollwerteingabe in Nm:", font=self.my_font)
|
||||||
self.setpoint_label.grid(row=2, column=0, padx=(10, 5), pady=(10, 0), sticky="w")
|
self.setpoint_label.grid(row=4, column=0, padx=(10, 5), pady=(10, 0), sticky="w")
|
||||||
|
|
||||||
self.setpoint_entry = customtkinter.CTkEntry(self.root, font=self.my_font)
|
self.setpoint_entry = customtkinter.CTkEntry(self.root, font=self.my_font)
|
||||||
self.setpoint_entry.grid(row=2, column=1, padx=(0, 10), pady=(10, 0), sticky="ew")
|
self.setpoint_entry.grid(row=4, column=1, padx=(0, 10), pady=(10, 0), sticky="ew")
|
||||||
|
|
||||||
self.set_setpoint_button = customtkinter.CTkButton(self.root, text="Setzen", command=self.set_setpoint, font=self.my_font)
|
self.set_setpoint_button = customtkinter.CTkButton(self.root, text="Setzen", command=self.set_setpoint, font=self.my_font)
|
||||||
self.set_setpoint_button.grid(row=2, column=2, padx=(0, 10), pady=(10, 0), sticky="ew")
|
self.set_setpoint_button.grid(row=4, column=2, padx=(0, 10), pady=(10, 0), sticky="ew")
|
||||||
|
|
||||||
# Multi Setpoints Textbox and Button
|
# Multi Setpoints Textbox and Button
|
||||||
self.multi_setpoints_label = customtkinter.CTkLabel(self.root, text="Sollwerteeingabe\n(Winkel;Drehmoment):", font=self.my_font)
|
self.multi_setpoints_label = customtkinter.CTkLabel(self.root, text="Sollwerteeingabe\n(Winkel;Drehmoment):", font=self.my_font)
|
||||||
self.multi_setpoints_label.grid(row=3, column=0, padx=(10, 5), pady=(10, 0), sticky="w")
|
self.multi_setpoints_label.grid(row=5, column=0, padx=(10, 5), pady=(10, 0), sticky="w")
|
||||||
|
|
||||||
self.multi_setpoints_text = customtkinter.CTkTextbox(self.root, font=self.my_font)
|
self.multi_setpoints_text = customtkinter.CTkTextbox(self.root, font=self.my_font)
|
||||||
self.multi_setpoints_text.grid(row=3, column=1, padx=(0, 10), pady=(10, 0), sticky="ew")
|
self.multi_setpoints_text.grid(row=5, column=1, padx=(0, 10), pady=(10, 0), sticky="ew")
|
||||||
|
|
||||||
self.send_multi_setpoints_button = customtkinter.CTkButton(self.root, text="Sollwerte senden", command=self.send_multi_setpoints, font=self.my_font)
|
self.send_multi_setpoints_button = customtkinter.CTkButton(self.root, text="Sollwerte senden", command=self.send_multi_setpoints, font=self.my_font)
|
||||||
self.send_multi_setpoints_button.grid(row=3, column=2, padx=(0, 10), pady=(10, 0), sticky="ew")
|
self.send_multi_setpoints_button.grid(row=5, column=2, padx=(0, 10), pady=(10, 0), sticky="ew")
|
||||||
|
|
||||||
# Analog Control CheckBox
|
# Analog Control CheckBox
|
||||||
self.checkbox_var = customtkinter.IntVar()
|
self.checkbox_var = customtkinter.IntVar()
|
||||||
self.checkbox = customtkinter.CTkCheckBox(self.root, text="Analogsteuerung", variable=self.checkbox_var, command=self.input_source_Switch, font=self.my_font)
|
self.checkbox = customtkinter.CTkCheckBox(self.root, text="Analogsteuerung", variable=self.checkbox_var, command=self.input_source_Switch, font=self.my_font)
|
||||||
self.checkbox.grid(row=4, column=0, columnspan=3, padx=(10, 10), pady=(10, 0), sticky="w")
|
self.checkbox.grid(row=6, column=0, columnspan=3, padx=(10, 10), pady=(10, 0), sticky="w")
|
||||||
|
|
||||||
# Tare and Demagnetize Buttons
|
# Tare and Demagnetize Buttons
|
||||||
self.tare_button = customtkinter.CTkButton(self.root, text="Drehwinkel tarieren", command=self.tare_angle, font=self.my_font)
|
self.tare_button = customtkinter.CTkButton(self.root, text="Drehwinkel tarieren", command=self.tare_angle, font=self.my_font)
|
||||||
self.tare_button.grid(row=5, column=0, padx=(10, 5), pady=(10, 0), sticky="sew")
|
self.tare_button.grid(row=7, column=0, padx=(10, 5), pady=(10, 0), sticky="sew")
|
||||||
|
|
||||||
self.demag_button = customtkinter.CTkButton(self.root, text="Manuelle Entmagnetisierung", command=self.demagnetize, font=self.my_font)
|
self.demag_button = customtkinter.CTkButton(self.root, text="Manuelle Entmagnetisierung", command=self.demagnetize, font=self.my_font)
|
||||||
self.demag_button.grid(row=5, column=1, padx=(0, 5), pady=(10, 0), sticky="sew")
|
self.demag_button.grid(row=7, column=1, padx=(0, 5), pady=(10, 0), sticky="sew")
|
||||||
|
|
||||||
# Exit Button
|
# Exit Button
|
||||||
self.exit_button = customtkinter.CTkButton(self.root, text="Beenden", command=self.on_closing, font=self.my_font)
|
self.exit_button = customtkinter.CTkButton(self.root, text="Beenden", command=self.on_closing, font=self.my_font)
|
||||||
self.exit_button.grid(row=5, column=2, padx=(0, 10), pady=(10, 0), sticky="sew")
|
self.exit_button.grid(row=7, column=2, padx=(0, 10), pady=(10, 0), sticky="sew")
|
||||||
|
|
||||||
#Datalogger
|
#Datalogger
|
||||||
self.datalogger_button = customtkinter.CTkButton(self.root, text="Datenlogger", command=self.toggle_datalogger, font=self.my_font)
|
self.datalogger_button = customtkinter.CTkButton(self.root, text="Datenlogger", command=self.toggle_datalogger, font=self.my_font)
|
||||||
self.datalogger_button.grid(row=4, column=0, padx=(0, 10), pady=(10, 0), sticky="sew")
|
self.datalogger_button.grid(row=6, column=2, padx=(0, 10), pady=(10, 0), sticky="sew")
|
||||||
|
|
||||||
# Plot
|
# Plot
|
||||||
self.figure, self.ax = plt.subplots()
|
self.figure, self.ax = plt.subplots()
|
||||||
self.canvas = FigureCanvasTkAgg(self.figure, self.root)
|
self.canvas = FigureCanvasTkAgg(self.figure, self.root)
|
||||||
self.canvas.get_tk_widget().grid(row=0, column=3, rowspan=6, columnspan=4, padx=(10, 10), pady=(10, 0), sticky="nsew")
|
self.canvas.get_tk_widget().grid(row=0, column=3, rowspan=8, columnspan=4, padx=(10, 10), pady=(10, 0), sticky="nsew")
|
||||||
|
|
||||||
self.ax.set_title("Drehmoment-Drehwinkel-Kennlinie")
|
self.ax.set_title("Drehmoment-Drehwinkel-Kennlinie")
|
||||||
self.ax.set_xlabel("Winkel (°)")
|
self.ax.set_xlabel("Winkel (°)")
|
||||||
@@ -158,26 +175,28 @@ class ArduinoGUI:
|
|||||||
self.current_angle = 0
|
self.current_angle = 0
|
||||||
self.current_torque = 0
|
self.current_torque = 0
|
||||||
self.analogInput = 0
|
self.analogInput = 0
|
||||||
|
self.currentSetpoint = 0
|
||||||
|
self.currentOutput = 0
|
||||||
|
|
||||||
self.angle_label_var = customtkinter.StringVar()
|
self.angle_label_var = customtkinter.StringVar()
|
||||||
self.angle_label_var.set("Drehwinkel: 0")
|
self.angle_label_var.set("Drehwinkel: 0")
|
||||||
self.angle_label = customtkinter.CTkLabel(self.root, textvariable=self.angle_label_var, font=self.my_font)
|
self.angle_label = customtkinter.CTkLabel(self.root, textvariable=self.angle_label_var, font=self.my_font)
|
||||||
self.angle_label.grid(row=6, column=3, padx=(10, 5), pady=(10, 0), sticky="sw")
|
self.angle_label.grid(row=8, column=3, padx=(10, 5), pady=(10, 0), sticky="sw")
|
||||||
|
|
||||||
self.torque_label_var = customtkinter.StringVar()
|
self.torque_label_var = customtkinter.StringVar()
|
||||||
self.torque_label_var.set("Istwert: 0")
|
self.torque_label_var.set("Istwert: 0")
|
||||||
self.torque_label = customtkinter.CTkLabel(self.root, textvariable=self.torque_label_var, font=self.my_font)
|
self.torque_label = customtkinter.CTkLabel(self.root, textvariable=self.torque_label_var, font=self.my_font)
|
||||||
self.torque_label.grid(row=6, column=4, padx=(10, 5), pady=(10, 0), sticky="sw")
|
self.torque_label.grid(row=8, column=4, padx=(10, 5), pady=(10, 0), sticky="sw")
|
||||||
|
|
||||||
self.analogread_label_var = customtkinter.StringVar()
|
self.analogread_label_var = customtkinter.StringVar()
|
||||||
self.analogread_label_var.set("Analogeingang: 0")
|
self.analogread_label_var.set("Analogeingang: 0")
|
||||||
self.analogread_label = customtkinter.CTkLabel(self.root, textvariable=self.analogread_label_var, font=self.my_font)
|
self.analogread_label = customtkinter.CTkLabel(self.root, textvariable=self.analogread_label_var, font=self.my_font)
|
||||||
self.analogread_label.grid(row=6, column=5, padx=(10, 5), pady=(10, 0), sticky="sw")
|
self.analogread_label.grid(row=8, column=5, padx=(10, 5), pady=(10, 0), sticky="sw")
|
||||||
|
|
||||||
self.currentSetpoint_label_var = customtkinter.StringVar()
|
self.currentSetpoint_label_var = customtkinter.StringVar()
|
||||||
self.currentSetpoint_label_var.set("Aktueller Sollwert: 0")
|
self.currentSetpoint_label_var.set("Aktueller Sollwert: 0")
|
||||||
self.currentSetpoint_label = customtkinter.CTkLabel(self.root, textvariable=self.currentSetpoint_label_var, font=self.my_font)
|
self.currentSetpoint_label = customtkinter.CTkLabel(self.root, textvariable=self.currentSetpoint_label_var, font=self.my_font)
|
||||||
self.currentSetpoint_label.grid(row=6, column=6, padx=(10, 5), pady=(10, 0), sticky="sw")
|
self.currentSetpoint_label.grid(row=8, column=6, padx=(10, 5), pady=(10, 0), sticky="sw")
|
||||||
|
|
||||||
self.root.grid_columnconfigure(0, weight=0)
|
self.root.grid_columnconfigure(0, weight=0)
|
||||||
self.root.grid_columnconfigure(1, weight=0)
|
self.root.grid_columnconfigure(1, weight=0)
|
||||||
@@ -191,8 +210,11 @@ class ArduinoGUI:
|
|||||||
self.root.grid_rowconfigure(2, weight=0)
|
self.root.grid_rowconfigure(2, weight=0)
|
||||||
self.root.grid_rowconfigure(3, weight=0)
|
self.root.grid_rowconfigure(3, weight=0)
|
||||||
self.root.grid_rowconfigure(4, weight=0)
|
self.root.grid_rowconfigure(4, weight=0)
|
||||||
self.root.grid_rowconfigure(5, weight=1)
|
self.root.grid_rowconfigure(5, weight=0)
|
||||||
self.root.grid_rowconfigure(6, weight=0)
|
self.root.grid_rowconfigure(6, weight=0)
|
||||||
|
self.root.grid_rowconfigure(7, weight=1)
|
||||||
|
self.root.grid_rowconfigure(8, weight=0)
|
||||||
|
|
||||||
|
|
||||||
def set_pid_parameters(self):
|
def set_pid_parameters(self):
|
||||||
if self.arduino:
|
if self.arduino:
|
||||||
@@ -241,6 +263,38 @@ class ArduinoGUI:
|
|||||||
messagebox.showerror("Fehler", str(e))
|
messagebox.showerror("Fehler", str(e))
|
||||||
else:
|
else:
|
||||||
messagebox.showwarning("Warnung", "Bitte einen COM-Port auswählen")
|
messagebox.showwarning("Warnung", "Bitte einen COM-Port auswählen")
|
||||||
|
|
||||||
|
def connect_lsp(self):
|
||||||
|
try:
|
||||||
|
ports = serial.tools.list_ports.comports()
|
||||||
|
used_ports = [port.device for port in ports]
|
||||||
|
|
||||||
|
serPort = None
|
||||||
|
|
||||||
|
if os.name == 'nt':
|
||||||
|
for i in range(1, 257):
|
||||||
|
port = f'(COM{i}'
|
||||||
|
if (port not in used_ports) and (serPort == None):
|
||||||
|
serPort = port
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
for i in range(256):
|
||||||
|
port = f'/dev/ttyS{i}'
|
||||||
|
if (port not in used_ports) and (serPort == None):
|
||||||
|
serPort = port
|
||||||
|
pass
|
||||||
|
for i in range(256):
|
||||||
|
port = f'/dev/ttyUSB{i}'
|
||||||
|
if (port not in used_ports) and (serPort == None):
|
||||||
|
serPort = port
|
||||||
|
pass
|
||||||
|
|
||||||
|
if serPort != None:
|
||||||
|
self.ser = serial.Serial(serPort, 9600, timeout=1)
|
||||||
|
print(F"Slave Port bereit an {serPort}")
|
||||||
|
except Exception as e:
|
||||||
|
print(F"Fehler beim Öffnen des Slave Ports an {serPort}")
|
||||||
|
pass
|
||||||
|
|
||||||
def set_setpoint(self):
|
def set_setpoint(self):
|
||||||
if self.arduino:
|
if self.arduino:
|
||||||
@@ -345,23 +399,28 @@ class ArduinoGUI:
|
|||||||
if self.setpoint_flag:
|
if self.setpoint_flag:
|
||||||
self.arduino.write(f"s{self.setpoint:.0f},0\n".encode())
|
self.arduino.write(f"s{self.setpoint:.0f},0\n".encode())
|
||||||
self.setpoint_flag = False
|
self.setpoint_flag = False
|
||||||
time.sleep(0.1)
|
while self.arduino.out_waiting:
|
||||||
|
pass
|
||||||
if self.multi_setpoints_flag:
|
if self.multi_setpoints_flag:
|
||||||
self.send_interpolated_points()
|
self.send_interpolated_points()
|
||||||
self.multi_setpoints_flag = False
|
self.multi_setpoints_flag = False
|
||||||
time.sleep(0.1)
|
while self.arduino.out_waiting:
|
||||||
|
pass
|
||||||
if self.tare_flag:
|
if self.tare_flag:
|
||||||
self.arduino.write(b'w\n')
|
self.arduino.write(b'w\n')
|
||||||
self.tare_flag = False
|
self.tare_flag = False
|
||||||
time.sleep(0.1)
|
while self.arduino.out_waiting:
|
||||||
|
pass
|
||||||
if self.demag_flag:
|
if self.demag_flag:
|
||||||
self.arduino.write(b'e\n')
|
self.arduino.write(b'e\n')
|
||||||
self.demag_flag = False
|
self.demag_flag = False
|
||||||
time.sleep(0.1)
|
while self.arduino.out_waiting:
|
||||||
|
pass
|
||||||
if self.input_source_flag:
|
if self.input_source_flag:
|
||||||
self.arduino.write(b'S\n')
|
self.arduino.write(b'S\n')
|
||||||
self.input_source_flag = False
|
self.input_source_flag = False
|
||||||
time.sleep(0.1)
|
while self.arduino.out_waiting:
|
||||||
|
pass
|
||||||
if self.pid_flag:
|
if self.pid_flag:
|
||||||
self.send_pid_parameters()
|
self.send_pid_parameters()
|
||||||
self.pid_flag = False
|
self.pid_flag = False
|
||||||
@@ -400,11 +459,39 @@ class ArduinoGUI:
|
|||||||
|
|
||||||
self.csv_writer.writerow([formatted_time, formatted_angle, formatted_setpoint, formatted_torque, formatted_output])
|
self.csv_writer.writerow([formatted_time, formatted_angle, formatted_setpoint, formatted_torque, formatted_output])
|
||||||
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
time.sleep(0.1)
|
time.sleep(0.01)
|
||||||
|
|
||||||
|
|
||||||
|
if self.ser:
|
||||||
|
if self.ser.in_waiting:
|
||||||
|
try:
|
||||||
|
command = ""
|
||||||
|
while self.ser.in_waiting:
|
||||||
|
command += self.ser.read(1).decode(errors='ignore').strip()
|
||||||
|
if command[0] == 'a':
|
||||||
|
message = f"{self.current_angle};{self.current_torque};{self.analogInput};{self.currentSetpoint};{self.currentOutput}\n"
|
||||||
|
self.ser.write(message.encode())
|
||||||
|
if command[0] == 'w':
|
||||||
|
self.tare_angle()
|
||||||
|
if command[0] == 'u':
|
||||||
|
outCommand = F"{command}\n"
|
||||||
|
self.arduino.write(outCommand.encode())
|
||||||
|
print(self.arduino.readline())
|
||||||
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
self.ser.read()
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
#self.ser.write(b'Hallo\n')
|
||||||
|
else :
|
||||||
|
try:
|
||||||
|
pass
|
||||||
|
self.connect_lsp()
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
|
||||||
def send_pid_parameters(self):
|
def send_pid_parameters(self):
|
||||||
if self.selected_pid in self.pid_params:
|
if self.selected_pid in self.pid_params:
|
||||||
@@ -422,11 +509,20 @@ class ArduinoGUI:
|
|||||||
messagebox.showerror("Fehler", "Ausgewählte PID Konfiguration nicht gefunden.")
|
messagebox.showerror("Fehler", "Ausgewählte PID Konfiguration nicht gefunden.")
|
||||||
|
|
||||||
def on_closing(self):
|
def on_closing(self):
|
||||||
self.running = False
|
userInput = simpledialog.askstring("Masterpasswort eingeben", "Zum Ausführen dieses Befehls ist das Masterpasswort notwendig.\n")
|
||||||
if self.arduino:
|
if userInput == "976638":
|
||||||
self.arduino.close()
|
self.running = False
|
||||||
self.root.quit()
|
if self.arduino:
|
||||||
self.root.destroy()
|
self.arduino.close()
|
||||||
|
self.communication_thread = None
|
||||||
|
if self.ser:
|
||||||
|
self.ser.close()
|
||||||
|
self.root.quit()
|
||||||
|
self.root.destroy()
|
||||||
|
elif userInput == None:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
messagebox.showerror("Fehler", "Es wurde ein falsches Passwort eingegeben.")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
root = customtkinter.CTk()
|
root = customtkinter.CTk()
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
tk==0.1.0
|
||||||
|
customtkinter==5.2.2
|
||||||
pyserial==3.5
|
pyserial==3.5
|
||||||
matplotlib==3.9.0
|
matplotlib==3.9.0
|
||||||
tk==0.1.0
|
numpy==2.0.1
|
||||||
customtkinter==5.2.2
|
Pillow==10.4.0
|
||||||
Reference in New Issue
Block a user