Skip to the content
2 layers104.9 × 130.2 mmEngineManagementSimpleWithRelays, the printed circuit board in 3D

EngineManagementSimpleWithRelays

ieb/EngineManagement1

Replacement engine electronics for a Volvo Penta D2-40 and other MDI based engines.

Size
104.9 × 130.2 mm
Copper layers
2
Thickness
1.6 mm
Parts
83
Nets
46
Pads
215
Tracks, vias
501, 21
Pours
8
Routed
Yes
KiCad
KiCad 4
Created
16 Aug 2021
Updated
8 Jul 2026

Overview

EngineManagementSimpleWithRelays is an open-source printed circuit board by ieb, from the ieb/EngineManagement repository on GitHub. It is a 2-layer board of 104.9 × 130.2 mm with 83 parts on 46 nets, routed with 501 tracks and 21 vias.

It is built around the LM358 and BC807-40. Its parts include 29 resistors, 17 diodes, 13 connectors, 6 transistors and 5 capacitors.

Main components

2

README

README.md

Engine Management

In July 2021 my boat was hit by lightning. The Volvo Penta D2-40 MDI unit that manages the Engine, a Volvo Penta D2-40F failed badly leaving the starter motor engaged and nearly causing an engine fire.

Main control board

Update 20240417: In service, no issues after 3 years.

(see pcb/EngineManagementSimpleWithRelays.sch )

This project is based on the standard wiring for the core engine which is a Perkins 100. In that form the engine is controlled by switches, relays and a few flyback diodes. The only part of the original engine control that survived the strike was the Volvo Penta buttons, so those are used by a control board with pnp transistors driving relays triggered by the original buttons pulling the base of the pnp to ground. PushOn/PushOff is provided by a latching relay unit based on a LED control chip that draws a few uA when off. The control circuit draws 0.5A max and is protected by a 5A fuse and 600W TVS which will blow the fuse in the event of a voltage surge.

The main relays for Start, Stop, Glow and aux are all standard iso 40A automotive relays, each circuit fused with a suitable fuse.

There are basic alarms for oil pressure, charge and temperature with the temperature alarm using a differential op amp with high gain adjusted to turn on a pnp at a set temperature. These all drive a buzzer with LEDs to indicate the alarm.

A standard Tachometer sensing from the alternator W+ provides rev and engine hours. These are almost disposable being 30 GBP on eBay from many sources, all 85mm same as the Volvo Penta Tachometer.

Mosfet alternative

Update 20240417: The PCB was prototyped, but never put into service since the relay based control board has proved 100% reliable and in service for 3 years. This section is for reference.

Although the original MDI failed due to the MOSFETs going short circuit, and in this respect relays may be more robust, it should be possible to protect MOSFETs or at least fail safe.

A 1.5KW TVS (eg SMCJ14A) with a 14.0V revers standoff, 15.6V minimum breakdown will conduct 5A@16V, 10A@18V and 40A@20V, which makes it viable as protection for excessive voltages upto 40A current, aiming to blow a fuse at above those voltages. Each mosfet needs its own TVS + suitably sized fuse or breaker. In the event of a strike or surge the TVS will short and blow the fuse before damage is done even if the MOSFET is shorted. It wont work for currents greater than 40A without exceeding the max Vds voltage of the MOSFET below.

A SI7137DP-T1-GE3 has an on resistance of 0.0016 Ohms and will dissipate < 640mW for 20A when fully on. It, unfortunately has a Max Vds of 20V and Vgs of 12v so needs protection, but provided its protected represents a robust solution as a high level switch.

In the relay board on/off was provided by a eBay relay board which used a LED controller. To keep the number of daughter boards to a minimum and save space this is replaced by a MAX15054 on-off controller driving a N-Channel mosfet which when turned on draws the gate of one of the SI7137's to near zero turning it fully on. The same N-Channel mosfet enables P-Channel mosfets connected to the gates of other SI7137s. When the VP buttons are pressed the gates of these mosfets are dragged down to 0v turning them on, and since the N-Channel mosfet is conducting the gate of the respective SI7137 is also dragged to 0v switching that mosfet on. All P-Channel gates are pulled to +ve, and all N-Channel gates are pulled to 0v. The SI7137 has a max source gate voltage of 12v and so a 10v zener with forward diode ensures that never gets over 11.5v.

Simulations indicate that the power dissipation in the SI7137 at 20A is 2.5W, so a pair are used for the glow plugs. At 8A for the start and stop solenoids power dissipation is closer to 500mW. Board cooling pads are used, although it might be necessary to add chip heat sinks.

Since the SI7137 are 1/10th the size of the relays, the switching circuit and NMEA2000 interface controller will all fit onto a single 10cm x 15cm board (which is the size I have in stock).

All of the silicon components were available at Farnell except the SI7137's which were ordered from Mouser, airmailed from California. For some reason RS in the UK had no stock of any mosfets.

see pcb/EngineManagementWithMosfets.sch which includes a sub-sheet of the NMEA interface. There are LTSpice simulations in pcb/simulations/ of the mosfet layout confirming transient behavior, currents and power dissipation.

Since its likely that when there is a voltage spike something on the board will blow, assuming this board works, I'll probably make a batch and keep a few spares onboard the boat.

NMEA2000 Interface

  • Update 20240417: In service, minor issues after 3 years, mostly surrounding message frequency and how to some parameters to display on standard instruments.
  • Update 2025????: Redesigned board to eliminat pro mini plugin see https://github.com/ieb/N2KEngine for details. The NMEA2000 Interface here is no longer in service.

(see pcb/EngineManagement.sch)

The standard MDI talks J1939 which is the Diesel engine CAN standard protocol. Normally this communicates with other Volvo Penta instruments, but in my case this was only the Tachometer. The J1939 Volvo Penta Tachometer did not survive the strike. The CAN bus interface was destroyed, even though there was an attempt to protect if from surges. At over 500 GBP to replace, I decided to stick with the non J1939 tachometer from eBay. For details on how to drive J1939 see the main_deprecated.cpp file. Volvo Penta service technicians probably query the MDI for fault codes, but for owners there is limited benefit where the only unit is a tachometer or basic instruments.

Once I discovered the VP Tachometer was not repairable, a separate mechanical diesel to NMEA2000 board was designed and built around an Arduino Pro Mini (Atmel 328p MCU), MCP2515 CAN controller board and some passive components. There is just enough space on 328p to hold the code and run the controller and the data collected and emitted can be displayed on any NMEA2000 instrument (eg Raymarine e7 MFD).

Component cost of the boards is probably less than 30 GBP, hence spares boards can be carried and in the worst case the engine can be controlled manually.

Replacing the blown VP parts with OEM parts would have been 1500 GBP with a further 1500 GBP required for the spare set, safe in the knowledge that a EM pulse from a near strike would result in precisely the same failure and risk of engine fire.

NMEA2000 Messages

A D-2/40 is not exactly performance. Its not going to rev up quickly and so periods of 100ms are not really necessary for rapid engine. Same with temperatures which are really not going to change that fast. 5s is plenty fast enough. 10s is too long and most instruments treat this as no data sent.

  • pgn 127488 rapid engine, 500ms
  • pgn 127489 dynamic engine 1s oil temperature == alternator temperature.
  • pgn 127505 tank level 5s, instance 0 fuel type 0 diesel
  • pgn 130316 temperatures 5s, instance/source 0/14=Exhaust, 1/3=EngineRoom, 2/15=Alternator.
  • pgn 127508L battery voltage 1s, instance 0=engine battery, voltage only. instance 2=Alternator, voltage and temperature

The main battery as its now LiFePO4 with a serial to BLE module providing very detailed information. A CAN interface to this could be implemented, but the standard android app gives more than enough information and is lower power. The original battery sensor mechanism didnt work well due to slight differences in -ve potential at the battery terminals. Hence the N2K interface only monitors Engine Battery and Alternator voltages. With a LiFeP04 battery, alternator temperature has become more important. Alternator load is controld via a Sterling A2B 120A converter which actively monitors and protect the alternator from excessive load.

Sensors

The standard VP flywheel pickup produces 415Hz 20V pk2pk puses with sharp edges at idle, however the signal is noisy and so it needs to be conditioned. A Schmidt trigger using an OpAmp set up positive feedback to reduce hysteresis. The positive input uses a RC network acting as a low pass filter reducing the sensitivity as the rpm rises, eliminating high frequencies ( > 10KHz). On the negative a RC network smooths the input voltage to find the mean allowing automatic offset compensation. The time period constant of the -ve input is >> than the +ve. The inputs are via 22K resistors with the voltage measured over 100K. There are 2 chopper diodes to limit the input voltage to no more than 1V.

Using a 358 opamp with 5V supply the square wave out is 3.7V high and 0.7v low, which is just enough (3.5v being logic high), 1.5 below Vcc isn't great for an OpAmp, however 3v is high on an Arduino.

The frequency is measured by timing 10 pulses using micros().

The previous attempt without a Schmidt Trigger failed to work reliably due to noise.

The standard VP oil pressure switch is a simple switch that closes when the oil pressure drops below a threshold.

The standard VP coolant temperature sensor is identical to almost every other coolant sensor, with about 1743R at 0C and 22R at 120C. When about 33R (105C adjustable) is measured the alarm is triggered.

The charge alarm uses the voltage across the resistor supplying current into the alternator excitation coil, analogous to the charge light in cars long before there were computers.

The NMEA2000 interface board also measures fule level (0R-190R), battery voltage, alternator voltage, and 3 NCT inputs. Inputs are protected with capacitors and 100K resistors to limit current.

Outputs

The relay board provides outputs for starter motor, stop solenoid, glow plugs and aux 12v.

The NMEA2000 board provides NMEA2000 messages.

Connections.

The VP wiring loom has largely been replaced except for the connection to the VP buttons. Most of the original wiring loom was melted by the starter motor, but the rest was strapped tightly to the engine risking shorts when it melted.

The control box will be mounted outside the engine bay where temperatures are considerably lower (typically < 30C vs often > 85C next to the engine).

Code

Code is all in main.cpp rather than a classes since there is little to it and I needed tight control over memory usage (less risk of hidden bloat). NMEA support uses

text
https://github.com/ttlappalainen/NMEA2000.git
https://github.com/ttlappalainen/NMEA2000_mcp.git
https://github.com/ttlappalainen/CAN_BUS_Shield.git

however there are some patches required, see src/*.patch. src/CAN_BUS_Shield.patch. The SPI clk was heavily distorted at 8MHz with a Pro Mini so I dropped the SPI to 1MHz to get a clean clk square wave.

src/NMEA2000-library.patch The memory savings (see NMEA2000_CompilerDefns.h) which are required to run on a 382p dont compile without this patch. Additionally there I needed feedback on serial of failed packets without enabling all packet output.

Both patches must be applied if pulling fresh dependencies.

Memory usage

Building .pio/build/pro16MHzatmega328/firmware.hex Advanced Memory Usage is available via "PlatformIO Home > Project Inspect" RAM: [== ] 18.4% (used 377 bytes from 2048 bytes) Flash: [========= ] 89.4% (used 27458 bytes from 30720 bytes)

If debugging of the sensors is enabled, then NMEA2000 output may have to be disabled to get the code to fit into FLASH. No problems seen with RAM at the moment, but it hasnt been tested on a live NMEA2000 bus yet.

Update on memory.

Memory usage has proved a problem. The NMEA2000 library was designed for chips with more memory than a Pro mini and although it will run, it runs out of stack and heap when dealing with ISO Reqeusts, causing the cpu to lock up or crash. It is possible to greatly reduce memory usage by limiting buffer sizes but this truncates the responses ot the ISO requests. I think the underlying problem is that the NMEA2000 library uses temporary buffers allow it to use interrupts and to support TP packets.

So, the code is now switched to a smaller SNMEA2000 library. This only uses an 8 byte buffer for sending and is written to load that buffer, sending when full. It supports standard packets and fast packet messages. It doesn't support interrupts and is a lot simpler.

Building with debug enabled all in ram gives RAM: [=== ] 32.2% (used 659 bytes from 2048 bytes) Flash: [==== ] 37.4% (used 11492 bytes from 30720 bytes)

Initial tests indicate 1292 bytes ram available at all times when running, compared to the < 60 bytes reported with the smallest viable NMEA2000 configuration. Most of the implementation is informed by the NMEA2000 code and functionality for each use is by extension only. To reduce the work load on a polling only interface to the MCP2515 message filters are implemented on receive. It only supports a MCP2515 over SPI and will only run on an AVR based chip as it assumes little endian.

The code has, or is being verified talking to a ESP32 + MCP2562 running the NMEA2000 device analyzer.

Changes

  • 20240417 Reduced the periods for battery and fuel to 5s from 10s as N2K instruments were showing -.- periodically.
  • 20240417 Output Alternator temperature to Engine Oil Temp and a dedicated "battery" (no 2) for display. Oddly no standard PGN for an DC alternator available.

Todo/Status Relay Board

[x] Build prototype PCB and populate. [x] Test on/off sequence. [x] Test 20x4 I2C display. [x] Test port extender. - discovered Can board back powers 5v switched line, added blocking diode. [x] Connect 8 way relay board and test. [x] Verify CAN board working. [ ] Connect test harness sensors and test. [FAIL] Connect VP Taco and test with simulated engine - the VP Taco is blown internally, CanH at 5V, CanL and 0V. Inside three is a large Asic which looks like it directly controls the Can bus. Very unlikely to be able to repair. Google for the numbers turns up no chips, and none of the other chips are CAN related.

[x] Design build and test simple relay controller unit with no MCU [x] Design build NMEA2000 controller board [x] Test NCT readings, - adjusted to 4.7K top R and rebuilt NTC table from base equations. [x] Test coolant readings - tested with fake NTC sensor wiring, need full test on real sensor [x] Test fuel level readings [x] Test voltage readings [x] Test coolant with variable voltage. [x] Test RPM with signal generator [x] Test NMEA2000 output [x] install [x] Test output on MFD, all working except Charge alarm sounds all the time and RPM sensor is unreliable. [x] Fix RPM sensor, using Schmidt trigger [x] (disabled) Fix charge sensor, adjust resistors or disable. [x] Adjust temperature sensor [x] calibrate ADCs, or at least check they are correct. [x] Test again. [x] Install check RPM with strobe [x] Fix fuel and voltage periods, 10s too long for N2K instruments, dropped to 5s. [x] Output alternator temperature as oil temp, dedicated "battery" instance 2.

Todo Status Mosfet board

This has been put on hold as the relay board works well other than the charge and temperature alarms whcih are too sensitive. Same mosfets have been used for a high current remote switch and appear to produce almost zero heat dissipation.

[x] Simulate everything in LTSpice [x] Layout PCB [ ] Mill prototype [x] Order Silicon [ ] Build prototype [ ] Test on/off [ ] Test other buttons and circuits, under load ideally. [ ] Test warning circuits [ ] Test sensors [ ] Test NMEA2000 output [ ] Install [ ] Test running [ ] Order boards and build spares.

CanDrivers

AVR -> MCP2515 -> TJA1050

TJA1050 runs on 5V but can take 3 or 5v logic in. MCP2515 will run on 3v or 5v On 3v it will need a 1K/10K divider to take TJA1050 out from 3.6v to 3.3v

Scope output for this setup on 5V is very clean

ESP -> TJA1050

TJA1050 runs on 5v with a divider on RX out to take Vrxh to 3.3v, may be easier than a MCP2562, although the output from a MCP2562 is not nearly as clean.

This setup works. Output is very clean, however the mean voltage is sensitive to the 5V supply being exactly 5V.

Pi -> MCP2515 -> TA1050

Same as 3v AVR 3v. Would also need a RTC, DS3231 with a LI charger TP4056 Not done as was able to fit everything I wanted into a ESP32 running a http server which draws < 40mA when not transmitting on WiFi, see CanDiagnose project.

Parts

83
QtyValueFootprintReferences
910KResistors_SMD:R_0805_HandSolderingR4, R5, R6, R13, R14, R15, R17, R21, R101
81KResistors_SMD:R_0805_HandSolderingR11, R16, R19, R22, R23, R102, R105, R107
62.2KResistors_SMD:R_0805_HandSolderingR8, R9, R10, R18, R20, R106
6BC807-40TO_SOT_Packages_SMD:SOT-23Q101, Q102, Q103, Q104, Q105, Q106
4S1JL 1A 40VDiodes_SMD:D_SMA_StandardD3, D9, D102, D103
4S1JL 1A 600VDiodes_SMD:D_SMA_StandardD6, D11, D12, D13
4mountConnect:1pinP105, P106, P107, P108
210A 600VDiodes_ThroughHole:Diode_P600_HorizontalD8, D10
21uFCapacitors_SMD:C_1206C101, C103
2FUSE 30ADivers:BladeFuse-CarTypeF2, F6
2OilWarnDiodes_SMD:D_0805D5, D14
10vDivers:M5BoltP103
1100KResistors_SMD:R_0805_HandSolderingR104
1100nFCapacitors_SMD:C_1206C102
1100uFCapacitors_ThroughHole:C_Radial_D8_L11.5_P3.5C2
110KPotentiometers:Potentiometer_Bourns_3296W_3-8Zoll_Inline_ScrewUpRV1
110MResistors_SMD:R_0805_HandSolderingR12
110RResistors_ThroughHole:Resistor_Horizontal_RM20mmR7
110nFCapacitors_SMD:C_0805_HandSolderingC1
112VSwitchedPowerDivers:CrimpBladeP5
11MResistors_SMD:R_0805_HandSolderingR3
122KResistors_SMD:R_0805_HandSolderingR103
1330RResistors_SMD:R_0805_HandSolderingR2
15A 600VDiodes_ThroughHole:Diode_P600_HorizontalD7
1Battery+Divers:M5BoltP104
1CONN_3Connect:bornier3P102
1CONN_4Connect:bornier4P101
1ChargeWarnDiodes_SMD:D_0805D2
1EnginePowerDivers:AutomotiveRelay35ARL1
1EngineStartDivers:AutomotiveRelay35ARL2
1EngineStopDivers:AutomotiveRelay35ARL3
1FUSE 15ADivers:BladeFuse-CarTypeF7
1FUSE 5ADivers:BladeFuse-CarTypeF1
1GlowPlugsDivers:AutomotiveRelay35ARL4
1GlowPlugsDivers:CrimpBladeP6
1LM358Housings_DIP:DIP-8_W7.62mm_LongPadsU1
1LatchingRelayDivers:LatchingRelayRL5
1SMBJ30CA-TR TSVDiodes_SMD:DO-214AB_HandsolderingD1
1SlJL 1A 40VDiodes_SMD:D_SMA_StandardD101
1StarterSolenoidT30Divers:CrimpBladeP3
1StopSolenoidDivers:CrimpBladeP4
1TempWarnDiodes_SMD:D_0805D4
1Use12vSupplyPin_Headers:Pin_Header_Straight_1x02JP2
1UseSensorAlarmPin_Headers:Pin_Header_Straight_1x02JP1
1VPButtonsConnect:bornier5P1

More from ieb/EngineManagement

4
  • 2 layers150 × 100 mmEngineManagementSimpleWithMosfets, the printed circuit board in 3D

    EngineManagementSimpleWithMosfets

    ieb/EngineManagement

    Replacement engine electronics for a Volvo Penta D2-40 and other MDI based engines.

    151 parts1
  • 2 layers90 × 50 mmMosfetSwitch, the printed circuit board in 3D

    MosfetSwitch

    ieb/EngineManagement

    Replacement engine electronics for a Volvo Penta D2-40 and other MDI based engines.

    78 parts1
  • 2 layers97 × 56.1 mmEngineManagement, the printed circuit board in 3D

    EngineManagement

    ieb/EngineManagement

    Replacement engine electronics for a Volvo Penta D2-40 and other MDI based engines.

    63 parts1
  • 2 layers106.7 × 61.6 mmPiCanBoard, the printed circuit board in 3D

    PiCanBoard

    ieb/EngineManagement

    Replacement engine electronics for a Volvo Penta D2-40 and other MDI based engines.

    48 parts1

Similar boards

  • 2 layers91.4 × 40.6 mmMhixy, the printed circuit board in 3D

    Mhixy

    iblue/mhi-xy-bus

    Reverse engineering of the Mitsubishi Heavy Industries X/Y Bus as used in FDUM air condition

    70 parts6
  • 2 layers105 × 50 mmMagneto chico, the printed circuit board in 3D

    Magneto chico

    MarianoDel/kicad_magneto_chico

    Placa para el magneto chico

    53 parts
  • 2 layers77 × 100 mmBeamer1, the printed circuit board in 3D

    Beamer1

    shufps/diy-projector-clock

    DIY Projector Clock

    283 parts172
  • 4 layersIONPAK2, the printed circuit board in 3D

    IONPAK2

    m-labs/ionpak

    A modern, low-cost universal controller for hot-cathode ionization vacuum gauges. (WIP)

    259 parts23
  • 2 layers180.5 × 52.3 mmPclptcnc, the printed circuit board in 3D

    Pclptcnc

    awpe/lpt_breakout_board

    IEEE1284 breakout board

    249 parts2
  • 2 layers125.5 × 79 mmPeterThePowerMeter, the printed circuit board in 3D

    PeterThePowerMeter

    CtrlAltJon/PeterThePowerMeter

    IoT Power Meter for real-time energy monitoring. Includes a local color display, acoustic alarms, and a web interface for smart home integration (Home Assistant/MQTT).

    79 parts1MIT
  • 2 layers150 × 80 mmRpi extension, the printed circuit board in 3D

    Rpi extension

    andriy-bilynskyy/rpi-extension

    This project is a PCB design to create SDR transceiver using Raspberry Pi and Radioberry boards. Simple connection of boards seems incomplete:

    97 partsMIT
  • 4 layers166.3 × 70 mmGanglia, the printed circuit board in 3D

    Ganglia

    H2O-Tnp/ganglia

    Ganglia is an open BLDC / brushed motor driver platform — custom PCB hardware plus STM32 firmware that runs a real-time control loop on top of FreeRTOS.

    202 parts

Questions

How big is the EngineManagementSimpleWithRelays PCB?

It measures 104.9 × 130.2 mm and has 2 copper layers, 1.6 mm thick.

What parts does the EngineManagementSimpleWithRelays use?

83 parts, built around the LM358 and BC807-40. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the EngineManagementSimpleWithRelays KiCad files?

From the ieb/EngineManagement repository on GitHub, at the commit this page was made from: the board is pcb/relayboard/EngineManagementSimpleWithRelays.kicad_pcb. PCBKit opens the board in the browser, with nothing to install.

Can I use the EngineManagementSimpleWithRelays design in my own project?

Its repository states no licence, so its author keeps all rights: ask ieb before reusing the design.