Do you know the duty cycle of the sensor output ?
My thought is to use the "Port B interrupt on change" feature on something like the 16F88. Looking at the datasheet it seems to indicate that an interrupt will be generated on any change so low-high and high-low would both generate an interrupt.
Create an interrupt routine that generates a short pulse on a pin and feed the speedo with that. Provided the speedo only needs to count the pulses rather than needing an exact mark/space ratio then it should work. You would obviously need to ensure that the pulse you generated was short enough to be completed in about half the time that pulses would be arriving at maximum speed.
The only caveat is that it depends on how it calculates the speed. If it counts the number of pulses in a second then it should be OK, but if it times the interval between pulses then there could be a problem if the output of the sensor is not 50/50 as alternate generated pulses would have different spacings.
Dont know if any of the 8 pin PICs would be able to do it as I haven used any of those yet.
Keith
www.diyha.co.uk
www.kat5.tv
what brand, year and model of car?
the Speed Sensor is mechanical, then you MUST measure the frequency for x speed. Once you know that, i think it can be done with a 10Fxxx pic and few line of code... if the frequency is not to high of course...
The duty cycle have to be 50%... VSS (vehicule speed sensor) are noted in Pulse Per Mile.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Hi Malc-c,
Tell your friend to take the car to a speedometer shop. They will install a gear increaser to calibrate the speedometer, or they will change the drive gear or driven gear. This is probably the cheapest fastest route.
JS
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Guys thanks again for your contributions
I'll pass on the URL to this topic and let him have a read.
Hi Malcolm,
Here's one for your friend.
It doubles input pulses from somewhere around .1 hz to 750hz. (output = .2 to 1500hz)
Should be good enough for a speedometer.
I did it on a 12F629 and it's internal oscillator. But, you should be able to run it on just about any 14bit core. (94 words)
If the sensor's dutycycle isn't around 50% (40-60% max), I may need to make a couple changes.
Here's what it looks like on the scope. Top is the input, bottom is the output.
HTH,Code:'**************************************************************** '* Name : FREQx2.bas * '* Author : Darrel Taylor * '* Date : 2/27/2007 * '* Version : 1.0 * '* Notes : Doubles the frequency of input pulses * '* : Range = .1hz to 750 hz (40-60% DutyCycle) * '* : Target = PIC12F629 * '**************************************************************** @ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF DEFINE NO_CLRWDT 1 Clear SpeedPin VAR GPIO.2 ; Input from speed sensor SpeedX2Pin VAR GPIO.4 ; Output to Speedometer IdleState CON 1 ; State of input when sensor ; is not on a "Slot" LastState VAR BIT ; Last state the Input changed to LoopCount VAR byte ; Counts the loops of each pulse LoopCount1 VAR byte LoopCount2 VAR byte X2Count VAR byte ; Counts the loops of output pulse X2Count1 VAR byte X2Count2 VAR byte CMCON = 7 SpeedX2Pin = IdleState OUTPUT SpeedX2Pin Main: LoopCount = LoopCount + 1 ; 24-bit counter If LoopCount = 0 Then LoopCount1 = LoopCount1 + 1 if LoopCount1 = 0 then LoopCount2 = LoopCount2 + 1 endif endif IF SpeedPin <> LastState then ; If Input State Changed? LastState = SpeedPin X2Count = LoopCount X2Count1 = LoopCount1 X2Count2 = LoopCount2 ASM bcf STATUS,C ; X2Count = LoopCount / 2 rrf _X2Count2, F ; Output Pulse is half of Input rrf _X2Count1, F rrf _X2Count, F ENDASM LoopCount = 0 ; reset LoopCount LoopCount1 = 0 LoopCount2 = 0 SpeedX2Pin = !IdleState ; start Output Pulse else if SpeedX2Pin != IdleState then if X2Count = 0 then ; countdown output time (24bit) if X2Count1 = 0 then if X2Count2 = 0 then SpeedX2Pin = IdleState ; end of pulse, else ; wait for next transition X2Count2 = X2Count2 - 1 X2Count1 = 255 X2Count = 255 endif else X2Count1 = X2Count1 - 1 X2Count = 255 endif else X2Count = X2Count - 1 endif else @ NOP ; Keep the loop symmetrical @ NOP @ NOP @ NOP endif endif goto Main end
DT
Bookmarks