Commit f99ca120 authored by Erik Andresen's avatar Erik Andresen

move voltage calculation out of libroboint to python

parent bb258fc7
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -2,64 +2,77 @@
# Form implementation generated from reading ui file 'open.ui'
#
# Created: Sun Aug 24 15:00:54 2008
# by: PyQt4 UI code generator 4.4.2
# Created by: PyQt4 UI code generator 4.11.4
#
# WARNING! All changes made in this file will be lost!
from PyQt4 import QtCore, QtGui
try:
_fromUtf8 = QtCore.QString.fromUtf8
except AttributeError:
def _fromUtf8(s):
return s
try:
_encoding = QtGui.QApplication.UnicodeUTF8
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig, _encoding)
except AttributeError:
def _translate(context, text, disambig):
return QtGui.QApplication.translate(context, text, disambig)
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(600,300)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed,QtGui.QSizePolicy.Fixed)
Dialog.setObjectName(_fromUtf8("Dialog"))
Dialog.resize(600, 300)
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(Dialog.sizePolicy().hasHeightForWidth())
Dialog.setSizePolicy(sizePolicy)
Dialog.setMinimumSize(QtCore.QSize(600,300))
Dialog.setMaximumSize(QtCore.QSize(600,300))
Dialog.setMinimumSize(QtCore.QSize(600, 300))
Dialog.setMaximumSize(QtCore.QSize(600, 300))
self.radioButton_Serial = QtGui.QRadioButton(Dialog)
self.radioButton_Serial.setGeometry(QtCore.QRect(20,80,211,31))
self.radioButton_Serial.setObjectName("radioButton_Serial")
self.radioButton_Serial.setGeometry(QtCore.QRect(20, 80, 211, 31))
self.radioButton_Serial.setObjectName(_fromUtf8("radioButton_Serial"))
self.radioButton_USB = QtGui.QRadioButton(Dialog)
self.radioButton_USB.setGeometry(QtCore.QRect(20,20,121,25))
self.radioButton_USB.setGeometry(QtCore.QRect(20, 20, 121, 25))
self.radioButton_USB.setChecked(True)
self.radioButton_USB.setObjectName("radioButton_USB")
self.radioButton_USB.setObjectName(_fromUtf8("radioButton_USB"))
self.comboBox = QtGui.QComboBox(Dialog)
self.comboBox.setGeometry(QtCore.QRect(150,20,421,31))
self.comboBox.setObjectName("comboBox")
self.comboBox.setGeometry(QtCore.QRect(150, 20, 421, 31))
self.comboBox.setObjectName(_fromUtf8("comboBox"))
self.buttonBox = QtGui.QDialogButtonBox(Dialog)
self.buttonBox.setGeometry(QtCore.QRect(210,220,177,29))
self.buttonBox.setGeometry(QtCore.QRect(210, 220, 177, 29))
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
self.buttonBox.setObjectName("buttonBox")
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
self.lineEdit = QtGui.QLineEdit(Dialog)
self.lineEdit.setGeometry(QtCore.QRect(400,140,171,30))
self.lineEdit.setObjectName("lineEdit")
self.lineEdit.setGeometry(QtCore.QRect(400, 140, 171, 30))
self.lineEdit.setObjectName(_fromUtf8("lineEdit"))
self.radioButton_Serial_II = QtGui.QRadioButton(Dialog)
self.radioButton_Serial_II.setGeometry(QtCore.QRect(20,110,241,25))
self.radioButton_Serial_II.setObjectName("radioButton_Serial_II")
self.radioButton_Serial_II.setGeometry(QtCore.QRect(20, 110, 241, 25))
self.radioButton_Serial_II.setObjectName(_fromUtf8("radioButton_Serial_II"))
self.radioButton_Serial_II_Slave = QtGui.QRadioButton(Dialog)
self.radioButton_Serial_II_Slave.setGeometry(QtCore.QRect(20,140,331,25))
self.radioButton_Serial_II_Slave.setObjectName("radioButton_Serial_II_Slave")
self.radioButton_Serial_II_Slave.setGeometry(QtCore.QRect(20, 140, 331, 25))
self.radioButton_Serial_II_Slave.setObjectName(_fromUtf8("radioButton_Serial_II_Slave"))
self.label = QtGui.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(400,120,111,18))
self.label.setObjectName("label")
self.label.setGeometry(QtCore.QRect(400, 120, 111, 18))
self.label.setObjectName(_fromUtf8("label"))
self.checkBox = QtGui.QCheckBox(Dialog)
self.checkBox.setGeometry(QtCore.QRect(340,60,231,31))
self.checkBox.setObjectName("checkBox")
self.checkBox.setGeometry(QtCore.QRect(340, 60, 231, 31))
self.checkBox.setObjectName(_fromUtf8("checkBox"))
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
self.radioButton_Serial.setText(QtGui.QApplication.translate("Dialog", "Serial Robo Interface", None, QtGui.QApplication.UnicodeUTF8))
self.radioButton_USB.setText(QtGui.QApplication.translate("Dialog", "USB Device", None, QtGui.QApplication.UnicodeUTF8))
self.lineEdit.setText(QtGui.QApplication.translate("Dialog", "/dev/ttyS0", None, QtGui.QApplication.UnicodeUTF8))
self.radioButton_Serial_II.setText(QtGui.QApplication.translate("Dialog", "Serial Intelligent Interface", None, QtGui.QApplication.UnicodeUTF8))
self.radioButton_Serial_II_Slave.setText(QtGui.QApplication.translate("Dialog", "Serial Intelligent Interface with Slave", None, QtGui.QApplication.UnicodeUTF8))
self.label.setText(QtGui.QApplication.translate("Dialog", "Serial Device:", None, QtGui.QApplication.UnicodeUTF8))
self.checkBox.setText(QtGui.QApplication.translate("Dialog", "D1/D2 in distance mode", None, QtGui.QApplication.UnicodeUTF8))
Dialog.setWindowTitle(_translate("Dialog", "Dialog", None))
self.radioButton_Serial.setText(_translate("Dialog", "Serial Robo Interface", None))
self.radioButton_USB.setText(_translate("Dialog", "USB Device", None))
self.lineEdit.setText(_translate("Dialog", "/dev/ttyS0", None))
self.radioButton_Serial_II.setText(_translate("Dialog", "Serial Intelligent Interface", None))
self.radioButton_Serial_II_Slave.setText(_translate("Dialog", "Serial Intelligent Interface with Slave", None))
self.label.setText(_translate("Dialog", "Serial Device:", None))
self.checkBox.setText(_translate("Dialog", "D1/D2 in distance mode", None))
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -1063,14 +1063,10 @@ static void *FtThread(FT_HANDLE hFt)
}
}
// AV Values
if (num_read == 6) { // FT_ROBO_IO_EXTENSION/FT_ROBO_LT_CONTROLLER
area->AV = 3.1267*AV-51.068;
} else {
area->AV = 8.63*AV-1775;
area->AVS1 = 8.63*AVS1-1775;
area->AVS2 = 8.63*AVS2-1775;
area->AVS3 = 8.63*AVS3-1775;
}
area->AV = AV;
area->AVS1 = AVS1;
area->AVS2 = AVS2;
area->AVS3 = AVS3;
sem_post(&hFt->lock);
hFt->interface_connected = 1;
......
......@@ -533,6 +533,13 @@ class RoboInterface:
return self.transfer_area.D2
return 0
def av_to_v(self, av):
"""Converts analog value 0..1023 in voltage
"""
if self.GetDeviceType() in [self.FT_ROBO_IO_EXTENSION, self.FT_ROBO_LT_CONTROLLER]:
return 0.03*av
return 8.63*av-1775
def GetAV(self):
"""Get the value of AV (power supply)
......@@ -540,7 +547,7 @@ class RoboInterface:
Will return a number between 0 and 1024
"""
if self.transfer_area:
return self.transfer_area.AV
return self.av_to_v(self.transfer_area.AV)
return 0
......@@ -550,7 +557,7 @@ class RoboInterface:
Will return a number between 0 and 1024
"""
if self.transfer_area:
return self.transfer_area.AVS1
return self.av_to_v(self.transfer_area.AVS1)
return 0
......@@ -560,7 +567,7 @@ class RoboInterface:
Will return a number between 0 and 1024
"""
if self.transfer_area:
return self.transfer_area.AVS2
return self.av_to_v(self.transfer_area.AVS2)
return 0
......@@ -570,7 +577,7 @@ class RoboInterface:
Will return a number between 0 and 1024
"""
if self.transfer_area:
return self.transfer_area.AVS3
return self.av_to_v(self.transfer_area.AVS3)
return 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment