Rev 706 | Rev 717 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 706 | Rev 709 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #!/usr/bin/env python |
1 | #!/usr/bin/env python |
2 | # -*- coding: iso-8859-15 -*- |
2 | # -*- coding: iso-8859-15 -*- |
3 | # generated by wxGlade 0.6.3 on Thu Sep 24 15:46:36 2009 |
3 | # generated by wxGlade 0.6.3 on Thu Sep 24 15:46:36 2009 |
Line 4... | Line 4... | ||
4 | 4 | ||
5 | # |
5 | # |
6 | # Mikrokopter VibrationTest Rev: $Rev: 701 $ |
6 | # Mikrokopter VibrationTest Rev: $Rev: 709 $ |
7 | # |
7 | # |
8 | # Author: Frederic Goddeeris (frederic@rc-flight.be) |
8 | # Author: Frederic Goddeeris (frederic@rc-flight.be) |
Line 9... | Line 9... | ||
9 | # |
9 | # |
Line 26... | Line 26... | ||
26 | 26 | ||
27 | 27 | ||
Line 28... | Line 28... | ||
28 | CHANNEL_NAMES = ["GyroYaw", "GyroRoll", "GyroNick", "Pressure", "Batt", "AccTop", "AccRoll", "AccNick"] |
28 | CHANNEL_NAMES = ["GyroYaw", "GyroRoll", "GyroNick", "Pressure", "Batt", "AccTop", "AccRoll", "AccNick"] |
29 | MOTOR_MAX = 16 |
29 | MOTOR_MAX = 16 |
30 | 30 | ||
31 | FS = 11111 |
31 | FS = 20 |
Line 32... | Line 32... | ||
32 | pi = 3.14 |
32 | pi = 3.14 |
Line 330... | Line 330... | ||
330 | self.static_line_1 = wx.StaticLine(self, -1) |
330 | self.static_line_1 = wx.StaticLine(self, -1) |
331 | self.graphCtrl = wx.lib.plot.PlotCanvas(self, size=(800,300)) |
331 | self.graphCtrl = wx.lib.plot.PlotCanvas(self, size=(800,300)) |
332 | self.label_40 = wx.StaticText(self, -1, "Graph Type ") |
332 | self.label_40 = wx.StaticText(self, -1, "Graph Type ") |
333 | self.graphTypeChoice = wx.Choice(self, -1, choices=["Raw Signal", "Filtered Signal", "Spectrum"]) |
333 | self.graphTypeChoice = wx.Choice(self, -1, choices=["Raw Signal", "Filtered Signal", "Spectrum"]) |
334 | self.label_41 = wx.StaticText(self, -1, "Y Axis Range ") |
334 | self.label_41 = wx.StaticText(self, -1, "Y Axis Range ") |
335 | self.yAxisChoice = wx.Choice(self, -1, choices=["25", "50", "75", "100", "200"]) |
335 | self.yAxisChoice = wx.Choice(self, -1, choices=["10", "25", "50", "75", "100", "200", "500", "1000", "2000"]) |
336 | self.copyGraphButton = wx.Button(self, -1, "Copy Graph Data") |
336 | self.copyGraphButton = wx.Button(self, -1, "Copy Graph Data") |
337 | self.TestListCtrl = wx.ListCtrl(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER) |
337 | self.TestListCtrl = wx.ListCtrl(self, -1, style=wx.LC_REPORT|wx.SUNKEN_BORDER) |
Line 338... | Line 338... | ||
338 | 338 | ||
339 | self.__set_properties() |
339 | self.__set_properties() |
Line 671... | Line 671... | ||
671 | fc = self.app.settings["lpf"].value |
671 | fc = self.app.settings["lpf"].value |
672 | filterLine2 = wx.lib.plot.PolyLine(((fc,0),(fc,y)), legend='HP Filter', colour='Black', width=4) |
672 | filterLine2 = wx.lib.plot.PolyLine(((fc,0),(fc,y)), legend='HP Filter', colour='Black', width=4) |
Line 673... | Line 673... | ||
673 | 673 | ||
674 | title = "Spectrum: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed) |
674 | title = "Spectrum: %s %s %d" %(vibTest.descr, vibTest.channel, vibTest.speed) |
675 | self.graphCtrl.setLogScale((True,False)) |
675 | self.graphCtrl.setLogScale((True,False)) |
676 | self.graphCtrl.Draw(wx.lib.plot.PlotGraphics([line,markers, filterLine1, filterLine2], title, "Freq (Hz)", "Acc"), xAxis=(20,500), yAxis= (0,y)) |
676 | self.graphCtrl.Draw(wx.lib.plot.PlotGraphics([line,markers, filterLine1, filterLine2], title, "Freq (Hz)", "Acc"), xAxis=(0.1,20), yAxis= (0,y)) |
677 | self.graphCtrl.SetEnableGrid(True) |
677 | self.graphCtrl.SetEnableGrid(True) |
Line 823... | Line 823... | ||
823 | def onAbout(self, event): # wxGlade: MainFrame.<event_handler> |
823 | def onAbout(self, event): # wxGlade: MainFrame.<event_handler> |
824 | # First we create and fill the info object |
824 | # First we create and fill the info object |
825 | print "about" |
825 | print "about" |
826 | info = wx.AboutDialogInfo() |
826 | info = wx.AboutDialogInfo() |
827 | info.Name = "MK Vibration Test - " |
827 | info.Name = "MK Vibration Test - " |
828 | info.Version = "v1.2 ($Rev: 701 $)".replace("$","") |
828 | info.Version = "v1.2 ($Rev: 709 $)".replace("$","") |
829 | info.Copyright = "" |
829 | info.Copyright = "" |
830 | info.Developers=["Frederic Goddeeris (Frederic@rc-flight.be)"] |
830 | info.Developers=["Frederic Goddeeris (Frederic@rc-flight.be)"] |
831 | info.Description = "Please consult the WIKI page for a complete description of the tool:" |
831 | info.Description = "Please consult the WIKI page for a complete description of the tool:" |
832 | info.WebSite = ("http://www.mikrokopter.de/ucwiki/en/VibrationTest", "VibrationTest WIKI page") |
832 | info.WebSite = ("http://www.mikrokopter.de/ucwiki/en/VibrationTest", "VibrationTest WIKI page") |
833 | wx.AboutBox(info) |
833 | wx.AboutBox(info) |
Line 889... | Line 889... | ||
889 | 889 | ||
890 | def _sendEvent(self, msg=None, error=False, parVoltage=None, speed=None): |
890 | def _sendEvent(self, msg=None, error=False, parVoltage=None, speed=None): |
891 | evt = MeasStatusUpdateEvent(running=self.running, msg=msg, error=error, voltage=parVoltage, speed=speed) |
891 | evt = MeasStatusUpdateEvent(running=self.running, msg=msg, error=error, voltage=parVoltage, speed=speed) |
Line 892... | Line 892... | ||
892 | wx.PostEvent(self.evtConsumer, evt) |
892 | wx.PostEvent(self.evtConsumer, evt) |
893 | 893 | ||
894 | def _setMotorSpeed(self, speed, settlingTime): |
894 | # def _setMotorSpeed(self, speed, settlingTime): |
895 | speeds = [0]*MOTOR_MAX |
895 | # speeds = [0]*MOTOR_MAX |
896 | 896 | # |
|
897 | for motor in self.param.motors: |
897 | # for motor in self.param.motors: |
898 | speeds[motor-1] = speed |
898 | # speeds[motor-1] = speed |
899 | for i in range(int(settlingTime*10)): |
899 | # for i in range(int(settlingTime*10)): |
900 | self._testCancel() |
900 | # self._testCancel() |
901 | self.mk.setMotorTest(speeds) |
901 | # self.mk.setMotorTest(speeds) |
Line 902... | Line 902... | ||
902 | time.sleep(.1) |
902 | # time.sleep(.1) |
903 | self.currSpeed = speed |
903 | # self.currSpeed = speed |
904 | 904 | ||
Line 942... | Line 942... | ||
942 | else: |
942 | else: |
943 | maxVoltage = nbCells*3.9 |
943 | maxVoltage = nbCells*3.9 |
Line 944... | Line 944... | ||
944 | 944 | ||
945 | self._sendEvent("Voltage: %2.1fV" % voltage) |
945 | self._sendEvent("Voltage: %2.1fV" % voltage) |
946 | self._sendEvent("Min/Max Voltage: %2.1fV-%2.1fV" % (minVoltage, maxVoltage), parVoltage=(minVoltage, maxVoltage, voltage)) |
946 | self._sendEvent("Min/Max Voltage: %2.1fV-%2.1fV" % (minVoltage, maxVoltage), parVoltage=(minVoltage, maxVoltage, voltage)) |
947 | - | ||
948 | self._sendEvent("Starting motor(s) (speed=%d)... " % self.param.motorStartupSpeed, speed=self.param.motorStartupSpeed) |
- | |
949 | self._setMotorSpeed(self.param.motorStartupSpeed, self.param.motorStartupSettlingTime) |
- | |
950 | - | ||
951 | for speed in self.param.speeds: |
- | |
952 | if speed != self.currSpeed: |
- | |
953 | self._sendEvent("Changing motor speed to %d... " % speed, speed=speed) |
- | |
954 | self._setMotorSpeed(speed, 1) |
- | |
955 | - | ||
956 | for channel in self.param.channels: |
- | |
957 | self._setMotorSpeed(speed, .1) |
- | |
958 | msg = self.mk.getDebugMsg() |
- | |
959 | voltage = msg.getVoltage() |
- | |
960 | - | ||
961 | self._sendEvent("Getting data from channel %s" % CHANNEL_NAMES[channel], parVoltage=(minVoltage, maxVoltage, voltage)) |
- | |
962 | data = self.mk.doVibrationTest(1000, channel) |
- | |
963 | - | ||
964 | vt = VibTest(self.param.descr, voltage, self.param.motors, speed, CHANNEL_NAMES[channel], data) |
- | |
965 | evt = MeasDataEvent(vibTest = vt) |
- | |
966 | wx.PostEvent(self.evtConsumer, evt) |
- | |
967 | - | ||
968 | if voltage<minVoltage: |
- | |
969 | raise Exception("Voltage too low") |
- | |
970 | - | ||
971 | - | ||
972 | self._setMotorSpeed(speed, .1) |
- | |
973 | time.sleep(1) |
947 | |
974 | msg = self.mk.getDebugMsg() |
948 | msg = self.mk.getDebugMsg() |
975 | voltage = msg.getVoltage() |
949 | voltage = msg.getVoltage() |
- | 950 | ||
- | 951 | #data = self.mk.doVibrationTest(1000, channel) |
|
- | 952 | messages = self.mk.recordDbgMsg(0.05, 20*5) |
|
- | 953 | data = [] |
|
- | 954 | for msg in messages: |
|
- | 955 | data.append(msg.getAngleRoll()) |
|
- | 956 | print data |
|
- | 957 | ||
- | 958 | vt = VibTest(self.param.descr, voltage, self.param.motors, 0, "AngleRoll", data) |
|
- | 959 | evt = MeasDataEvent(vibTest = vt) |
|
- | 960 | wx.PostEvent(self.evtConsumer, evt) |
|
- | 961 | ||
- | 962 | if voltage<minVoltage: |
|
- | 963 | raise Exception("Voltage too low") |
|
976 | 964 | ||
Line 977... | Line 965... | ||
977 | self._sendEvent("Done !", parVoltage=(minVoltage, maxVoltage, voltage)) |
965 | self._sendEvent("Done !", parVoltage=(minVoltage, maxVoltage, voltage)) |
978 | 966 |