Skip to content

Commit

Permalink
Added speed limit options
Browse files Browse the repository at this point in the history
  • Loading branch information
Ultrawipf committed Jul 20, 2023
1 parent 21e8aef commit 108d740
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 135 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### Changes in 1.14.x:
- Added TMC space vector PWM checkbox
- Added option to prefer energy dissipation in motor for TMC instead of brake resistor

- Added speed limiter axis option
31 changes: 30 additions & 1 deletion axis_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def __init__(self, main: 'main.MainUi'=None, unique=0):
self.pushButton_center.clicked.connect(lambda : self.send_command("axis","zeroenc",instance=self.axis))

#self.checkBox_invert.stateChanged.connect(lambda val : self.send_value("axis","invert",(0 if val == 0 else 1),instance=self.axis))
self.checkBox_speedlimit.stateChanged.connect(self.setSpeedLimitEnabled)
self.spinBox_speedlimit.valueChanged.connect(lambda val : self.send_value("axis","maxspeed",val,instance=self.axis))

self.spinBox_reduction_numerator.valueChanged.connect(self.updateReductionText)
self.spinBox_reduction_denominator.valueChanged.connect(self.updateReductionText)
Expand All @@ -76,8 +78,35 @@ def __init__(self, main: 'main.MainUi'=None, unique=0):

self.register_callback("axis","cmdinfo",self.reductionAvailable,self.axis,int,adr = 17)

self.register_callback("axis","maxspeed",self.speedLimitCb,self.axis,int)

self.pushButton_encoderTuning.clicked.connect(self.encoder_tuning_dlg.display)

def setSpeedLimit(self,val):
if self.checkBox_speedlimit.isChecked():
self.send_value("axis","maxspeed",self.spinBox_speedlimit.value(),instance=self.axis)
else:
self.send_value("axis","maxspeed",0,instance=self.axis)


def speedLimitCb(self,val):
qtBlockAndCall(self.spinBox_speedlimit,self.spinBox_speedlimit.setValue,val)
if not val:
self.spinBox_speedlimit.setEnabled(False)
self.checkBox_speedlimit.setChecked(False)
else:
self.checkBox_speedlimit.setChecked(True)
self.spinBox_speedlimit.setEnabled(True)


def setSpeedLimitEnabled(self,val):
self.spinBox_speedlimit.setEnabled(val)
if self.checkBox_speedlimit.isChecked():
self.send_value("axis","maxspeed",self.spinBox_speedlimit.value(),instance=self.axis)
else:
self.send_value("axis","maxspeed",0,instance=self.axis)


def updateReduction(self,val):
numerator,denominator = val
self.spinBox_reduction_numerator.setValue(numerator)
Expand Down Expand Up @@ -229,7 +258,7 @@ def updateSliders(self):
self.max_power = 0x7fff
self.horizontalSlider_power.setMaximum(self.max_power)

commands = ["power","degrees","fxratio","esgain","idlespring","axisdamper"] # requests updates
commands = ["power","degrees","fxratio","esgain","idlespring","axisdamper","maxspeed"] # requests updates
self.send_commands("axis",commands,self.axis)

self.updatePowerLabel(self.horizontalSlider_power.value())
Expand Down
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@
import simplemotion_ui

# This GUIs version
VERSION = "1.13.4"
VERSION = "1.14.0"

# Minimal supported firmware version.
# Major version of firmware must match firmware. Minor versions must be higher or equal
MIN_FW = "1.13.1"
MIN_FW = "1.14.0"

class MainUi(PyQt6.QtWidgets.QMainWindow, base_ui.WidgetUI, base_ui.CommunicationHandler):
"""Display and manage the main UI."""
Expand Down
Loading

0 comments on commit 108d740

Please sign in to comment.