Skip to content

Commit

Permalink
Realtime data works now in the gray text fields. Having the realtime …
Browse files Browse the repository at this point in the history
…data and graphs plotted is next on the todo list.
  • Loading branch information
DieBieEngineering committed Aug 23, 2018
1 parent 815077b commit 014b480
Show file tree
Hide file tree
Showing 83 changed files with 296 additions and 290 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Builds/DieBieMSToolV0.19Windows/Qt5Bluetooth.dll
Binary file not shown.
Binary file added Builds/DieBieMSToolV0.19Windows/Qt5Core.dll
Binary file not shown.
Binary file added Builds/DieBieMSToolV0.19Windows/Qt5Gui.dll
Binary file not shown.
Binary file added Builds/DieBieMSToolV0.19Windows/Qt5Network.dll
Binary file not shown.
Binary file not shown.
Binary file added Builds/DieBieMSToolV0.19Windows/Qt5Qml.dll
Binary file not shown.
Binary file added Builds/DieBieMSToolV0.19Windows/Qt5Quick.dll
Binary file not shown.
Binary file added Builds/DieBieMSToolV0.19Windows/Qt5SerialPort.dll
Binary file not shown.
Binary file added Builds/DieBieMSToolV0.19Windows/Qt5Svg.dll
Binary file not shown.
Binary file added Builds/DieBieMSToolV0.19Windows/Qt5Widgets.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Builds/DieBieMSToolV0.19Windows/libEGL.dll
Binary file not shown.
Binary file added Builds/DieBieMSToolV0.19Windows/libGLESV2.dll
Binary file not shown.
Binary file not shown.
Binary file added Builds/DieBieMSToolV0.19Windows/libstdc++-6.dll
Binary file not shown.
Binary file not shown.
Binary file added Builds/DieBieMSToolV0.19Windows/opengl32sw.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion DieBieMSTool.pro
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#-------------------------------------------------

# Version
DT_VERSION = 0.18
DT_VERSION = 0.19

DEFINES += DT_VERSION=$$DT_VERSION

Expand Down
6 changes: 3 additions & 3 deletions DieBieMSTool.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.7.0, 2018-08-17T19:30:03. -->
<!-- Written by QtCreator 4.7.0, 2018-08-23T20:53:00. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down Expand Up @@ -68,7 +68,7 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.11.1 MinGW 32bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.11.1 MinGW 32bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.qt5.5111.win32_mingw53_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">1</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
Expand Down Expand Up @@ -297,7 +297,7 @@
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">DieBieMSTool.pro</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">C:/Projecten/DieBieMS/GitHub/UserInterface/build-DieBieMSTool-Desktop_Qt_5_11_1_MinGW_32bit-Debug</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory.default">C:/Projecten/DieBieMS/GitHub/UserInterface/build-DieBieMSTool-Desktop_Qt_5_11_1_MinGW_32bit-Release</value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
Expand Down
2 changes: 1 addition & 1 deletion bmsinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ void BMSInterface::fwVersionReceived(int major, int minor, QString hw, QByteArra
" only the firmware can be changed."), false, false);
}
} else if (!fwPairs.contains(fw_connected)) {
if (fw_connected >= qMakePair(1, 1)) {
if (fw_connected >= qMakePair(0, 10)) {
mCommands->setLimitedMode(true);
updateFwRx(true);
if (!wasReceived) {
Expand Down
70 changes: 38 additions & 32 deletions commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,30 +120,31 @@ void Commands::processPacket(QByteArray data)

case COMM_GET_VALUES: {
mTimeoutValues = 0;
MC_VALUES values;
values.temp_mos = vb.vbPopFrontDouble16(1e1);
values.temp_motor = vb.vbPopFrontDouble16(1e1);
values.current_motor = vb.vbPopFrontDouble32(1e2);
values.current_in = vb.vbPopFrontDouble32(1e2);
values.id = vb.vbPopFrontDouble32(1e2);
values.iq = vb.vbPopFrontDouble32(1e2);
values.duty_now = vb.vbPopFrontDouble16(1e3);
values.rpm = vb.vbPopFrontDouble32(1e0);
values.v_in = vb.vbPopFrontDouble16(1e1);
values.amp_hours = vb.vbPopFrontDouble32(1e4);
values.amp_hours_charged = vb.vbPopFrontDouble32(1e4);
values.watt_hours = vb.vbPopFrontDouble32(1e4);
values.watt_hours_charged = vb.vbPopFrontDouble32(1e4);
values.tachometer = vb.vbPopFrontInt32();
values.tachometer_abs = vb.vbPopFrontInt32();
values.fault_code = (mc_fault_code)vb.vbPopFrontInt8();
values.fault_str = faultToStr(values.fault_code);

if (vb.size() >= 4) {
values.position = vb.vbPopFrontDouble32(1e6);
} else {
values.position = -1.0;
}
BMS_VALUES values;

values.packVoltage = vb.vbPopFrontDouble32(1e3);
values.packCurrent = vb.vbPopFrontDouble32(1e3);

values.soC = vb.vbPopFrontUint8();

values.cVHigh = vb.vbPopFrontDouble32(1e3);
values.cVAverage = vb.vbPopFrontDouble32(1e3);
values.cVLow = vb.vbPopFrontDouble32(1e3);
values.cVMisMatch = vb.vbPopFrontDouble32(1e3);

values.loadLCVoltage = vb.vbPopFrontDouble16(1e2);
values.loadLCCurrent = vb.vbPopFrontDouble16(1e2);
values.loadHCVoltage = vb.vbPopFrontDouble16(1e2);
values.loadHCCurrent = vb.vbPopFrontDouble16(1e2);
values.auxVoltage = vb.vbPopFrontDouble16(1e2);
values.auxCurrent = vb.vbPopFrontDouble16(1e2);

values.tempBattHigh = vb.vbPopFrontDouble16(1e1);
values.tempBattAverage = vb.vbPopFrontDouble16(1e1);
values.tempBMSHigh = vb.vbPopFrontDouble16(1e1);
values.tempBMSAverage = vb.vbPopFrontDouble16(1e1);

values.opState = opStateToStr((OperationalStateTypedef)vb.vbPopFrontUint8());

emit valuesReceived(values);
} break;
Expand Down Expand Up @@ -454,16 +455,21 @@ void Commands::firmwareUploadUpdate(bool isTimeout)
}
}

QString Commands::faultToStr(mc_fault_code fault)
QString Commands::opStateToStr(OperationalStateTypedef fault)
{
switch (fault) {
case FAULT_CODE_NONE: return "FAULT_CODE_NONE";
case FAULT_CODE_OVER_VOLTAGE: return "FAULT_CODE_OVER_VOLTAGE";
case FAULT_CODE_UNDER_VOLTAGE: return "FAULT_CODE_UNDER_VOLTAGE";
case FAULT_CODE_DRV: return "FAULT_CODE_DRV";
case FAULT_CODE_ABS_OVER_CURRENT: return "FAULT_CODE_ABS_OVER_CURRENT";
case FAULT_CODE_OVER_TEMP_FET: return "FAULT_CODE_OVER_TEMP_FET";
case FAULT_CODE_OVER_TEMP_MOTOR: return "FAULT_CODE_OVER_TEMP_MOTOR";
case OP_STATE_INIT: return "Init";
case OP_STATE_CHARGING: return "Charging";
case OP_STATE_PRE_CHARGE: return "PreCharging";
case OP_STATE_LOAD_ENABLED: return "Load enabled";
case OP_STATE_BATTERY_DEAD: return "Battery dead";
case OP_STATE_POWER_DOWN: return "Power down";
case OP_STATE_EXTERNAL: return "External";
case OP_STATE_ERROR: return "Error";
case OP_STATE_ERROR_PRECHARGE: return "ErrPreCharge";
case OP_STATE_BALANCING: return "Balancing";
case OP_STATE_CHARGED: return "Charged";
case OP_STATE_FORCEON: return "ForceOn";
default: return "Unknown fault";
}
}
Expand Down
4 changes: 2 additions & 2 deletions commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Commands : public QObject
void dataToSend(QByteArray &data);
void fwVersionReceived(int major, int minor, QString hw, QByteArray uuid);
void ackReceived(QString ackType);
void valuesReceived(MC_VALUES values);
void valuesReceived(BMS_VALUES values);
void printReceived(QString str);
void rotorPosReceived(double pos);
void bmsConfigCheckResult(QStringList paramsNotSet);
Expand All @@ -77,7 +77,7 @@ private slots:
private:
void emitData(QByteArray data);
void firmwareUploadUpdate(bool isTimeout);
QString faultToStr(mc_fault_code fault);
QString opStateToStr(OperationalStateTypedef fault);

QTimer *mTimer;
bool mSendCan;
Expand Down
62 changes: 62 additions & 0 deletions datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,53 @@ struct MC_VALUES {

Q_DECLARE_METATYPE(MC_VALUES)

struct BMS_VALUES {
Q_GADGET

Q_PROPERTY(double packVoltage MEMBER packVoltage)
Q_PROPERTY(double packCurrent MEMBER packCurrent)
Q_PROPERTY(int soC MEMBER soC)
Q_PROPERTY(double cVHigh MEMBER cVHigh)
Q_PROPERTY(double cVAverage MEMBER cVAverage)
Q_PROPERTY(double cVLow MEMBER cVLow)
Q_PROPERTY(double cVMisMatch MEMBER cVMisMatch)
Q_PROPERTY(double loadLCVoltage MEMBER loadLCVoltage)
Q_PROPERTY(double loadLCCurrent MEMBER loadLCCurrent)
Q_PROPERTY(double loadHCVoltage MEMBER loadHCVoltage)
Q_PROPERTY(double loadHCCurrent MEMBER loadHCCurrent)
Q_PROPERTY(double auxVoltage MEMBER auxVoltage)
Q_PROPERTY(double auxCurrent MEMBER auxCurrent)
Q_PROPERTY(double tempBattHigh MEMBER tempBattHigh)
Q_PROPERTY(double tempBattAverage MEMBER tempBattAverage)
Q_PROPERTY(double tempBMSHigh MEMBER tempBMSHigh)
Q_PROPERTY(double tempBMSAverage MEMBER tempBMSAverage)
Q_PROPERTY(QString opState MEMBER opState)
Q_PROPERTY(QString faultState MEMBER faultState)

public:
double packVoltage;
double packCurrent;
int soC;
double cVHigh;
double cVAverage;
double cVLow;
double cVMisMatch;
double loadLCVoltage;
double loadLCCurrent;
double loadHCVoltage;
double loadHCCurrent;
double auxVoltage;
double auxCurrent;
double tempBattHigh;
double tempBattAverage;
double tempBMSHigh;
double tempBMSAverage;
QString opState;
QString faultState;
};

Q_DECLARE_METATYPE(BMS_VALUES)

typedef enum {
DEBUG_SAMPLING_OFF = 0,
DEBUG_SAMPLING_NOW,
Expand Down Expand Up @@ -206,4 +253,19 @@ typedef enum {
NRF_PAIR_FAIL
} NRF_PAIR_RES;

typedef enum {
OP_STATE_INIT = 0, // 0
OP_STATE_CHARGING, // 1
OP_STATE_PRE_CHARGE, // 2
OP_STATE_LOAD_ENABLED, // 3
OP_STATE_BATTERY_DEAD, // 4
OP_STATE_POWER_DOWN, // 5
OP_STATE_EXTERNAL, // 6
OP_STATE_ERROR, // 7
OP_STATE_ERROR_PRECHARGE, // 8
OP_STATE_BALANCING, // 9
OP_STATE_CHARGED, // 10
OP_STATE_FORCEON, // 11
} OperationalStateTypedef;

#endif // DATATYPES_H
2 changes: 1 addition & 1 deletion pages/pagefirmware.ui
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<enum>QTabWidget::Triangular</enum>
</property>
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
Expand Down
3 changes: 3 additions & 0 deletions pages/pagemastergeneral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ void PageMasterGeneral::setDieBieMS(BMSInterface *dieBieMS)
ui->canTab->addParamRow(mDieBieMS->bmsConfig(), "useCANSafetyInput");
ui->canTab->addParamRow(mDieBieMS->bmsConfig(), "useCANDelayedPowerDown");

ui->masterSensorsTab->addRowSeparator(tr("Shunt"));
ui->masterSensorsTab->addParamRow(mDieBieMS->bmsConfig(), "shuntLCFactor");
ui->masterSensorsTab->addParamRow(mDieBieMS->bmsConfig(), "shuntLCOffset");
ui->masterSensorsTab->addRowSeparator(tr("NTC enable mask"));
ui->masterSensorsTab->addParamRow(mDieBieMS->bmsConfig(), "tempEnableMaskBMS");
ui->masterSensorsTab->addParamRow(mDieBieMS->bmsConfig(), "tempEnableMaskBattery");
Expand Down
88 changes: 15 additions & 73 deletions pages/pagertdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ PageRtData::PageRtData(QWidget *parent) :
ui->posPlot->xAxis->setLabel("Sample");
ui->posPlot->yAxis->setLabel("Degrees");

connect(mTimer, SIGNAL(timeout()),
this, SLOT(timerSlot()));
connect(mTimer, SIGNAL(timeout()),this, SLOT(timerSlot()));
}

PageRtData::~PageRtData()
Expand All @@ -162,8 +161,7 @@ void PageRtData::setDieBieMS(BMSInterface *dieBieMS)
mDieBieMS = dieBieMS;

if (mDieBieMS) {
connect(mDieBieMS->commands(), SIGNAL(valuesReceived(MC_VALUES)),this, SLOT(valuesReceived(MC_VALUES)));
connect(mDieBieMS->commands(), SIGNAL(rotorPosReceived(double)),this, SLOT(rotorPosReceived(double)));
connect(mDieBieMS->commands(), SIGNAL(valuesReceived(BMS_VALUES)),this, SLOT(valuesReceived(BMS_VALUES)));
}
}

Expand Down Expand Up @@ -218,7 +216,6 @@ void PageRtData::timerSlot()
xAxis[i] = (double)i;
}

ui->posBar->setValue((int)fabs(mPositionVec.last()));
ui->posPlot->graph(0)->setData(xAxis, mPositionVec);

if (ui->autoscaleButton->isChecked()) {
Expand All @@ -231,20 +228,20 @@ void PageRtData::timerSlot()
}
}

void PageRtData::valuesReceived(MC_VALUES values)
void PageRtData::valuesReceived(BMS_VALUES values)
{
ui->rtText->setValues(values);

const int maxS = 500;

appendDoubleAndTrunc(&mTempMosVec, values.temp_mos, maxS);
appendDoubleAndTrunc(&mTempMotorVec, values.temp_motor, maxS);
appendDoubleAndTrunc(&mCurrInVec, values.current_in, maxS);
appendDoubleAndTrunc(&mCurrMotorVec, values.current_motor, maxS);
appendDoubleAndTrunc(&mIdVec, values.id, maxS);
appendDoubleAndTrunc(&mIqVec, values.iq, maxS);
appendDoubleAndTrunc(&mDutyVec, values.duty_now, maxS);
appendDoubleAndTrunc(&mRpmVec, values.rpm, maxS);
//appendDoubleAndTrunc(&mTempMosVec, values.temp_mos, maxS);
//appendDoubleAndTrunc(&mTempMotorVec, values.temp_motor, maxS);
//appendDoubleAndTrunc(&mCurrInVec, values.current_in, maxS);
//appendDoubleAndTrunc(&mCurrMotorVec, values.current_motor, maxS);
//appendDoubleAndTrunc(&mIdVec, values.id, maxS);
//appendDoubleAndTrunc(&mIqVec, values.iq, maxS);
//appendDoubleAndTrunc(&mDutyVec, values.duty_now, maxS);
//appendDoubleAndTrunc(&mRpmVec, values.rpm, maxS);

qint64 tNow = QDateTime::currentMSecsSinceEpoch();

Expand All @@ -253,19 +250,13 @@ void PageRtData::valuesReceived(MC_VALUES values)
elapsed = 1.0;
}

mSecondCounter += elapsed;
//mSecondCounter += elapsed;

appendDoubleAndTrunc(&mSeconds, mSecondCounter, maxS);
//appendDoubleAndTrunc(&mSeconds, mSecondCounter, maxS);

mLastUpdateTime = tNow;
//mLastUpdateTime = tNow;

mUpdateValPlot = true;
}

void PageRtData::rotorPosReceived(double pos)
{
appendDoubleAndTrunc(&mPositionVec, pos, 1500);
mUpdatePosPlot = true;
//mUpdateValPlot = true;
}

void PageRtData::appendDoubleAndTrunc(QVector<double> *vec, double num, int maxSize)
Expand Down Expand Up @@ -317,55 +308,6 @@ void PageRtData::on_rescaleButton_clicked()
ui->posPlot->replot();
}

void PageRtData::on_posInductanceButton_clicked()
{
if (mDieBieMS) {
mDieBieMS->commands()->setDetect(DISP_POS_MODE_INDUCTANCE);
}
}

void PageRtData::on_posObserverButton_clicked()
{
if (mDieBieMS) {
mDieBieMS->commands()->setDetect(DISP_POS_MODE_OBSERVER);
}
}

void PageRtData::on_posEncoderButton_clicked()
{
if (mDieBieMS) {
mDieBieMS->commands()->setDetect(DISP_POS_MODE_ENCODER);
}
}

void PageRtData::on_posPidButton_clicked()
{
if (mDieBieMS) {
mDieBieMS->commands()->setDetect(DISP_POS_MODE_PID_POS);
}
}

void PageRtData::on_posPidErrorButton_clicked()
{
if (mDieBieMS) {
mDieBieMS->commands()->setDetect(DISP_POS_MODE_PID_POS_ERROR);
}
}

void PageRtData::on_posEncoderObserverErrorButton_clicked()
{
if (mDieBieMS) {
mDieBieMS->commands()->setDetect(DISP_POS_MODE_ENCODER_OBSERVER_ERROR);
}
}

void PageRtData::on_posStopButton_clicked()
{
if (mDieBieMS) {
mDieBieMS->commands()->setDetect(DISP_POS_MODE_NONE);
}
}

void PageRtData::on_tempShowMosfetBox_toggled(bool checked)
{
ui->tempPlot->graph(0)->setVisible(checked);
Expand Down
10 changes: 1 addition & 9 deletions pages/pagertdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,11 @@ class PageRtData : public QWidget

private slots:
void timerSlot();
void valuesReceived(MC_VALUES values);
void rotorPosReceived(double pos);
void valuesReceived(BMS_VALUES values);

void on_zoomHButton_toggled(bool checked);
void on_zoomVButton_toggled(bool checked);
void on_rescaleButton_clicked();
void on_posInductanceButton_clicked();
void on_posObserverButton_clicked();
void on_posEncoderButton_clicked();
void on_posPidButton_clicked();
void on_posPidErrorButton_clicked();
void on_posEncoderObserverErrorButton_clicked();
void on_posStopButton_clicked();
void on_tempShowMosfetBox_toggled(bool checked);
void on_tempShowMotorBox_toggled(bool checked);

Expand Down
Loading

0 comments on commit 014b480

Please sign in to comment.