document updated 18 years ago, on Apr 5, 2006
Filtering VehicleSpeedSensor input
Specs:
- swings from 0v to 12v
- We'll have to precisely calibrate this to our vehicle/tires/road-surface, but it should be about 1.14hz for every 1mph. eg. 100mph = 114hz. Top end for my car is currently 127mph, which should be ~144hz. Though note that we're exceeeedingly unlikely to get anywhere near that in a normal road-rally.
- Note that this is extremely accurate.
- I don't have a scope to be able to verify the highs/lows/frequency
So how do we do this?
- Generate two reference voltages between 0-12v, and use a Schmitt Trigger
- if the output really does drop down to 0v, then simply use a zener regulator to drop the top-end down to 5v. If there's enough CPU for it, debounce could be done in software.
- At most, I think a differentiator op-amp
- the PIC has some basic Schmitt triggering built-in. According to the "Electrical Specifications" section of the 16F628 manual, the trigger points are 0.2v and 0.8v.
- the high-frequency components can be filtered out with a low-pass filter tuned to the expected frequency range of the input.
- possibly related concepts:
- OH OH OH. The 16F628 Timer module contains 1) an edge-trigger, and 2) a 16-BIT counter that uses the edge-trigger, and 3) all of that can run while in SLEEP. Wow, is that perfect, or what?
- Oh wow, I didn't think of that. For a ton more precision, you can count the number of 20MHz clock ticks that have gone by between each edge. At the VERY LEAST, this provides a software-only precise tunable low-pass filter. How much better does it fucking get?
- For the record, a 16-bit timer isn't enough to provide the precision available at 20MHz, tehe.
- Simply counting the number of pulses so far may be a little less accurate, as it relies on the laptop's clock and introduces delay over the parallel port? Though if the count is cleared each read, then no "ticks" will really be lost.
- Alternatively, the PIC could precisely figure out the time between the last two pulses, or better yet, the last 5 pulses (since that would be one entire shaft revolution and wouldn't depend on the precise location of the magnets? or is this thing manufactured really well?) and send that as a measure of how fast the wheels are turning?
- Okay, so this looks really simple. So some loose ends:
- Vss comes in to a diode, so we make sure we don't send anything back out
- (optional) low-pass filter with the right values in case there's any high-frequency noise from automotive environment
- vehicle's ground should come in through the laptop charger, and to the computer? or is the charger and/or laptop isolated? I have no idea how this should work if it doesn't...
PIC and such
- Remember to tie all unused pins.
- How small of a package can we fit this in?
Parallel Port
- 2mA @ 5V power will come from the parallel port,
Similar projects
Okay, random free-thinking crap mode now
----------------------------------------------------------
My musing about RS232-transceiver hacking here:
http://paperlined.org/hardware/microcontrollers/serial/serial_sensor.html
Led me to thinking about even more optimizations.
Guess what? RS232 receivers and speedometer wires share several significant properties:
- designed to handle noise in an automotive/industrial environment
(eg. circuit builds-in some hysteresis, inputs are designed to allow short voltage spikes, etc...)
- designed to handle a variety of voltage ranges on the input
- might even have electro-static and other such random niceties
And guess what? Lots of RS232 transceivers include multiple receivers. So I THINK we've just reduced this whole shebang literally down to
only two chips. Which could be done in SOIC if we really had the urge. Note to self: you don't see this urge. What urge? NO URGE!
Okay, so searching for a RS232 transceiver with 2 receivers and 1 driver:
SN7515. 1rec, 1drv. Supples 4v at 10ma. We need 2 receivers to compact things though.
MAX201. 2rec, 2drv. Supplies 3.5 - 5v at 1mA. (suck) 2 external caps.
SN75C1406. As far as I can tell, this requires a separate 4-6v supply, so won't be as compact.
Okay, the 16F628 doesn't seem to have NEAR the amount of input filtering these things have. So am I stuck with using a separate regulator, or doing software-debounce of the VSS?
What I really need is the big-brother to SN7515.
http://www.digikey.com/scripts/dksearch/dksus.dll?MfcISAPICommand=KeywordSearch&Site=US&Vendor=0&Keywords=LT1121%20sot-223%205v&Stock=1
Okay, either way, we have to have the external crystal and two caps for accurate timing, right? So it's kind of pointless to try to minimize this so dang much. We have no experience with this.