Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iobox support #35

Closed
wants to merge 93 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
b5bca8a
heater: 5 sec stabilization time after switching to closed loop
dron0gus Jul 15, 2022
2b634a0
heater_control: retry heating attempt after timeout
dron0gus Feb 4, 2023
2539428
heater_control: report SensorNoHeatSupply if no supply
dron0gus Feb 19, 2023
209918d
f1_dual: select bigger Vbat voltage from two heater voltages
dron0gus Feb 1, 2023
6ac008c
TODO
dron0gus Feb 1, 2023
de8b629
livedata: show per-channel heater supply voltage
dron0gus Feb 1, 2023
f1bc573
livedata: show Nernst voltage
dron0gus Apr 26, 2023
ae9bf40
Rename GetInternalBatteryVoltage() to GetInternalHeaterVoltage()
dron0gus Jul 21, 2023
7918a0f
sampling, heater: fix Battery vs Heater naming mess
dron0gus Jul 21, 2023
a3b5321
heater: always rely on localy measured heater voltage
dron0gus Jul 21, 2023
3bf989b
build: fix hex file generation
dron0gus Sep 24, 2023
daf4867
Fix reset to DFU command
dron0gus Sep 24, 2023
0b876f6
Add reset to DFU script
dron0gus Sep 25, 2023
1c5a58d
sampling: do not try to calculate ESR if NerstAc is clamped
dron0gus Oct 14, 2023
2b0505d
openbtl: f1_dual_rev1: enable OpenBLT on USART2 (Bluetooth)
dron0gus Oct 16, 2023
4cb34e1
OpneBLT: switch to my repo
dron0gus Oct 16, 2023
32b1418
AEM X series protocol packet definition for UEGO and EGT
dron0gus Dec 10, 2023
9922bd8
can_helper: DLC can be less than 8, support extended ID
dron0gus Feb 5, 2024
eaa9a81
fix AEM protocol definitions
dron0gus Feb 5, 2024
5dd0f83
can protocol selection to settings
dron0gus Feb 5, 2024
3eaa3d2
f0_module: fix
dron0gus Feb 5, 2024
cc267a1
ini files: cleanup
dron0gus Feb 5, 2024
ee43331
Fix no-EGT boards
dron0gus Feb 5, 2024
c61244f
ini file update
dron0gus Feb 5, 2024
55c42c2
byteswap.h: add BE storage types
dron0gus Feb 10, 2024
cb169fd
AEMNET: move to separate files
dron0gus Feb 10, 2024
cb2e38d
CAN: more accurate time intervals
dron0gus Feb 10, 2024
6825eef
CAN: EGT message rate is 20Hz
dron0gus Feb 10, 2024
81dc734
byteswap.h: packed
dron0gus Feb 11, 2024
20c8e86
f1_dual_rev1: bump signature
dron0gus Feb 11, 2024
f54b7f1
Fix default config
dron0gus Mar 16, 2024
5d96ce9
max3185x: more const
dron0gus Mar 18, 2024
b27fe64
max3185x: deinit SPI bus after use
dron0gus Mar 18, 2024
65edf8d
max3185x: improve chip type detection
dron0gus Mar 18, 2024
6b062c4
max3185x: no magic numbers
dron0gus Mar 18, 2024
03c2bfc
max3185x: check spi_txrx return value
dron0gus Mar 18, 2024
6b7d2c2
max3185x: simplify, fix negative values for max31856
dron0gus Mar 18, 2024
fd95e67
max3185x: SPI ts buffer is const
dron0gus Mar 18, 2024
722475a
max3185x: paranoid check for max31856
dron0gus Mar 18, 2024
e4fc23f
max3185x: start in proper state
dron0gus Mar 18, 2024
74176a6
max3185x: communication error counter to TS
dron0gus Mar 18, 2024
b55beff
Github action to auto-generate releases
esaulenka Apr 8, 2024
e167c80
Merge pull request #17 from esaulenka/feature/AutoReleases
dron0gus Apr 8, 2024
f37a034
allow manual fw runs
mck1117 Mar 11, 2024
a9facf4
f0_module needs hack to start pump before closed loop
dron0gus Mar 23, 2024
5c672e4
Fix paranoid check
dron0gus Mar 23, 2024
4adc794
Make START_PUMP_TEMP_THRESHOLD relative
dron0gus Apr 14, 2024
d321f98
default settings: fix RusEFI CAN messages offset
dron0gus Apr 7, 2024
8a2e4f2
README update
dron0gus Jun 2, 2024
698bebf
README: flashing
dron0gus Jun 2, 2024
76abf58
Missed flashing scripts
dron0gus Jun 2, 2024
bbd7a2b
README: minor changes
dron0gus Jun 2, 2024
fd1c2f0
uart: directly chprintf() to SD device
dron0gus Jan 6, 2025
5690b5c
uart: fix debug code compilation
dron0gus Jan 6, 2025
692bd1d
heater: 5 sec stabilization time after switching to closed loop
dron0gus Jul 15, 2022
860d3e9
heater_control: retry heating attempt after timeout
dron0gus Feb 4, 2023
3b8f610
heater_control: report SensorNoHeatSupply if no supply
dron0gus Feb 19, 2023
1141894
f1_dual: select bigger Vbat voltage from two heater voltages
dron0gus Feb 1, 2023
1956861
TODO
dron0gus Feb 1, 2023
d4ee6e9
livedata: show per-channel heater supply voltage
dron0gus Feb 1, 2023
7253d0e
livedata: show Nernst voltage
dron0gus Apr 26, 2023
f782b48
sampling, heater: fix Battery vs Heater naming mess
dron0gus Jul 21, 2023
d4e024d
heater: always rely on localy measured heater voltage
dron0gus Jul 21, 2023
c5db290
Fix reset to DFU command
dron0gus Sep 24, 2023
ee9e4b6
Add reset to DFU script
dron0gus Sep 25, 2023
b7c5f86
sampling: do not try to calculate ESR if NerstAc is clamped
dron0gus Oct 14, 2023
2c32b59
openbtl: f1_dual_rev1: enable OpenBLT on USART2 (Bluetooth)
dron0gus Oct 16, 2023
82bc9f6
OpneBLT: switch to my repo
dron0gus Oct 16, 2023
386d2b8
can_helper: DLC can be less than 8, support extended ID
dron0gus Feb 5, 2024
0fa06cf
CAN: protocol configuration to settings
dron0gus Feb 5, 2024
2393224
ini files: cleanup
dron0gus Feb 5, 2024
c20a505
ini file update
dron0gus Feb 5, 2024
5cd9c5d
byteswap.h: add BE storage types
dron0gus Feb 10, 2024
a1879c4
AEMNET: AFR and EGT
dron0gus Dec 10, 2023
1d7166f
CAN: EGT message rate is 20Hz
dron0gus Feb 10, 2024
47c377b
f1_dual_rev1: bump signature
dron0gus Feb 11, 2024
e07c034
Github action to auto-generate releases
esaulenka Apr 8, 2024
b280e9b
README update
dron0gus Jun 2, 2024
bb15a59
README: flashing
dron0gus Jun 2, 2024
587b755
Missed flashing scripts
dron0gus Jun 2, 2024
fe73b25
README: minor changes
dron0gus Jun 2, 2024
70914da
uart: directly chprintf() to SD device
dron0gus Jan 6, 2025
b557d03
ChibiOS: fix STM32F1xx DAC driver compilation
dron0gus Jan 27, 2025
a932d63
Merge branch 'master-rebase-2'
dron0gus Feb 3, 2025
27b8777
WIP: add CANio box protocol
dron0gus Feb 10, 2024
01b4fb1
AUXOUT: use unsigned as channel index
dron0gus Feb 3, 2025
5d60d8f
AUXOUT: fix ripple canelation channel check
dron0gus Feb 3, 2025
f5956ec
AUXOUT: check arguments
dron0gus Feb 3, 2025
a67fe47
iobox: update
dron0gus Feb 3, 2025
057ec1f
IoBox settings to config and export to TS
dron0gus Feb 4, 2025
b786240
DAC mode implemented
dron0gus Feb 4, 2025
15f3462
TS: bump signature
dron0gus Feb 4, 2025
541d413
fix f0 compilation
dron0gus Feb 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/build-firmware.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,12 @@ jobs:
with:
name: Wideband ${{matrix.build-target}}
path: ./firmware/deliver/${{matrix.build-target}}/wideband*

- name: Zip artifacts
run: zip Wideband\ ${{matrix.build-target}}.zip ./firmware/deliver/${{matrix.build-target}}/wideband*

- name: Make a new Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: Wideband\ ${{matrix.build-target}}.zip
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
url = https://github.com/rusefi/kicad-libraries
[submodule "firmware/ext/openblt"]
path = firmware/ext/openblt
url = https://github.com/rusefi/openblt
url = https://github.com/dron0gus/openblt
[submodule "firmware/libfirmware"]
path = firmware/libfirmware
url = https://github.com/rusefi/libfirmware.git
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
# Wideband

This fork is for development of FW for [RusEFI](https://github.com/rusefi) [dual channel wideband](https://github.com/rusefi/rusefi-hardware/tree/main/lambda-x2). Based on [original desing](https://github.com/mck1117/wideband) from [mck1117](https://github.com/mck1117)

For stm32f042 FW please refer to original repo. While I try to keep it buildable and unaffected by my modification I can not guaranty its functionality and provide any support.

# Initial flashing

For initial flashing of newly assembled device under Windows please refer to [this instruction](https://rusefi.com/forum/viewtopic.php?p=48379#p48379).

I hope Linux users are experience enough to know how to use [stm32flash tool](https://github.com/ARMinARM/stm32flash). There are two sample scripts to [flash OpenBLT only](/firmware/dfu_flash_openblt.sh) and [flash combined image of OpenBLT + main FW](/firmware/dfu_flash.sh).

# Update using OpenBLT

[OpenBLT](https://github.com/feaser/openblt) bootloader is used for FW update functionality. Please reffer to original [documentation](https://www.feaser.com/openblt/doku.php?id=faq) on how to compile host tools and use it.

There are few sample linux scripts for updating device over [CAN](/firmware/flash_can.sh) or [UART](/firmware/flash_uart.sh).

Linux users can use almost any USB to CAN adapter supported by linux and providing SocketCAN interface ([for example](https://rusefi.com/forum/viewtopic.php?f=13&t=2209)). Windows users please check OpenBLT documentation.

# Original readme

[![Build Firmware](https://github.com/mck1117/wideband/actions/workflows/build-firmware.yaml/badge.svg)](https://github.com/mck1117/wideband/actions/workflows/build-firmware.yaml) ![license](https://img.shields.io/github/license/mck1117/wideband)

# rusEFI Wideband Controller
Expand Down
6 changes: 6 additions & 0 deletions firmware/.gdbinit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
target extended-remote localhost:3333
file build/wideband.elf
load
set breakpoint auto-hw on
set remote hardware-breakpoint-limit 8
set remote hardware-watchpoint-limit 4
2 changes: 1 addition & 1 deletion firmware/ChibiOS
12 changes: 7 additions & 5 deletions firmware/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ LDSCRIPT=app.ld

# C sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CSRC = $(ALLCSRC) $(BOARDDIR)/board.c
CSRC = $(ALLCSRC) \
$(BOARDDIR)/board.c \
boards/f1_common/openblt/shared_params.c

# C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
Expand All @@ -148,6 +150,8 @@ CPPSRC = $(ALLCPPSRC) \
shared/flash.cpp \
can.cpp \
can_helper.cpp \
can_aemnet.cpp \
can_iobox.cpp \
fault.cpp \
lambda_conversion.cpp \
pwm.cpp \
Expand Down Expand Up @@ -187,7 +191,8 @@ INCDIR = $(CONFDIR) \
console/binary/ \
boards/ \
shared/ \
$(BOARDDIR)/io/
$(BOARDDIR)/io/ \
boards/f1_common/openblt

# Define C warning options here.
CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes
Expand Down Expand Up @@ -236,9 +241,6 @@ ifeq ($(USE_OPENBLT),yes)
# Reserve start of flash for OpenBLT
USE_OPT += -Wl,--defsym=USE_BOOTLOADER=1
DDEFS += -DUSE_OPENBLT=TRUE
# Shared params
INCDIR += boards/f1_common/openblt
CSRC += boards/f1_common/openblt/shared_params.c
endif

#
Expand Down
Binary file added firmware/Wideband f1_dual.zip
Binary file not shown.
22 changes: 19 additions & 3 deletions firmware/auxout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,19 @@ static const int8_t auxOutPwmChN[AFR_CHANNELS] = {
#endif
};

void SetAuxDac(int channel, float voltage)
void SetAuxDac(size_t channel, float voltage)
{
if (channel >= AFR_CHANNELS) {
return;
}

voltage = voltage / AUXOUT_GAIN;
auto duty = voltage / VCC_VOLTS;
duty = clampF(0, duty, 1);

auxDac.SetDuty(auxOutPwmCh[channel], duty);
// Ripple cancelation channel
if (auxOutPwmChN[channel >= 0]) {
if (auxOutPwmChN[channel] >= 0) {
auxDac.SetDuty(auxOutPwmChN[channel], duty);
}
}
Expand All @@ -110,8 +114,12 @@ static const uint8_t auxOutDacCh[] = {
#endif
};

void SetAuxDac(int channel, float voltage)
void SetAuxDac(size_t channel, float voltage)
{
if (channel >= AFR_CHANNELS) {
return;
}

voltage = voltage / AUXOUT_GAIN;

auxDac.SetVoltage(auxOutDacCh[channel], voltage);
Expand Down Expand Up @@ -158,6 +166,9 @@ void AuxOutThread(void*)
{
for (int ch = 0; ch < AFR_CHANNELS; ch++)
{
if (cfg->auxOutputSource[ch] == AuxOutputMode::MsIoBox)
continue;

float input = AuxGetInputSignal(cfg->auxOutputSource[ch]);
float voltage = interpolate2d(input, cfg->auxOutBins[ch], cfg->auxOutValues[ch]);

Expand Down Expand Up @@ -192,4 +203,9 @@ void InitAuxDac()
{
}


void SetAuxDac(size_t, float)
{
}

#endif
2 changes: 1 addition & 1 deletion firmware/auxout.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
#include <cstdint>

void InitAuxDac();
void SetAuxDac(int channel, float voltage);
void SetAuxDac(size_t channel, float voltage);
22 changes: 14 additions & 8 deletions firmware/boards/f0_module/port.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ AnalogResult AnalogSample()
.NernstVoltage = AverageSamples(adcBuffer, 0) * (1.0 / NERNST_INPUT_GAIN),
.PumpCurrentVoltage = AverageSamples(adcBuffer, 1),
.HeaterSupplyVoltage = 0,
.NernstClamped = false,
},
},
.VirtualGroundVoltageInt = AverageSamples(adcBuffer, 2),
Expand Down Expand Up @@ -118,15 +119,15 @@ Configuration* GetConfiguration()

// See https://github.com/mck1117/wideband/issues/11 to explain this madness
switch (3 * sel1 + sel2) {
case 0: config.CanIndexOffset = 2; break;
case 1: config.CanIndexOffset = 0; break;
case 2: config.CanIndexOffset = 3; break;
case 3: config.CanIndexOffset = 4; break;
case 0: config.afr[0].RusEfiIdOffset = 2; break;
case 1: config.afr[0].RusEfiIdOffset = 0; break;
case 2: config.afr[0].RusEfiIdOffset = 3; break;
case 3: config.afr[0].RusEfiIdOffset = 4; break;
case 4: /* both floating, do nothing */ break;
case 5: config.CanIndexOffset = 1; break;
case 6: config.CanIndexOffset = 5; break;
case 7: config.CanIndexOffset = 6; break;
case 8: config.CanIndexOffset = 7; break;
case 5: config.afr[0].RusEfiIdOffset = 1; break;
case 6: config.afr[0].RusEfiIdOffset = 5; break;
case 7: config.afr[0].RusEfiIdOffset = 6; break;
case 8: config.afr[0].RusEfiIdOffset = 7; break;
default: break;
}

Expand All @@ -146,6 +147,11 @@ void SetConfiguration()
);
}

void ResetConfiguration(uint16_t option)
{
// NOP
}

SensorType GetSensorType()
{
return SensorType::LSU49;
Expand Down
6 changes: 6 additions & 0 deletions firmware/boards/f0_module/wideband_board_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@
// Nernst voltage & ESR sense
// *******************************
#define VM_RESISTOR_VALUE (10)

// *******************************
// Hack: allow pump driving above target temperature
// minus this offset to avoid Vnerns voltage clamp near 0V
// *******************************
#define START_PUMP_TEMP_OFFSET (200.0)
Loading