Skip to content

Commit

Permalink
Merge pull request #107 from Tom-evnut/FeatureUpdateSept24
Browse files Browse the repository at this point in the history
Feature update sept24
  • Loading branch information
damienmaguire authored Sep 26, 2024
2 parents 02074ea + 5f4f316 commit fa59d79
Show file tree
Hide file tree
Showing 18 changed files with 940 additions and 398 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ OBJSL = $(BINARY).o hwinit.o stm32scheduler.o params.o terminal.o terminal_prj.
chademo.o amperaheater.o amperacharger.o subaruvehicle.o iomatrix.o bmw_sbox.o NissanPDM.o teslaCharger.o extCharger.o vag_sbox.o \
daisychainbms.o simpbms.o outlanderCharger.o Can_OBD2.o cansdo.o TeslaDCDC.o BMW_E31.o F30_Lever.o \
CPC.o ElconCharger.o RearOutlanderinverter.o linbus.o VWheater.o JLR_G1.o JLR_G2.o Focci.o digipot.o\
E65_Lever.o
E65_Lever.o leafbms.o V_Classic.o

OBJS = $(patsubst %.o,$(OUT_DIR)/%.o, $(OBJSL))
vpath %.c src/ libopeninv/src/
Expand Down
1 change: 0 additions & 1 deletion include/BMW_E65.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class BMW_E65: public Vehicle
void DecodeCAN(int, uint32_t* data);
bool Ready() { return terminal15On; }
bool Start() { return terminal15On; }
bool GetGear(Vehicle::gear& outGear);
void DashOff();
void handle130(uint32_t data[2]);
void handle192(uint32_t data[2]);
Expand Down
50 changes: 50 additions & 0 deletions include/V_Classic.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* This file is part of the Zombieverter project.
*
* Copyright (C) 2023 Damien Maguire
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef V_Classic_h
#define V_Classic_h


#include <stdint.h>
#include "vehicle.h"
#include "digio.h"
#include "utils.h"
#include "stm32_can.h"

class V_Classic: public Vehicle
{

public:
void SetCanInterface(CanHardware* c);
void Task10Ms();
void Task100Ms();
void Task1Ms();
void SetRevCounter(int s);
void SetTemperatureGauge(float temp);
bool Ready();
bool Start();


private:
uint16_t speed;

};

#endif /* BMW_E31_h */


70 changes: 43 additions & 27 deletions include/param_prj.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,25 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#define VER 2.20.TC

#define VER 2.20.TJ


/* Entries must be ordered as follows:
1. Saveable parameters (id != 0)
2. Temporary parameters (id = 0)
3. Display values
*/
//Next param id (increase when adding new parameter!): 134
//Next param id (increase when adding new parameter!): 138
/* category name unit min max default id */
#define PARAM_LIST \
PARAM_ENTRY(CAT_SETUP, Inverter, INVMODES, 0, 8, 0, 5 ) \
PARAM_ENTRY(CAT_SETUP, Vehicle, VEHMODES, 0, 8, 0, 6 ) \
PARAM_ENTRY(CAT_SETUP, GearLvr, SHIFTERS, 0, 4, 0, 108 ) \
PARAM_ENTRY(CAT_SETUP, Transmission, TRNMODES, 0, 1, 0, 78 ) \
PARAM_ENTRY(CAT_SETUP, interface, CHGINT, 0, 4, 0, 39 ) \
PARAM_ENTRY(CAT_SETUP, chargemodes, CHGMODS, 0, 6, 0, 37 ) \
PARAM_ENTRY(CAT_SETUP, BMS_Mode, BMSMODES, 0, 4, 0, 90 ) \
PARAM_ENTRY(CAT_SETUP, ShuntType, SHNTYPE, 0, 3, 0, 88 ) \
PARAM_ENTRY(CAT_SETUP, InverterCan, CAN_DEV, 0, 1, 0, 70 ) \
PARAM_ENTRY(CAT_SETUP, VehicleCan, CAN_DEV, 0, 1, 1, 71 ) \
PARAM_ENTRY(CAT_SETUP, ShuntCan, CAN_DEV, 0, 1, 0, 72 ) \
Expand All @@ -44,7 +45,6 @@
PARAM_ENTRY(CAT_SETUP, OBD2Can, CAN_DEV, 0, 1, 0, 96 ) \
PARAM_ENTRY(CAT_SETUP, CanMapCan, CAN_DEV, 0, 1, 0, 97 ) \
PARAM_ENTRY(CAT_SETUP, DCDCCan, CAN_DEV, 0, 1, 1, 107 ) \
PARAM_ENTRY(CAT_SETUP, GearLvr, SHIFTERS, 0, 4, 0, 108 ) \
PARAM_ENTRY(CAT_SETUP, MotActive, MotorsAct, 0, 2, 0, 129 ) \
PARAM_ENTRY(CAT_THROTTLE, potmin, "dig", 0, 4095, 0, 7 ) \
PARAM_ENTRY(CAT_THROTTLE, potmax, "dig", 0, 4095, 4095, 8 ) \
Expand All @@ -54,15 +54,14 @@
PARAM_ENTRY(CAT_THROTTLE, regenendrpm,"rpm", 100, 10000, 100, 126 ) \
PARAM_ENTRY(CAT_THROTTLE, regenmax, "%", -30, 0, -10, 61 ) \
PARAM_ENTRY(CAT_THROTTLE, regenBrake, "%", -30, 0, -10, 122 ) \
PARAM_ENTRY(CAT_THROTTLE, regenramp, "%/10ms", 0.1, 100, 1, 68 ) \
PARAM_ENTRY(CAT_THROTTLE, regenramp, "%/10ms", 0.1, 100, 1, 68 ) \
PARAM_ENTRY(CAT_THROTTLE, potmode, POTMODES, 0, 1, 0, 11 ) \
PARAM_ENTRY(CAT_THROTTLE, dirmode, DIRMODES, 0, 4, 1, 12 ) \
PARAM_ENTRY(CAT_THROTTLE, reversemotor, ONOFF, 0, 1, 0, 127 ) \
PARAM_ENTRY(CAT_THROTTLE, throtramp, "%/10ms", 1, 100, 10, 13 ) \
PARAM_ENTRY(CAT_THROTTLE, throtramp, "%/10ms", 1, 100, 10, 13 ) \
PARAM_ENTRY(CAT_THROTTLE, throtramprpm,"rpm", 0, 20000, 20000, 14 ) \
PARAM_ENTRY(CAT_THROTTLE, revlim, "rpm", 0, 20000, 6000, 15 ) \
PARAM_ENTRY(CAT_THROTTLE, bmslimhigh, "%", 0, 100, 50, 17 ) \
PARAM_ENTRY(CAT_THROTTLE, bmslimlow, "%", -100, 0, -1, 18 ) \
PARAM_ENTRY(CAT_THROTTLE, revRegen, ONOFF, 0, 1, 0, 137 ) \
PARAM_ENTRY(CAT_THROTTLE, udcmin, "V", 0, 1000, 450, 19 ) \
PARAM_ENTRY(CAT_THROTTLE, udclim, "V", 0, 1000, 520, 20 ) \
PARAM_ENTRY(CAT_THROTTLE, idcmax, "A", 0, 5000, 5000, 21 ) \
Expand Down Expand Up @@ -98,7 +97,6 @@
PARAM_ENTRY(CAT_CHARGER, ConfigFocci, ONOFF, 0, 1, 0, 133) \
PARAM_ENTRY(CAT_DCDC, DCdc_Type, DCDCTYPES, 0, 1, 0, 105 ) \
PARAM_ENTRY(CAT_DCDC, DCSetPnt, "V", 9, 15, 14, 106 ) \
PARAM_ENTRY(CAT_BMS, BMS_Mode, BMSMODES, 0, 3, 0, 90 ) \
PARAM_ENTRY(CAT_BMS, BMS_Timeout, "sec", 1, 120, 10, 91 ) \
PARAM_ENTRY(CAT_BMS, BMS_VminLimit, "V", 0, 10, 3.0, 92 ) \
PARAM_ENTRY(CAT_BMS, BMS_VmaxLimit, "V", 0, 10, 4.2, 93 ) \
Expand All @@ -118,14 +116,15 @@
PARAM_ENTRY(CAT_CLOCK, Pre_Hrs, "Hours", 0, 59, 0, 53 ) \
PARAM_ENTRY(CAT_CLOCK, Pre_Min, "Mins", 0, 59, 0, 54 ) \
PARAM_ENTRY(CAT_CLOCK, Pre_Dur, "Mins", 0, 60, 0, 55 ) \
PARAM_ENTRY(CAT_IOPINS, Out1Func, PINFUNCS, 0, 13, 6, 80 ) \
PARAM_ENTRY(CAT_IOPINS, Out2Func, PINFUNCS, 0, 13, 7, 81 ) \
PARAM_ENTRY(CAT_IOPINS, Out3Func, PINFUNCS, 0, 13, 3, 82 ) \
PARAM_ENTRY(CAT_IOPINS, SL1Func, PINFUNCS, 0, 13, 0, 83 ) \
PARAM_ENTRY(CAT_IOPINS, SL2Func, PINFUNCS, 0, 13, 0, 84 ) \
PARAM_ENTRY(CAT_IOPINS, PWM1Func, PINFUNCS, 0, 14, 0, 85 ) \
PARAM_ENTRY(CAT_IOPINS, PWM2Func, PINFUNCS, 0, 14, 4, 86 ) \
PARAM_ENTRY(CAT_IOPINS, PWM3Func, PINFUNCS, 0, 15, 2, 87 ) \
PARAM_ENTRY(CAT_IOPINS, PumpPWM, PumpOutType,0, 1, 0, 135 ) \
PARAM_ENTRY(CAT_IOPINS, Out1Func, PINFUNCS, 0, 15, 6, 80 ) \
PARAM_ENTRY(CAT_IOPINS, Out2Func, PINFUNCS, 0, 15, 7, 81 ) \
PARAM_ENTRY(CAT_IOPINS, Out3Func, PINFUNCS, 0, 15, 3, 82 ) \
PARAM_ENTRY(CAT_IOPINS, SL1Func, PINFUNCS, 0, 15, 0, 83 ) \
PARAM_ENTRY(CAT_IOPINS, SL2Func, PINFUNCS, 0, 15, 0, 84 ) \
PARAM_ENTRY(CAT_IOPINS, PWM1Func, PINFUNCS, 0, 18, 0, 85 ) \
PARAM_ENTRY(CAT_IOPINS, PWM2Func, PINFUNCS, 0, 18, 4, 86 ) \
PARAM_ENTRY(CAT_IOPINS, PWM3Func, PINFUNCS, 0, 18, 2, 87 ) \
PARAM_ENTRY(CAT_IOPINS, GP12VInFunc, PINFUNCS, 0, 13, 12, 98 ) \
PARAM_ENTRY(CAT_IOPINS, HVReqFunc, PINFUNCS, 0, 13, 11, 99 ) \
PARAM_ENTRY(CAT_IOPINS, GPA1Func, APINFUNCS, 0, 2, 0, 110 ) \
Expand All @@ -135,8 +134,9 @@
PARAM_ENTRY(CAT_IOPINS, BrkVacHyst, "dig", 0, 4095, 2500, 116 ) \
PARAM_ENTRY(CAT_IOPINS, DigiPot1Step,"dig", 0, 255, 0, 117 ) \
PARAM_ENTRY(CAT_IOPINS, DigiPot2Step,"dig", 0, 255, 0, 118 ) \
PARAM_ENTRY(CAT_IOPINS, FanTemp, "°C", 0, 100, 40, 134 ) \
PARAM_ENTRY(CAT_IOPINS, TachoPPR, "PPR", 0, 100, 2, 136 ) \
PARAM_ENTRY(CAT_SHUNT, IsaInit, ONOFF, 0, 1, 0, 75 ) \
PARAM_ENTRY(CAT_SHUNT, Type, SHNTYPE, 0, 2, 0, 88 ) \
PARAM_ENTRY(CAT_PWM, Tim3_Presc, "", 1, 72000, 719, 100 ) \
PARAM_ENTRY(CAT_PWM, Tim3_Period, "", 1, 100000, 7200, 101 ) \
PARAM_ENTRY(CAT_PWM, Tim3_1_OC, "", 1, 100000, 3600, 102 ) \
Expand All @@ -148,6 +148,7 @@
VALUE_ENTRY(chgtyp, CHGTYPS, 2003 ) \
VALUE_ENTRY(lasterr, errorListString, 2004 ) \
VALUE_ENTRY(status, STATUS, 2005 ) \
VALUE_ENTRY(TorqDerate, LIMITREASON, 2102 ) \
VALUE_ENTRY(udc, "V", 2006 ) \
VALUE_ENTRY(udc2, "V", 2007 ) \
VALUE_ENTRY(udc3, "V", 2008 ) \
Expand All @@ -163,6 +164,7 @@
VALUE_ENTRY(BMS_Tmin, "°C", 2086 ) \
VALUE_ENTRY(BMS_Tmax, "°C", 2087 ) \
VALUE_ENTRY(BMS_ChargeLim, "A", 2088 ) \
VALUE_ENTRY(BMS_IsoMeas, "mV", 2099 ) \
VALUE_ENTRY(speed, "rpm", 2016 ) \
VALUE_ENTRY(Veh_Speed, "kph", 2017 ) \
VALUE_ENTRY(torque, "dig", 2018 ) \
Expand Down Expand Up @@ -228,28 +230,33 @@
VALUE_ENTRY(tmpheater, "°C", 2096 ) \
VALUE_ENTRY(udcheater, "V", 2097 ) \
VALUE_ENTRY(powerheater, "W", 2098 ) \
VALUE_ENTRY(VehLockSt, ONOFF, 2100 ) \

//Next value Id: 2101
VALUE_ENTRY(VehLockSt, ONOFF, 2100 ) \

//Next value Id: 2102

//Dead params
/*
PARAM_ENTRY(CAT_THROTTLE, bmslimhigh, "%", 0, 100, 50, 17 ) \
PARAM_ENTRY(CAT_THROTTLE, bmslimlow, "%", -100, 0, -1, 18 ) \
*/
//////////

#define VERSTR STRINGIFY(4=VER)

#define PINFUNCS "0=None, 1=ChaDeMoAlw, 2=OBCEnable, 3=HeaterEnable, 4=RunIndication, 5=WarnIndication," \
"6=CoolantPump, 7=NegContactor, 8=BrakeLight, 9=ReverseLight, 10=HeatReq, 11=HVRequest," \
"12=DCFCRequest, 13=BrakeVacPump, 14=PwmTim3, 15=CpSpoof"
"12=DCFCRequest, 13=BrakeVacPump, 14=CoolingFan, 15=HvActive, 16=PwmTim3, 17=CpSpoof,"\
"18=GS450pump"
#define APINFUNCS "0=None, 1=ProxPilot, 2=BrakeVacSensor"
#define SHIFTERS "0=None, 1=BMW_F30, 2=JLR_G1, 3=JLR_G2, 4=BMW_E65"
#define SHNTYPE "0=ISA, 1=SBOX, 2=VAG"
#define SHNTYPE "0=None, 1=ISA, 2=SBOX, 3=VAG"
#define DMODES "0=CLOSED, 1=OPEN, 2=ERROR, 3=INVALID"
#define POTMODES "0=SingleChannel, 1=DualChannel"
#define BTNSWITCH "0=Button, 1=Switch, 2=CAN"
#define DIRMODES "0=Button, 1=Switch, 2=ButtonReversed, 3=SwitchReversed, 4=DefaultForward"
#define INVMODES "0=None, 1=Leaf_Gen1, 2=GS450H, 3=UserCAN, 4=OpenI, 5=Prius_Gen3, 6=Outlander, 7=GS300H, 8=RearOutlander"
#define PLTMODES "0=Absent, 1=ACStd, 2=ACchg, 3=Error, 4=CCS_Not_Rdy, 5=CCS_Rdy, 6=Static"
#define VEHMODES "0=BMW_E46, 1=BMW_E6x+, 2=Classic, 3=None, 5=BMW_E39, 6=VAG, 7=Subaru, 8=BMW_E31"
#define BMSMODES "0=Off, 1=SimpBMS, 2=TiDaisychainSingle, 3=TiDaisychainDual"
#define BMSMODES "0=Off, 1=SimpBMS, 2=TiDaisychainSingle, 3=TiDaisychainDual, 4=LeafBms"
#define OPMODES "0=Off, 1=Run, 2=Precharge, 3=PchFail, 4=Charge"
#define DOW "0=Sun, 1=Mon, 2=Tue, 3=Wed, 4=Thu, 5=Fri, 6=Sat"
#define CHGTYPS "0=Off, 1=AC, 2=DCFC"
Expand Down Expand Up @@ -291,6 +298,14 @@
#define CAT_IOPINS "General Purpose I/O"
#define CAT_PWM "PWM Control"
#define MotorsAct "0=Mg1and2, 1=Mg1, 2=Mg2"
#define PumpOutType "0=GS450hOil, 1=TachoOut"
#define LIMITREASON "0=None, 1=UDClimLow, 2=UDClimHigh, 3=UDClimHigh+UDClimHigh, 4=IDClimLow, 5=UDClimLow+IDClimLow, 6=UDClimHigh+IDClimLow,"\
"7=UDClimLow+UDClimHigh+IDClimLow, 8=IDClimHigh, 9=UDClimLow+IDClimHigh, 10=UDClimHigh+IDClimHigh, 11=UDClimHigh+UDClimHigh+IDClimHigh,"\
"12=IDClimLow+IDClimHigh, 13=UDClimHigh+IDClimLow+IDClimHigh 14=UDClimHigh+IDClimLow+IDClimHigh, 15=UDClimLow+UDClimHigh+IDClimLow+IDClimHigh,"\
"16=TempLim, 17=UDClimLow+TempLim, 18=UDClimHigh+TempLim, 19=UDClimHigh+UDClimHigh+TempLim, 20=IDClimLow+TempLim, 21=UDClimLow+IDClimLow+TempLim,"\
"22=UDClimHigh+IDClimLow+TempLim, 23=UDClimLow+UDClimHigh+IDClimLow+TempLim, 24=IDClimHigh+TempLim, 25=UDClimLow+IDClimHigh+TempLim,"\
"26=UDClimHigh+IDClimHigh+TempLim, 27=UDClimHigh+UDClimHigh+IDClimHigh+TempLim, 28=IDClimLow+IDClimHigh+TempLim,"\
"29=UDClimHigh+IDClimLow+IDClimHigh+TempLim, 30=UDClimHigh+IDClimLow+IDClimHigh+TempLim,31=UDClimLow+UDClimHigh+IDClimLow+IDClimHigh+TempLim"

#define CAN_PERIOD_100MS 0
#define CAN_PERIOD_10MS 1
Expand Down Expand Up @@ -374,7 +389,8 @@ enum BMSModes
BMSModeNoBMS = 0,
BMSModeSimpBMS = 1,
BMSModeDaisychainSingleBMS = 2,
BMSModeDaisychainDualBMS = 3
BMSModeDaisychainDualBMS = 3,
BMSModeLeafBMS = 4
};

enum DCDCModes
Expand Down
4 changes: 3 additions & 1 deletion include/stm32_vcu.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,15 @@
#include "noHeater.h"
#include "bms.h"
#include "simpbms.h"
#include "leafbms.h"
#include "daisychainbms.h"
#include "outlanderCharger.h"
#include "Can_OBD2.h"
#include "dcdc.h"
#include "TeslaDCDC.h"
#include "BMW_E31.h"
#include "digipot.h"
#include "shifter.h"
#include "DigiPot.h"
#include "F30_Lever.h"
#include "E65_Lever.h"
#include "JLR_G1.h"
Expand All @@ -93,6 +94,7 @@
#include "ElconCharger.h"
#include "rearoutlanderinverter.h"
#include "NoVehicle.h"
#include "V_Classic.h"

#define PRECHARGE_TIMEOUT 5 //5s

Expand Down
2 changes: 1 addition & 1 deletion include/subaruvehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define SUBARUVEHICLE_H

#include <vehicle.h>

#include "utils.h"

class SubaruVehicle : public Vehicle
{
Expand Down
21 changes: 19 additions & 2 deletions include/utils.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
#ifndef UTILS_H
#define UTILS_H


#include "my_fp.h"
#include "my_math.h"
#include "errormessage.h"
#include "params.h"
#include "digio.h"
#include <libopencm3/stm32/rtc.h>
#include "canhardware.h"
#include "anain.h"
#include "throttle.h"
#include "isa_shunt.h"
#include "bmw_sbox.h"
#include "vag_sbox.h"
#include "vehicle.h"
#include "shifter.h"
#include <libopencm3/stm32/timer.h>
#include "iomatrix.h"
#include "hwinit.h"

#include "canhardware.h"
#include "errormessage.h"

namespace utils
{
Expand All @@ -24,6 +38,9 @@ namespace utils
void displayThrottle();
void ProcessCruiseControlButtons();
void CpSpoofOutput();
void SpeedoSet(uint16_t speed);
void SpeedoStart();
void GS450hOilPump(uint16_t pumpdc);
}

#endif
24 changes: 4 additions & 20 deletions src/BMW_E31.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,18 @@
void BMW_E31::SetCanInterface(CanHardware* c)
{
can = c;
tim_setup();//Fire up timer one...
timer_disable_counter(TIM1);//...but disable until needed
//note we are trying to reuse the lexus gs450h oil pump pwm output here to drive the tach
//Be aware this will prevent combo of E31 and GS450H for now ...
timerIsRunning=false;

utils::SpeedoStart();
can->RegisterUserMessage(0x153);//ASC message. Will confirm.
}


void BMW_E31::SetRevCounter(int speed)
{

uint16_t speed_input = speed;
speed_input = MAX(750, speed_input);//
speed_input = MIN(7500, speed_input);
timerPeriod = 30000000 / speed_input; //TODO: find correct factor or make parameter. current gives 52Hz at 750rpm.
timer_set_period(TIM1, timerPeriod);
timer_set_oc_value(TIM1, TIM_OC1, timerPeriod / 2); //always stay at 50% duty cycle

utils::SpeedoSet(speed_input);//Moved pwm control into Utils
}


Expand Down Expand Up @@ -173,18 +165,10 @@ void BMW_E31::Task10Ms()

void BMW_E31::Task100Ms()
{

if(Param::GetInt(Param::T15Stat) && !timerIsRunning)
if (!Param::GetInt(Param::T15Stat))
{
timer_enable_counter(TIM1);
timerIsRunning=true;
utils::SpeedoSet(0);//set speedo off
}
else if (!Param::GetInt(Param::T15Stat) && timerIsRunning)
{
timer_disable_counter(TIM1);
timerIsRunning=false;
}

}


Expand Down
2 changes: 2 additions & 0 deletions src/BMW_E65.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,9 @@ void BMW_E65::Engine_Data()

}


bool BMW_E65::GetGear(Vehicle::gear& outGear __attribute__((unused)))
{
return false;
}

Loading

0 comments on commit fa59d79

Please sign in to comment.