PDA

View Full Version : Doubling the pusle count



malc-c
- 26th February 2007, 23:14
Guys,

Quick question. A friend has replaced his instrument consol in his wifes car, for one that has a tacho and odometer (speedo). The tacho works fine, but the speedo uses an optical sensor (from where I don't know) that uses a slotted disk to generate the pulses, the result of which is that the speedo reads half of the true speed (ie when the speedo is showing 20mph the car is actually doing 40mph.

He has asked me if there is a way of using some form of electronics to double the count from the optical disk sensor. I did suggest replacing the disk with twice the number of slots, but he said that is impossible to do without distroying the sensor.

I was wondering if there was any way of using a small PIC to do the job. Not sure of how the current sensor is decoded (ie if its just the square wave pusles that is checked or if it already counts the low to high / high to low pusles. - If it counts just the positive going pulses, the could a PIC be used to count the change of state which would then result in twice the count and use this to base the frequency of the outputted square wave which could then be fed to the speedo receiver ?

The other issue is that if the encouder is running at 12v what would be the best way to reduce this voltage to the normal 5v level, would a simple voltage divider with two resistors work ?

skimask
- 26th February 2007, 23:42
Guys,

Quick question. A friend has replaced his instrument consol in his wifes car, for one that has a tacho and odometer (speedo). The tacho works fine, but the speedo uses an optical sensor (from where I don't know) that uses a slotted disk to generate the pulses, the result of which is that the speedo reads half of the true speed (ie when the speedo is showing 20mph the car is actually doing 40mph.

He has asked me if there is a way of using some form of electronics to double the count from the optical disk sensor. I did suggest replacing the disk with twice the number of slots, but he said that is impossible to do without distroying the sensor.

I was wondering if there was any way of using a small PIC to do the job. Not sure of how the current sensor is decoded (ie if its just the square wave pusles that is checked or if it already counts the low to high / high to low pusles. - If it counts just the positive going pulses, the could a PIC be used to count the change of state which would then result in twice the count and use this to base the frequency of the outputted square wave which could then be fed to the speedo receiver ?

The other issue is that if the encouder is running at 12v what would be the best way to reduce this voltage to the normal 5v level, would a simple voltage divider with two resistors work ?

Off the top of my head (and to keep it seriously simple) you could 'COUNT' the input pulses, double that and 'FREQOUT'. I see the obvious problem with that...but them maybe setup the PWM or TMR hardware to output the doubled-pulses.

malc-c
- 27th February 2007, 07:52
Thanks for that - so something like Freqout=2 X pulsein.... I'll try knocking up a square wave generator and use that as a signal input to a PIC and see what happens - many thanks

sayzer
- 27th February 2007, 08:18
....(ie when the speedo is showing 20mph the car is actually doing 40mph...



malc-c,

Two other solutions:

1. Change the numbering on the speedo display.
or
2. Put a little note on the display telling the driver that "Drive half speed and be safe". :) :D

-------------

malc-c
- 27th February 2007, 21:32
malc-c,

Two other solutions:

1. Change the numbering on the speedo display.
or
2. Put a little note on the display telling the driver that "Drive half speed and be safe". :) :D

-------------

Yeah.. I already told my mate that the simple answer was to tippex out the numbers and letrasett new digits on the dial :)

Didn't go down well !

keithdoxey
- 27th February 2007, 22:11
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.

mister_e
- 27th February 2007, 22:38
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.

Archangel
- 28th February 2007, 06:51
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

malc-c
- 28th February 2007, 09:32
Guys thanks again for your contributions

I'll pass on the URL to this topic and let him have a read.

Darrel Taylor
- 1st March 2007, 08:14
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.

http://www.pbpgroup.com/files/FreqX2.JPG


'************************************************* ***************
'* 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

HTH,

Acetronics2
- 1st March 2007, 09:31
I remember we did that with a 4069 hex inverter ... some centuries ago.

The trick is to trigger a simple monostable through a basic diode AND Gate on the rising edge ... and also the falling edge.

How ???

an inverted falling edge is a leading edge ... no more.

That's not a "true" freq. doubler ... but it doubles the Pulse count !!!

Alain

Darrel Taylor
- 1st March 2007, 09:34
Sure,

But can a monostable multivibrator measure the previous pulse width and modify it's time period accordingly?

Added: In a single 8-pin package?
<br>

Acetronics2
- 1st March 2007, 12:15
Hi, Darrel

Your job is nice ...and I do appreciate !!!

Just understand it is over the requirements ...

But excellent example for further general development !!!

Alain

Darrel Taylor
- 1st March 2007, 12:25
Is it me? Or is everyone going nut's around me.

I got a teddy bear to throw here....
<br>

mister_e
- 1st March 2007, 14:04
don't worry... i feel of some jealousy 'round :D

malc-c
- 1st March 2007, 14:35
Is it me? Or is everyone going nut's around me.

I got a teddy bear to throw here....
<br>

LOL - (seems my comment stuck :eek: )

Well I apreciate your help Darrel.

I have a 12F675 to hand, and I'll compile and burn the HEX to it and post it to my mate so he can try it. What would be the best way to interface the PIC to the signal, assuming it output is at 12v battery levels.

malc-c
- 1st March 2007, 17:59
Darrel,

I've just received a reply from my mate




The pulses appear to be 0-12-0 "square" wave, but not 50/50 duty cycle. the 12 volt pulse is much less than the 0 volt. I've found that a similar unit off a Ford uses a hall effect transistor and a multipole magnet, very similar to a heli throttle govenor.

Frequency...difficult right now to get you an accurate figure for the maximum..minimum is easy, it's 0....LOL. I can't imagine it would be more than 1 khz maximum on the unit I have.



Does this help to determin the adjustments for the code

mister_e
- 1st March 2007, 18:03
o.k. ONCE again ;)

which car model, brand, year?

malc-c
- 1st March 2007, 21:04
o.k. ONCE again ;)

which car model, brand, year?

Probably not going to mean much to you.

Make and Model: Vauxhall Corsa
Year: ? no idea - will ask him.

All I had to go on was:


My wife Jenny has a Vauxhall Corsa that had just a cable driven speedo. I've gotten hold of an insrtumanet cluster that has tacho and speedo, but the speedo isn't cable, it's electrical. The tach works fine, but the rotary encoder I've picked up (which is supposed to be the right one) is giving only half the number of pulses required by the speedo, i.e. the speedo is reading half the actual speed.
The question I have is....."Is there a simple way to double the number of pulses to the speedo...like a frequency doubling circuit" ??

I believe the unit I have works optically...disc with 10 light dark changes per rev. The easy answer would be to put a disc in the unit with twice the number of segments, but it's not able to be disassembled easily.

mister_e
- 1st March 2007, 21:53
Maybe you didn't know it alrady but, i've been a car accessoiries installer (alarm, car starter, radio, gps, etc etc ) for over 12 years and i still do some custom car modification here and there.

Why i asked, is because most cruise control brand have their own application list and hints. Even on some VSS generated cable, some cars may have another source for an optional Cruise control or else. And you was right... i never see any opel/vauxhall here... only few picture here and there over the web.

Anyways, without knowing the exact frequency range, Darrel's example have to work within it's range... no doubt on it!

To interface.. a simple NPN or PNP or simple OP-AMP would do the job pretty well. I don't think 12V amplitude is really needed... maybe 5Volts could work... with a simple resistor in serie.

Hey.. you didn't SIMed it this time :D ? http://www.mister-e.org/Pics/ROFL

malc-c
- 1st March 2007, 23:03
Steve, no I didn't know you had the automotive electrical experience.

I'm off to download some spice application and SIM this... or should I just contact a local PCB house and get them to send me a prototype... afterall if its wrong I'll bin that one and order another :D :)

Any chance of a quick schematic on the input.. I was planning on using a small 100mA 5v reg for the PICs supply, and assume that the transistor would be between +5 and gnd (C and E) with the base connected to the sensor ?

mister_e
- 1st March 2007, 23:32
What i suspect to work... is something as simple as...
<img SRC="http://www.picbasic.co.uk/forum/attachment.php?attachmentid=1433&stc=1&d=1172791957">

for the input, a simple resistor in serie will work without problem (1-10k), OR a simple voltage divider.

Darrel Taylor
- 2nd March 2007, 00:27
The pulses appear to be 0-12-0 "square" wave, but not 50/50 duty cycle.

I was hoping it would be the easy way (50%).
Oh well, back to the drawing board. I'm re-writing it now.

Should have something later today (that's probably tomorrow for your time period).
<br>

mister_e
- 2nd March 2007, 00:37
Darrel... i don't think it will be revealant to be 50% or not... it's all about pulse/miles after all.

In the good ol' time we installed 2 magnetic sensor on the drive shaft as a VSS generator. using that... no way you could have a 50% duty cycle as the magnets where about 1 inch wide.

I should take a car ride here and record the VSS signal to see how clean it is... in case some want to know.

mister_e
- 2nd March 2007, 00:55
AAAAAAAAAAAHAHAHAHAHAHHA i knew that one of my OLD cruise control installation manual would be handy one day or another... here's a quote of the revealant part...
<table><tr><td>http://www.mister-e.org/Pics/DataSheet.gif</td><td>
Using a multimeter to measure the frequency
of the VSS pulse. Usually, the PPM
(pulses per mile) of the VSS signal is
known. At 40 km/hr (25 mph) the following
frequencies should be:
2000 PPM : 14 hz
4000 PPM : 28 hz
5000 PPM : 35 hz
8000 PPM : 56 hz
</td><td>http://www.mister-e.org/Pics/HappyBunny.gif</td></tr></table>

Darrel Taylor
- 2nd March 2007, 02:16
It was easier than I thought, just more of the same stuff. :)

<table><tr><td>
IdleState CON 0
http://www.pbpgroup.com/files/HighPulsesSM.JPG</td><td>
IdleState CON 1
http://www.pbpgroup.com/files/LowPulsesSM.JPG</td></tr></table>

'************************************************* ***************
'* Name : FREQx2.bas *
'* Author : Darrel Taylor *
'* Date : 3/1/2007 *
'* Version : 2.0 *
'* Notes : Doubles the frequency of input pulses, *
'* : and maintains the same DutyCycle as the Input. *
'* : Range = .1hz to 500 hz (0-40% DutyCyle) *
'* : Target = PIC12F629/675 *
'************************************************* ***************
@ __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 0 ; State of input when sensor
; is not on a "Slot"
NotIdle CON IdleState ^ 1
LastState VAR BIT ; Last state the Input changed to
LoopCount VAR byte ; Counts the loops of each pulse
LoopCount1 VAR byte
LoopCount2 VAR byte

PulseWidth VAR byte BANK0 ; Counts the loops of output pulse
PulseWidth1 VAR byte BANK0
PulseWidth2 VAR byte BANK0

LastPulseWidth VAR byte ; saved width of last pulse
LastPulseWidth1 VAR byte ; so it can duplicate it
LastPulseWidth2 VAR byte

CycleWidth VAR byte BANK0 ; Counts the loops of output cycle
CycleWidth1 VAR byte BANK0
CycleWidth2 VAR byte BANK0

OutPulseCount VAR BIT


CMCON = 7
'ANSEL = 0 ; for 12F675

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

if LastState = NotIdle then ; Start of Input Pulse
CycleWidth = LoopCount
CycleWidth1 = LoopCount1
CycleWidth2 = LoopCount2
ASM
bcf STATUS,C ; CycleWidth = LoopCount / 2
rrf _CycleWidth2, F ; Output Cycle is half of Input
rrf _CycleWidth1, F
rrf _CycleWidth, F
ENDASM
LoopCount = 0 ; reset LoopCount
LoopCount1 = 0
LoopCount2 = 0
else ; End of Input Pulse
PulseWidth = LoopCount
PulseWidth1 = LoopCount1
PulseWidth2 = LoopCount2
ASM
bcf STATUS,C ; PulseWidth = PulseWidth / 2
rrf _PulseWidth2, F ; Output Pulse is half of Input
rrf _PulseWidth1, F
rrf _PulseWidth, F
ENDASM
LastPulseWidth = PulseWidth
LastPulseWidth1 = PulseWidth1
LastPulseWidth2 = PulseWidth2
SpeedX2Pin = NotIdle ; start First Output Pulse
OutPulseCount = 0
endif
else
if SpeedX2Pin = NotIdle then
if PulseWidth = 0 then ; countdown output time (24bit)
if PulseWidth1 = 0 then
if PulseWidth2 = 0 then
SpeedX2Pin = IdleState ; end of pulse,
else ; wait for next transition
PulseWidth2 = PulseWidth2 - 1
PulseWidth1 = 255
PulseWidth = 255
endif
else
PulseWidth1 = PulseWidth1 - 1
PulseWidth = 255
endif
else
PulseWidth = PulseWidth - 1
endif
else
@ NOP ; Keep the loop symmetrical
@ NOP
@ NOP
@ NOP
@ NOP
endif

if OutPulseCount = 0 then
if CycleWidth = 0 then ; countdown to Midpoint of cycle
if CycleWidth1 = 0 then
if CycleWidth2 = 0 then
SpeedX2Pin = NotIdle ; Start second pulse
OutPulseCount = 1
PulseWidth = LastPulseWidth
PulseWidth1 = LastPulseWidth1
PulseWidth2 = LastPulseWidth2
else
CycleWidth2 = CycleWidth2 - 1
CycleWidth1 = 255
CycleWidth = 255
endif
else
CycleWidth1 = CycleWidth1 - 1
CycleWidth = 255
endif
else
CycleWidth = CycleWidth - 1
endif
else
@ NOP ; Keep the loop symmetrical
@ NOP
@ NOP
@ NOP
endif
endif
goto Main
end

HTH,

malc-c
- 2nd March 2007, 08:18
The knowledge and experience you guys have amaizes me !

Woke up this morning and checked this thread and found a suggested schematic from Steve and revised code from Darrel ! - Thanks guys.

I'll compile and burn the code to a 12F675 and send it to my mate for testing.. I'll report back on his findings in a couple of days

keithdoxey
- 2nd March 2007, 09:35
The knowledge and experience you guys have amaizes me !

Woke up this morning and checked this thread and found a suggested schematic from Steve and revised code from Darrel ! - Thanks guys.

I'll compile and burn the code to a 12F675 and send it to my mate for testing.. I'll report back on his findings in a couple of days

I would just like to point out that in the event of your mate getting caught for speeding, Steve and Darrels contribution towards the speeding fine will be limited to the amount paid for the code and schematic :) :)

Darrel Taylor
- 2nd March 2007, 12:09
I don't know if I could afford that Keith :)

I think Steve's circuit will invert the output, so I'll need to reverse the pulse in the program to be able to use that.

And you need an input circuit. I was thinking something like the circuit below might be nice. And, I'll need to make it use the GP0 input to determine what the Idle polarity is.

I smell a Version 3.

I tried something else, then realized it wouldn't work.
What do you think about this one.


Click Image to Enlarge
http://www.pbpgroup.com/files/PulseDoublerSM.GIF (http://www.pbpgroup.com/files/PulseDoubler.GIF)
Click Image to Enlarge

malc-c
- 2nd March 2007, 12:50
Keith, I like where you're coming from ;)

Darrel, that looks good. I've already pointed my mate to this forum so he can keep up to speed to see what a stirling effort you guys are doing !

Thanks guys !

Darrel Taylor
- 2nd March 2007, 14:18
Well, for whomever will be using it in the end ...

Here's version 3. Hopefully the last one.
I think I covered all the bases.

Added another input. (see schematic above) GPIO.1 that determines if the output is inverted or not. It has a weak Pull-up, so you can just leave it disconnected for use with the NPN transistor.


'************************************************* ***************
'* Name : FREQx2.bas *
'* Author : Darrel Taylor *
'* Date : 3/2/2007 *
'* Version : 3.0 *
'* Notes : Doubles the frequency of input pulses, *
'* : and maintains the same DutyCycle as the Input. *
'* : Range = .1hz to 500 hz (0-40% max DutyCyle) *
'* : Target = PIC12F629/675 *
'************************************************* ***************
@ __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 VAR GPIO.0 ; State of input when sensor
; is not on a "Slot"
Invert VAR GPIO.1 ; Inverts output if = 1

OPTION_REG.7 = 0 ; enable weak Pull-ups
WPU = 3 ; weak Pull-up on GP0 and GP1
;_________________________________________________ ____________________________

LastState VAR BIT ; Last state the Input changed to
LoopCount VAR byte ; Counts the loops of each pulse
LoopCount1 VAR byte
LoopCount2 VAR byte

PulseWidth VAR byte BANK0 ; Counts the loops of output pulse
PulseWidth1 VAR byte BANK0
PulseWidth2 VAR byte BANK0

LastPulseWidth VAR byte ; saved width of last pulse
LastPulseWidth1 VAR byte ; so it can duplicate it
LastPulseWidth2 VAR byte

CycleWidth VAR byte BANK0 ; Counts the loops of output cycle
CycleWidth1 VAR byte BANK0
CycleWidth2 VAR byte BANK0

OutPulseCount VAR BIT


CMCON = 7
'ANSEL = 0 ; for 12F675

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

if LastState = (IdleState ^ 1) then ; Start of Input Pulse
CycleWidth = LoopCount
CycleWidth1 = LoopCount1
CycleWidth2 = LoopCount2
ASM
bcf STATUS,C ; CycleWidth = LoopCount / 2
rrf _CycleWidth2, F ; Output Cycle is half of Input
rrf _CycleWidth1, F
rrf _CycleWidth, F
ENDASM
LoopCount = 0 ; reset LoopCount
LoopCount1 = 0
LoopCount2 = 0
else ; End of Input Pulse
PulseWidth = LoopCount
PulseWidth1 = LoopCount1
PulseWidth2 = LoopCount2
ASM
bcf STATUS,C ; PulseWidth = PulseWidth / 2
rrf _PulseWidth2, F ; Output Pulse is half of Input
rrf _PulseWidth1, F
rrf _PulseWidth, F
ENDASM
LastPulseWidth = PulseWidth
LastPulseWidth1 = PulseWidth1
LastPulseWidth2 = PulseWidth2
SpeedX2Pin = ((IdleState ^ 1) ^ Invert) ; start First Output Pulse
OutPulseCount = 0
endif
else
if SpeedX2Pin = ((IdleState ^ 1) ^ Invert) then
if PulseWidth = 0 then ; countdown output time (24bit)
if PulseWidth1 = 0 then
if PulseWidth2 = 0 then
SpeedX2Pin = (IdleState ^ Invert) ; end of pulse,
else ; wait for next transition
PulseWidth2 = PulseWidth2 - 1
PulseWidth1 = 255
PulseWidth = 255
endif
else
PulseWidth1 = PulseWidth1 - 1
PulseWidth = 255
endif
else
PulseWidth = PulseWidth - 1
endif
else
@ NOP ; Keep the loop symmetrical
@ NOP
@ NOP
@ NOP
@ NOP
@ NOP
endif

if OutPulseCount = 0 then
if CycleWidth = 0 then ; countdown to Midpoint of cycle
if CycleWidth1 = 0 then
if CycleWidth2 = 0 then
SpeedX2Pin = ((IdleState ^ 1) ^ Invert) ; Start second pulse
OutPulseCount = 1
PulseWidth = LastPulseWidth
PulseWidth1 = LastPulseWidth1
PulseWidth2 = LastPulseWidth2
else
CycleWidth2 = CycleWidth2 - 1
CycleWidth1 = 255
CycleWidth = 255
endif
else
CycleWidth1 = CycleWidth1 - 1
CycleWidth = 255
endif
else
CycleWidth = CycleWidth - 1
endif
else
@ NOP ; Keep the loop symmetrical
@ NOP
@ NOP
@ NOP
@ NOP
endif
endif
goto Main
end

You come up with some fun projects Malcolm. Trains, Automobiles, All we need are planes, and we're set. :)
<br>

Acetronics2
- 2nd March 2007, 14:30
Hi, Darrel

You really want something about planes ....???

I must have a project somewhere for you ... one minute please !

Alain

malc-c
- 2nd March 2007, 18:47
I've just received an e-mail from my mate, thought you guys might like to know that he passes on his thanks



Malc...really looks like I've given you guys something to think about with this one. Thank them for their efforts will you and just for the record the car is a 1995 Vauxhall Corsa 1.2 injection...LS

I've programmed the PIC with Darrels code and will build the circuit over the weekend as he doesn't have them to hand

Thanks guys for your help, hopefully it will be positive news when he receives it and fits it to his wifes car

malc-c
- 9th March 2007, 18:46
Darrel,

I've made a small PCB based on your schematic above, and sent it to my mate with the car to try. The PIC was programmed with your version 3 code.

I've received a mail from him asking the following

Do you think I should leave the two "control" wires open for starters and only mess with them if it doesn't work right stright off???

The two control wires he mentions are two wires for the idle and invert options. I suggested he leaves these un-connected first off and see if there is a change in the speedo reading, but wondered if you could clarify (in laymans terms for both me and Brian) how these options affect the processing of the signal from the sensor (or how it should affact the output)

mister_e
- 9th March 2007, 19:00
As long as the internal pull-up are good enough to reject the possible incoming noise, it won't cause any problem... but i'm not a internal-pull-up oriented guy for a final product... but once again it's me.

malc-c
- 9th March 2007, 20:58
I thought about adding a couple of external pull up resistors, but didn't know ( I know, should of asked ) if taking them high would of caused problems.. Its not a problem as they can be added at the switch

Darrel Taylor
- 10th March 2007, 03:21
I think if there are antenna's (a.k.a. long wires) hooked up to the option pins, the internal pull-ups may not be good enough. Small jumpers or dip switches should be ok though. No problem adding external pull-ups if desired. Or you can tie them directly to VDD or VSS.

With the IdleState pin left open, the program will assume the input idles HIGH, with negative going pulses, which is the opposite of the 0-12-0 polaraity described before. So I'd start with that pin grounded.

The Invert input should be left open, without any wires, since that circuit uses the NPN transistor that inverts the output. It was just an option available for anyone else that might pick up the code from the forum. The output follows the same polarity as the input Idlestate, so there shouldn't be a need to change it with that circuit.

When you programmed the chip, did you uncomment the ANSEL line?
I was using a 12F629, but I think you're using a 675.
<br>

malc-c
- 10th March 2007, 08:56
Thanks for the feedback.

I did see you note on the use of the chip, and missed it completely when I programed the ver3 of the code ! :eek: Bu99er !!!

With the ansel line remmed out and using a 12F675 - how would that effect the way the unit performed... (Brian - if you are reading this I'll send a new PIC to you if I screwed up !!)

Darrel Taylor
- 10th March 2007, 09:42
With the ansel line remmed out and using a 12F675 - how would that effect the way the unit performed

Without it, there won't be a performance.
The digital Input latches are disabled while in analog mode. So it can't see the pulses, or the options.

Sorry, I should have left it un-commented.

malc-c
- 10th March 2007, 11:52
beep beep beeeeeP

I thought as much... I'll re-code and send him a replacement PIC

Next time I'll wear my glasses !!

Darrel Taylor
- 9th June 2007, 19:57
HI Malcolm,

Stumbled across this thread again.
Just wondering if he ever got it working?
<br>

malc-c
- 9th June 2007, 21:10
Hi Darrel,

I sent a couple of PICs to him and I think that from memory he was not able to get it working and gave up in the end. Thanks for the interest and your support with the original code

Darrel Taylor
- 9th June 2007, 21:33
Bummer. :rolleyes:
<br>

mdaweb
- 17th May 2012, 13:17
Bummer. :rolleyes:
<br>

Mister E,


I used your program Pulse counter to make my speedometer, fit like a glove, 100Kmh = 400 Hz, and multiply by 3 the counting of pulses, has a tachometer.


This working more than eight years in my car.