Disclaimer: The physical load and wiring used in this example are specific to one real world application. If you recycle this for any other purpose, make sure you know what you are doing so that you don’t damage any of the electronics or components on your application.
In a vehicle there are several electronic solenoids and valves. If they are disconnected while the engine is running it should result in a diagnostic fault. This program is able to temporarily take control of a real load such as a valve or a solenoid of some kind without tripping a diagnostic. This is done with a Dual Pole Dual Throw relay. When the user closes a momentary switch the relay toggles to switch the Engine Control Unit to drive a 10 ohm resistor instead of the real load/solenoid/whatever. Then this device has control of the low side driver of the actual load. When the device is not active, the LED is an indicator of the duty cycle output. The brighter it is, the longer the active duty cycle will be for the load when the switch is closed.
The green LED is only for indicating that there is power to the board and the 5V regulator is working. There is a potentiometer tied into analog input zero. This will allow the user to adjust the duty cycle without changing the code. There are safety limits set in the software so that the load is not driven to 100% duty cycle, possibly damaging it. The frequency is a fixed value in the code.
I was able to incorporate the simulated load (10 ohm resistor network rated at 25 watts) into the case on the bottom of the board. For my initial use case, this should be fine because the ECU will only pull current through this circuit for very short bursts of time, under 10 seconds. If it were longer, I would use something rated for 50W. Even at that rating the resistor would likely get too hot to touch without a heatsink if driven at 100% duty cycle. To mount them like this, and actually be sturdy, there is an extra large via in the board that is not tied to any circuit. It is only used for installing these resistors in such a way that they to not flex easily against the bottom of the case. It worked better than I had expected too. The case did need some small notching to get things to fit. The relay is just slightly too call for the case, so I had to notch the corners to get it to sit flush inside with the lid on.
The circuit is built with a pull down diode going into digital pin 5. This allows for code that requires reading in the duty cycle of the from the ECU to see what its intentions are for the load. My code does not make use of that at the moment.
The PCB is drawn with a small heat sink area for the MOSFET, but my real intention is for it to be cut out and an off board sink to be used. This circuit is pretty jammed into the case that was picked and that was a good use of space. Again, as with the high power resistor, the MOSFET is rarely going to be doing any work in the application I picked for this design. That being the case, the heatsink can be smaller like this.