Last active
August 5, 2018 08:30
-
-
Save Mebus/09e600b404cfc660f7984a74626c5ecb to your computer and use it in GitHub Desktop.
Python3 Skript zur Berechnung des Kurbelsterns aus einer Zündreihenfolge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
from prettytable import PrettyTable # pip3 install prettytable | |
## Modulofunktion | |
def modulo(zahl): | |
erg = zahl % 360 | |
return erg + 360 if erg < 0 else erg | |
# Ausgabe der Berechnung | |
def print_firing_order(zylinders, order, viertakt): | |
if viertakt: | |
angle = 720.0 | |
else: | |
angle = 360.0 | |
if not len(zylinders) == len(order): | |
raise ValueError('Anzahl der Zylinder passt nicht zu den Daten!') | |
t = PrettyTable(['Zylinder', 'Bankversatz', 'Kurbelsternwinkel']) | |
i = 0 | |
for fire in order: | |
fireat = modulo(zylinders[(fire-1)] + i*angle/len(zylinders)) | |
t.add_row([str(fire), str(zylinders[(fire-1)]), str(fireat)]) | |
i = i + 1 | |
print(str(t) + "\n") | |
""" | |
Hier Daten eingeben | |
""" | |
# Viertakt? | |
viertakt = True | |
## Zylinder: Winkel der Zylinderachsen | |
zylinders = [0,0,0,0,-90,-90,-90, -90] | |
## Zündreihenfolgen | |
orders = [] | |
orders.append([1, 5, 4, 2, 6, 3, 7, 8]) | |
orders.append([1, 3, 4, 2, 6, 5, 7, 8]) | |
orders.append([1, 5, 7, 8, 6, 3, 4, 2]) | |
""" | |
Hier keine Daten mehr eingeben | |
""" | |
for order in orders: | |
print_firing_order(zylinders, order, True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment