-
Notifications
You must be signed in to change notification settings - Fork 0
/
motorphysical.py
56 lines (49 loc) · 1.72 KB
/
motorphysical.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout
from functools import partial
from communication import Axis
from tuner import create_ivar_row, TextUpdate
from motorstatus import AxisSelector
from base import Base
def max_current_cb(axis):
try:
i01 = float(axis.get_axis_ivar(1))
i69 = float(axis.get_axis_ivar(69))
i77 = float(axis.get_axis_ivar(77))
except ValueError:
i01 = 1
i69 = 1
i77 = 1
return "Max current: sqrt(Ixx01*Ixx69^2 + Ixx77^2) = " + str((i01*i69**2 + i77**2)**.5)
def gear_ratio_cb(axis):
try:
i07 = float(axis.get_axis_ivar(7))
i08 = float(axis.get_axis_ivar(8))
except ValueError:
i07 = 1
i08 = 1
return "Gear ratio: Ixx07/Ixx08 = " + str(i07/i08)
class MotorPhysicalSetup(QWidget, Base):
def addIvarRow(self, ivar, title):
row = create_ivar_row(self.axis, ivar, title+" (Ixx{:02d}): ".format(ivar))
self.layout().addLayout(row)
def __init__(self, axis_num=1, parent=None):
super().__init__()
#self.axis = Axis(axis_num)
self.axis = self.controller.getAxis(axis_num)
self.setLayout(QVBoxLayout())
self.addIvarRow(1, "Commutation enable")
self.addIvarRow(70, "Num. commutation cycles")
self.addIvarRow(69, "Command output limit")
self.addIvarRow(77, "Magnetization current")
self.layout().addWidget(TextUpdate(partial(max_current_cb, self.axis)))
self.addIvarRow(7, "Master scale factor")
self.addIvarRow(8, "Position scale factor")
self.layout().addWidget(TextUpdate(partial(gear_ratio_cb, self.axis)))
self.axis_selector = AxisSelector(self.axis)
self.layout().addWidget(self.axis_selector)
if __name__ == "__main__":
app = QApplication([])
widget = MotorPhysicalSetup()
widget.controller.set_pmac_socket("192.168.11.21", 1025)
widget.show()
app.exec()