Ok danke, aber ich würde ja nur dateiname wieder aufrufen müssen in der anderen Funktion, ich habe ja schon die ausgewählte Datei ![]()
Posts by Ringo27
-
-
Hallo, habe wieder ein kleines Problem..
Durch einen Button wird folgende Funktion aufgerufen:
(Der Code vom letzten mal)
Code
Display Moredef open(): dateiname = filedialog.askopenfilename(initialdir="/home/pi/Dokumente/ProjektAnschrift", filetypes = [("Excel files", "*.xlsx")],title = "Datei auswählen") workbook = Workbook() workbook = load_workbook(filename = dateiname) worksheet = workbook.active stadt = worksheet['A1'] land = worksheet['A2'] postleitzahl = worksheet['A3'] print(stadt.value) print(land.value) print(postleitzahl.value)Jetzt möchte ich in einer anderen Funktion [weiter()], diese ausgewählte Datei, die unter dateiname ausgewählt wurde, wieder verwenden und dort andere Werte aus der Excel-Datei holen. Wie funktioniert das?
Codedef weiter(): ## Datei aus der anderen Funktion bekommen ## strasse = worksheet['A4'] hausnummer = worksheet['A5'] nachname = worksheet['A6'] print(strasse.value) print(hausnummer.value) print(nachname.value)Danke im Voraus!

Grüße,
Ringo27
-
-
Achso ich schreibe einfach filename = dateiname

Danke!

-
Ja wird auch angezeigt
Ausgabe:
/home/pi/Dokumente/ProjektAnschrift/Brief.xlsx
Also habe die Datei mit dem Namen "Brief" ausgewählt
-
Hallo, habe wieder ein kleines Problem.
Ich versuche mich jetzt einmal mit Openpyxl und Excel. Sobald ein Button gedrückt wird, wird dateiname ausgeführt, dann öffnet sich ja das Filedialog.
Und ich möchte, dass die Excel-Datei die dort ausgewählt wurde dann ausgewertet wird (Also wird mir von der Datei die Zellen A1,A2,A3 angezeigt).
Was muss man bei filename = hineinschreiben, damit das Programm die ausgewählte Datei nimmt?
Danke im Voraus!
Code
Display Moredateiname = filedialog.askopenfilename(initialdir="/home/pi/Dokumente/ProjektAnschrift", filetypes = [("Excel files", "*.xlsx")], title = "Datei auswählen") workbook = Workbook() workbook = load_workbook(filename = '') worksheet = workbook.active stadt = worksheet['A1'] land = worksheet['A2'] postleitzahl = worksheet['A3'] print(stadt.value) print(land.value) print(postleitzahl.value) -
Ok ja vielen Dank!

Wie würde es dann funktionieren, wenn man einen Button mit mehreren Funktionen hat? Wenn nicht über lambda?
Werde das Programm wohl früher oder später sowieso umschreiben müssen..
-
Ok, Danke!
lambda steht nur da, da im ganzen Programm noch eine Funktion ausgeführt wird, wenn der Button ok gedrückt worden ist.
Die ganzen sendCommand und byte-arrays stammen aus einem Musterprogramm von den Hersteller der Führung, diese funktionieren auch, deshalb will ich da eigentlich nicht soviel bzw. garnichts ändern.
Ja hatte leider noch keine Zeit das ganze Programm zu überarbeiten.. müsste wirklich vieles noch verbesseren..
Aber leider löst das mein Problem nicht..
Dennis89 ja stimmt, hatten wir schon letzte Woche
-
Ja sobald ich jedoch command = start schreibe, wird die Funktion ausgeführt - also der Führungswagen fährt auf die zugewiesenen Werte, jedoch ist nun der Button "hängen geblieben".
Sobald ich command = start() aufrufe, funktioniert es sowieso nicht.
Mein Programm sieht so aus (bringt wahrscheinlich nichts, da man es ohne die Führung nicht ausführen kann):
Python
Display Morefrom tkinter import * from functools import partial import socket import time import sys App = Tk() App.title("Automatischer Längenanschlag") App.config(background = "white") App.geometry("1280x800") laenge = Label(App, text="Länge:", bg="white", font= ("Helvetica",40)) laenge.place(x=300, y=180) #Textfeld Länge: def clicker(entry, _event): #Tastatur App5 = Toplevel() App5.title("Bitte Maß einegben") App5.config(background = "white") App5.geometry("320x420+640+340") B7 =Button(App5, text ="7",font= ("Helvetica",20), borderwidth=3, command = partial(button_click, entry, 7)) B7.place(x=10, y=10, width=100, height=100) B8 =Button(App5, text ="8",font= ("Helvetica",20), borderwidth=3, command = partial(button_click, entry, 8)) B8.place(x=110, y=10, width=100, height=100) B9 =Button(App5, text ="9",font= ("Helvetica",20), borderwidth=3, command = partial(button_click, entry, 9)) B9.place(x=210, y=10, width=100, height=100) B4 =Button(App5, text ="4",font= ("Helvetica",20), borderwidth=3, command = partial(button_click, entry, 4)) B4.place(x=10, y=110, width=100, height=100) B5 =Button(App5, text ="5",font= ("Helvetica",20), borderwidth=3, command = partial(button_click, entry, 5)) B5.place(x=110, y=110, width=100, height=100) B6 =Button(App5, text ="6",font= ("Helvetica",20), borderwidth=3, command = partial(button_click, entry, 6)) B6.place(x=210, y=110, width=100, height=100) B1=Button(App5, text ="1",font= ("Helvetica",20), borderwidth=3, command = partial(button_click, entry, 1)) B1.place(x=10, y=210, width=100, height=100) B2=Button(App5, text ="2",font= ("Helvetica",20), borderwidth=3, command = partial(button_click, entry, 2)) B2.place(x=110, y=210, width=100, height=100) B3=Button(App5, text ="3",font= ("Helvetica",20), borderwidth=3, command = partial(button_click, entry, 3)) B3.place(x=210, y=210, width=100, height=100) B0 =Button(App5, text ="0",font= ("Helvetica",20), borderwidth=3, command = partial(button_click, entry, 0)) B0.place(x=110, y=310, width=100, height=100) C =Button(App5, text ="C",font= ("Helvetica",20), borderwidth=3, command= button_clear) C.place(x=210, y=310, width=100, height=100) App5.after(10000, App5.destroy) def button_click(entry, number): current = entry.get() entry.delete(0, END) entry.insert(0, str(current)+ str(number)) def button_clear(): laenge_eingabe.delete(0, END) schnitte_anzeige.delete(0, END) def start(): zahl = int(laenge_eingabe.get())* 100 if zahl <= int(4000): zahl1 = str(hex(zahl).lstrip("0x").rstrip("L")) [0:1] zahl2 = str(hex(zahl).lstrip("0x").rstrip("L")) [1:3] a = int(zahl2,16) b = int(zahl1,16) c = 0 elif zahl >= int(65600) and zahl <= int(99900): zahl1 = str(hex(zahl).lstrip("0x").rstrip("L")) [0:1] zahl2 = str(hex(zahl).lstrip("0x").rstrip("L")) [1:3] zahl3 = str(hex(zahl).lstrip("0x").rstrip("L")) [3:5] a = int(zahl3, 16) b = int(zahl2, 16) c = int(zahl1, 16) elif zahl == int(100000): zahl1 = str(hex(zahl).lstrip("0x").rstrip("L")) [0:2] zahl2 = str(hex(zahl).lstrip("0x").rstrip("L")) [2:4] zahl3 = str(hex(zahl).lstrip("0x").rstrip("L")) [4:6] a = int(zahl3, 16) b = int(zahl2, 16) c = int(zahl1, 16) elif zahl > int(100000): laenge_eingabe.delete(0, END) fehler.config(text="Zahl muss zwischen 0 und 1000 liegen") print("Error") else: zahl1 = str(hex(zahl).lstrip("0x").rstrip("L")) [0:2] zahl2 = str(hex(zahl).lstrip("0x").rstrip("L")) [2:4] zahl3 = str(hex(zahl).lstrip("0x").rstrip("L")) [4:5] a = int(zahl2, 16) b = int(zahl1, 16) c = 0 sendCommand(enableOperation_array) # 6060h Modes of Operation #Setzen auf Profile Position Mode (see "def set_mode(mode):"; Byte 19 = 1) #Set Profile Position Mode (see "def set_mode(mode):"; Byte 19 = 1) set_mode(1) # 6081h Profile Velocity #Setzen der Geschwindigkeit auf 150 U/min (Byte 19 = 152; Byte 20 = 58; Byte 21 = 0; Byte 22 = 0) #Set velocity to 150 rpm (Byte 19 = 152; Byte 20 = 58; Byte 21 = 0; Byte 22 = 0) sendCommand(bytearray([0, 0, 0, 0, 0, 17, 0, 43, 13, 1, 0, 0, 96, 129, 0, 0, 0, 0, 4, 152, 58, 0, 0])) # 6083h Profile Acceleration #Setzen der Beschleunigung auf 500 U/min² (Byte 19 = 80; Byte 20 = 195; Byte 21 = 0; Byte 22 = 0) #Set acceleration to 500 rpm/min² (Byte 19 = 80; Byte 20 = 195; Byte 21 = 0; Byte 22 = 0) sendCommand(bytearray([0, 0, 0, 0, 0, 17, 0, 43, 13, 1, 0, 0, 96, 131, 0, 0, 0, 0, 4, 80, 195, 0, 0])) # 607A Target Position #Setzen sie einer Zielposition auf den Wert 250mm (Byte 19 = 168; Byte 20 = 97; Byte 21 = 0; Byte 22 = 0) #Set target position to 250mm (Byte 19 = 168; Byte 20 = 97; Byte 21 = 0; Byte 22 = 0) sendCommand(bytearray([0, 0, 0, 0, 0, 17, 0, 43, 13, 1, 0, 0, 96, 122, 0, 0, 0, 0, 4, a, b, c, 0])) #Startbefehl zur Bewegung des Motors über Bit 4 #Set Bit 4 true to excecute the movoment of the motor sendCommand(bytearray([0, 0, 0, 0, 0, 15, 0, 43, 13, 1, 0, 0, 96, 64, 0, 0, 0, 0, 2, 31, 0])) print("go") time.sleep(0.1) #Check Statusword nach Ziel ereicht #Check Statusword for target reached while (sendCommand(status_array) != [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 39, 22]): print("wait for next command") #1 Sekunde Verzoegerung #1 second delay time.sleep(1) laenge_eingabe = Entry(App, bg="white", borderwidth=2, font=("Hevetica", 22)) laenge_eingabe.focus() laenge_eingabe.bind("<Button-1>", partial(clicker,laenge_eingabe)) laenge_eingabe.place(x=500, y=180, width= 200, height=65) ok_b1 = Button(App, text="OK", font=("Hevetica", 20) ,command = lambda:[start()]) ok_b1.place(x=900, y=180, width= 100, height=65) #Bus-Verbindung herstellen #Establish bus connection try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) except socket.error: print ('failed to create sockt') s.connect(("169.254.51.115", 502)) print ('Socket created') #Wird beim Ausfuehren des Programms nur der Speicherort und der Programmname in der Shell angezeigt, so sind die IP Adressen des Programms und der dryve D1 nicht uebereinstimmend #When executing the program and the shell displays the storing folder and the program name, the set IP address in the program and the dryve D1 doesn't match #Durchlauf State Machine (Handbuch: Visualisieung State Machine) #State Machine pass through (Manual: Visualisation State Machine) # Statusword 6041h # Status request status = [0, 0, 0, 0, 0, 13, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2] status_array = bytearray(status) print(status_array) # Controlword 6040h # Command: Shutdown shutdown = [0, 0, 0, 0, 0, 15, 0, 43, 13, 1, 0, 0, 96, 64, 0, 0, 0, 0, 2, 6, 0] shutdown_array = bytearray(shutdown) print(shutdown_array) # Controlword 6040h # Command: Switch on switchOn = [0, 0, 0, 0, 0, 15, 0, 43, 13, 1, 0, 0, 96, 64, 0, 0, 0, 0, 2, 7, 0] switchOn_array = bytearray(switchOn) print(switchOn_array) # Controlword 6040h # Command: enable Operation enableOperation = [0, 0, 0, 0, 0, 15, 0, 43,13, 1, 0, 0, 96, 64, 0, 0, 0, 0, 2, 15, 0] enableOperation_array = bytearray(enableOperation) print(enableOperation_array) #Definition der Funktion zum Senden und Empfangen von Daten #Definition of the function to send and receive data def sendCommand(data): #Socket erzeugen und Telegram senden #Create socket and send request s.send(data) res = s.recv(24) #Ausgabe Antworttelegram #Print response telegram print(list(res)) return list(res) #Shutdown Controlword senden und auf das folgende Statuswort pruefen. Pruefung auf mehrer Statuswords da mehrere Szenarien siehe Bit assignment Statusword, data package im Handbuch #sending Shutdown Controlword and check the following Statusword. Checking several Statuswords because of various options. look at Bit assignment Statusword, data package in user manual def set_shdn(): sendCommand(shutdown_array) while (sendCommand(status_array) != [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 33, 6] and sendCommand(status_array) != [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 33, 22] and sendCommand(status_array) != [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 33, 2]): print("wait for shdn") #1 Sekunde Verzoegerung #1 second delay time.sleep(1) #Switch on Disabled Controlword senden und auf das folgende Statuswort pruefen. Pruefung auf mehrer Statuswords da mehrere Szenarien siehe Bit assignment Statusword, data package im Handbuch #sending Switch on Disabled Controlword and check the following Statusword. Checking several Statuswords because of various options. look at Bit assignment Statusword, data package in user manual def set_swon(): sendCommand(switchOn_array) while (sendCommand(status_array) != [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 35, 6] and sendCommand(status_array) != [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 35, 22] and sendCommand(status_array) != [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 35, 2]): print("wait for sw on") #1 Sekunde Verzoegerung #1 second delay time.sleep(1) #Operation Enable Controlword senden und auf das folgende Statuswort pruefen. Pruefung auf mehrer Statuswords da mehrere Szenarien siehe Bit assignment Statusword, data package im Handbuch #Operation Enable Controlword and check the following Statusword. Checking several Statuswords because of various options. look at Bit assignment Statusword, data package in user manual def set_op_en(): sendCommand(enableOperation_array) while (sendCommand(status_array) != [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 39, 6] and sendCommand(status_array) != [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 39, 22] and sendCommand(status_array) != [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 39, 2]): print("wait for op en") #1 Sekunde Verzoegerung #1 second delay time.sleep(1) def init(): #Aufruf der Funktion sendCommand zum hochfahren der State Machine mit vorher definierten Telegrammen (Handbuch: Visualisieung State Machine) #Call of the function sendCommand to start the State Machine with the previously defined telegrams (Manual: Visualisation State Machine) set_shdn() set_swon() set_op_en() def set_mode(mode): #Setzen der Operationsmodi im Objekt 6060h Modes of Operation #Set operation modes in object 6060h Modes of Operation sendCommand(bytearray([0, 0, 0, 0, 0, 14, 0, 43, 13, 1, 0, 0, 96, 96, 0, 0, 0, 0, 1, mode])) while (sendCommand(bytearray([0, 0, 0, 0, 0, 13, 0, 43, 13, 0, 0, 0, 96, 97, 0, 0, 0, 0, 1])) != [0, 0, 0, 0, 0, 14, 0, 43, 13, 0, 0, 0, 96, 97, 0, 0, 0, 0, 1, mode]): print("wait for mode") #1 Sekunde Verzoegerung #1 second delay time.sleep(1) init() #Parametrierung der Objekte gemäß Handbuch #Parameterization of the objects according to the manual # 6060h Modes of Operation #Setzen auf Homing Modus (see "def set_mode(mode):"; Byte 19 = 6) #Set Homing mode (see "def set_mode(mode):"; Byte 19 = 6) set_mode(6) # 6092h_01h Feed constant Subindex 1 (Feed) #Setzen des Vorschubs auf den Wert 7000; vgl. Handbuch (Byte 19 = 88; Byte 20= 27) #Set feed constant to 6000; refer to manual (Byte 19 = 112; Byte 20= 23) sendCommand(bytearray([0, 0, 0, 0, 0, 15, 0, 43, 13, 1, 0, 0, 96, 146, 1, 0, 0, 0, 2, 88, 27])) # 6092h_02h Feed constant Subindex 2 (Shaft revolutions) #Setzen der Wellenumdrehung auf 1; vgl. Handbuch (Byte 19 = 1) #Set shaft revolutions to 1; refer to manual (Byte 19 = 1) sendCommand(bytearray([0, 0, 0, 0, 0, 14, 0, 43, 13, 1, 0, 0, 96, 146, 2, 0, 0, 0, 1, 1])) # 6099h_01h Homing speeds Switch #Vorgabe der Verfahrgeschwindigkeit beim Suchen auf den Schalter wird auf 60 U/min gesetzt (Byte 19 = 112; Byte 20 = 23)) #Speed during search for switch is set to 60 rpm (Byte 19 = 112; Byte 20 = 23)) sendCommand(bytearray([0, 0, 0, 0, 0, 15, 0, 43, 13, 1, 0, 0, 96, 153, 1, 0, 0, 0, 2, 48, 117])) # 6099h_02h Homing speeds Zero #Setzen Verfahrgeschwindigkeit beim Suchen von Null auf 60 U/min (Byte 19 = 112; Byte 20 = 23) #Set speed during Search for zero to 60 rpm (Byte 19 = 112; Byte 20 = 23)) sendCommand(bytearray([0, 0, 0, 0, 0, 15, 0, 43, 13, 1, 0, 0, 96, 153, 2, 0, 0, 0, 2, 48, 117])) # 609Ah Homing acceleration #Setzen der Refernzfahrt-Beschleunigung wird auf 500 U/min² (Byte 19 = 80; Byte 20 = 195) #Set Homing acceleration to 500 rpm/min² (Byte 19 = 80; Byte 20 = 195) sendCommand(bytearray([0, 0, 0, 0, 0, 15, 0, 43, 13, 1, 0, 0, 96, 154, 0, 0, 0, 0, 2, 80, 195])) # 6040h Controlword #Start Homing sendCommand(bytearray([0, 0, 0, 0, 0, 15, 0, 43, 13, 1, 0, 0, 96, 64, 0, 0, 0, 0, 2, 31, 0])) #Check Statusword nach Referenziert Signal #Check Statusword for signal referenced while (sendCommand(status_array) != [0, 0, 0, 0, 0, 15, 0, 43, 13, 0, 0, 0, 96, 65, 0, 0, 0, 0, 2, 39, 22]): print("wait for Homing to end") #1 Sekunde Verzoegerung #1 second delay time.sleep(1) App.mainloop()Und ich weiß, dass die Struktur nicht schön ist und die Umrechnung der Zahl auch nicht die effizient ist, aber habe ist nur ein kleiner Teil des Programmes.
-
Ok vielen Dank. Das Problem ist nur wenn ich euch das Programm schicke, könnt ihr das ja nicht ausführen, weil die Arrays zum Ansteuern einer Führung sind.
__blackjack__ was meinst du mit Rückgabewert? Ich denke dort könnte das Problem liegen.
Und Danke für die Erklärung!

-
Ja bitte, aber die Funktion wird einmal ausgeführt und wenn ich dann den Button nochmal drücke passiert nichts. Ich weiß nicht ob ich überhaupt die after methode benötige, da ja immer nur nach dem Drücken start ausgeführt werden soll.
Ich verstehe einfach nicht warum dann beim zweiten mal nichts passiert

-
Dachte so funktioniert das mit after oder?

Ich denke ich hab diese Methode falsch verstanden, bin ja auch Anfänger

Leider kann ich das ganze Programm nicht zeigen, würde das ganze zu kompliziert machen, da ich ja nur das Problem mit der abfrage habe.
-
Hallo, habe ein kleines Problem.
Ich bekomme bei meinem Programm aus 3 verschiedenen Entries Werte, diese Werte sollen dann in ein Bytearray eingetragen werden. Funktioniert alles soweit.
Durch den Button (ok) wird die Funktion Start abgefragt. (wird durch command = start() beim Button aufgerufen)
Jedes mal wenn der Button (ok) gedrückt worden ist, sollen dann die Werte neu eingetragen werden. Jedoch funktioniert das nur einmal, dann passiert nichts mehr..
Dachte mir mit der after-methode sollte das ja funktionieren oder?
Code
Display Moredef start(*args): a = int(entry1.get()) b = int(entry2.get()) c = int(entry3.get()) sendCommand(enableOperation_array) # 6060h Modes of Operation set_mode(1) # 6081h Profile Velocity sendCommand(bytearray([0, 0, 0, 0, 0, 17, 0, 43, 13, 1, 0, 0, 96, 129, 0, 0, 0, 0, 4, 152, 58, 0, 0])) # 6083h Profile Acceleration sendCommand(bytearray([0, 0, 0, 0, 0, 17, 0, 43, 13, 1, 0, 0, 96, 131, 0, 0, 0, 0, 4, 80, 195, 0, 0])) # 607A Target Position sendCommand(bytearray([0, 0, 0, 0, 0, 17, 0, 43, 13, 1, 0, 0, 96, 122, 0, 0, 0, 0, 4, a, b, c, 0])) #Startbefehl zur Bewegung des Motors über Bit 4 #Set Bit 4 true to excecute the movoment of the motor sendCommand(bytearray([0, 0, 0, 0, 0, 15, 0, 43, 13, 1, 0, 0, 96, 64, 0, 0, 0, 0, 2, 31, 0])) print("go") App.after(500, start) . . . . App.after(0,start) App.mainloop() -
Nein leider nicht so, wie gewünscht. Aber es funktioniert jetzt so auch also alles gut und Danke nochmals.
-
Ok Danke!

Ja der Mann war nur ein Support-Mitarbeiter also ich denke der kann wenig dafür wie diese Führungen positioniert werden.


Die Führung fährt eben nur auf genaue Werte, also wie 290 oder 763 (ohne Komma).
-
Wie gesagt ist sehr kompliziert und laut dem Herrn von der Firma ist das so. Die Multiplikation mit 100 hat nur etwas mit der Positionierungsgenauigkeit zu tun und bei laenge_eingabe wird eben ein Wert eingeben ( von 0 bis 1000 mm) und dann soll die Führung auf diese Position fahren. (Also habe ich 1000 Positionen, da sowieso nur genaue Werte verwendetet werden)
laenge_eingabe ist ein Integer
und ich habe soeben das Problem vorerst gelöst. (Anhang Programm)
Vielleicht nicht unbedingt schön, aber ich denke sollte funktionieren.
Danke euch! Gnom & __blackjack__
Code
Display Moredef start(): zahl = int(laenge_eingabe.get())* 100 zahl1 = str(hex(zahl).lstrip("0x").rstrip("L")) [0:2] zahl2 = str(hex(zahl).lstrip("0x").rstrip("L")) [2:4] zahl3 = str(hex(zahl).lstrip("0x").rstrip("L")) [4:6] a = int(zahl3, 16) b = int(zahl2, 16) c = int(zahl1, 16) print(a) print(b) print(c) -
__blackjack__ eben muss ich schon mit Hex rechnen
-
Gnom Nur das Problem ist ja die Eingaben variieren, also könnte einmal 1000 sein und einmal zum Beispiel 200
Und es muss eben heißen,
18
6a
0
Wär natürlich leichter wenn es nicht so wäre.. logisch ist das für mich auch nicht.
Weil wenn die Reihenfolge so wäre:
1
86
a0
dann wäre dass ja in Dec umgerechnet:
1
134
160 , so wie du schon gesagt hast
Nur wenn diese Werte dann in das Bytearray eingetragen werden, würde die Führung auf eine völlig andere Position fahren.
Doch wenn die Reihenfolge so wäre:
18
a6
0
dann wäre dass ja in Dec umgerechnet:
24
106
0
Dann würde die Führung auf meine eingegebene Position fahren
-
Leider ist es sehr schwer zu erklären, aber ich steuere mit dem Raspberry eine Zahnriemenachse an und bei dem Programm werden Bytearrays geschickt.
Die letzten vier Bytes sind für die Positionierung da und um die Werte einzutragen muss ich eben es wie folgt machen:
Ein Mitarbeiter der Firma, die diese Führungen herstellen hat mir es so erklärt:
sendCommand(bytearray([0, 0, 0, 0, 0, 17, 0, 43, 13, 1, 0, 0, 96, 122, 0, 0, 0, 0, 4, a, b, c, 0]))
Beispiel: Eingabe: 1000
1) 1000 wird mit 100 multipliziert, ergibt also 100000
2) 100000 wird dann in Hex umgerechnet, ergibt 186a0
3) Das Ergebnis 186a0 wird dann getrennt in:
18
6a
0
4) Nun werden die einzelnen Hex-Zahlen in Dec umgerechnet:
18 ist also 24
6a ist also 106
0 ist also 0
5) Nun würde 24 an Stelle c eingetragen werden
106 an Stelle b
Und 0 an Stelle a
(Little Endian)
Ich hoffe man versteht nun was das Problem ist.
-