Wednesday, October 7, 2020

Fuel Pressure Monitor PCB

 Here is a simple circuit I am using to monitor fuel pressure for troubleshooting in my project car.  


 The circuit itself is really nothing special, just an op-amp used as a comparator with a potentiometer, R3, on the non-inverting (+) input and the signal from my fuel pressure transducer fed in to the inverting (-) input.  The 7805 regulator provides power for this circuit and my pressure transducer.  The pressure transducer outputs a voltage that is proportional to the pressure.  The output transistor is a logic level MOSFET that acts as a low side switch.  In my application I have this wired to turn on the check engine light when the fuel pressure falls below a certain point which is set by R3.  C7 is optional.

 Some special consideration was given to the power supply circuit, namely the addition of a TVS and a couple diodes to protect the regulator in the harsh automotive electrical environment. Use 50 volt caps on the unregulated side.

 CEL connects to the check engine light, and goes low when the fuel pressure is low 

 S+, S-, and SIG connect to your sensor 

 12V is the power supply to the board from the chassis 

 Spare pins are broken out for a 5V tap and the sensor output (SIG) for a datalogger. 



 There are probably hundreds of other possible uses for this circuit.  **One word of caution, don't try to use it as a thermostat or to drive high current loads.  No hysteresis is added to the circuit and when the sensor output is approximately at the set point the output transistor will operate in the linear region rather than saturation or cutoff, and will dissipate quite a bit of heat. For my application this provides a dim check engine light, which I don't mind as it kind of turns a single light in to a 3-state indicator.  If you want to, it would be quite easy to create a Schmitt trigger and make the circuit operate in decisive on/ off manner.

 I am sharing the schematic, BOM, and Eagle files here in case they are useful for someone, feel free to share/ modify/ make/ sell PCBs for these as you see fit.  Just don't claim my work as your own and don't blame me if something doesn't work right.  For reference it cost me $16 to have 5 of these PCBs made and shipped to me in 2020.

 

 Eagle files, schematic, and gerbers (.zip): Google Drive



Time Lapse with Raspberry Pi and Webcam

The raspberry pi is a great tool for making time lapse videos.  I like to use a weatherproof USB webcam with night mode.  This lets me put the camera in the best location (Example: up on the tree) and have the raspberry pi and power source somewhere more convenient for access (Example: bottom of the tree).

The only problem with this is that there is an issue with the webcam, the driver, or the fswebcam program that causes it to sometimes capture blank images.  For me this is about 25% of my images when running this command:

fswebcam -r 1280x720 /home/pi/photos/$DATE.jpg 

Now, some say that skipping a few frames will help to stabilize the image before capture:

fswebcam -S 30 -r 1280x720 /home/pi/photos/$DATE.jpg

It improves things a bit, but I still get way too many blank frames.  So I try capturing multiple frames:

fswebcam -S 20 -F 2 -r 1280x720 /home/pi/photos/$DATE.jpg

Well now I have a motion blur problem, along with poor exposure control for some reason.  I suspect when it captures one black frame and one image they get overlapped and the image looks dark.

 

Here is my solution, webcam.sh:

 

#!/bin/bash

#set min file size
minSize=50000

#set file name
DATE=$(date +"%s")

#set 0 to the initial file size so the loop starts without errors
fileSize=0

#take photos until a suitable file size is generated
while (( fileSize < minSize ));
do
    fswebcam -S 20 -r 1280x720 /home/pi/photos/$DATE.jpg
    sleep 1
    fileSize=$(stat -c%s /home/pi/photos/$DATE.jpg)
done

 

Call the script by crontab every 15 minutes, or whatever you desire:

*/15 * * * * /home/pi/webcam.sh 2>&1

 

The script attempts to take a picture and then checks the size of the output.  If the size is less than your threshold it will try to take a new picture and overwrite it.  The script continues doing this until an acceptable size image is captured.  Note that the time in the file name will be off by however many seconds it takes to capture a good image, in practice it's usually just a few seconds so I don't care.  If that's important to you the script could be fixed easily.

You will have to experiment to find the correct threshold size.  For me, good daytime images are about 1MB, good nighttime images are about 200kB, and black junk frames are about 40kB - so I set my threshold for a "good" picture to be 50kB.  Obviously if you change the resolution or anything else you'll have to adjust that setting.