mechanical speedo motor driver from an ABS wheel sensor

Changster

New Member
Hi All,

Ive got an old (restored) MK3 Ford Fiesta RS1800 in which ive changed the differential so that unfortunately the original mechanical speedo drive is no longer functioning. I do however (to keep it original looking) want to retain the original mechanical speedo. I have fitted an ABS sensor to the gearbox to supply a speed signal.

I've obtained a suitable motor with 5:1 gearbox hooked up to the speedo cable that used to go to the gearbox and when running on 12v will see the speedo exceed the maximum speed indicated.
The speedo drive has a feedback hall effect unit in-line with the original speedo cable to supply feedback pulses to keep the motor and indicated speed correct in case of friction etc in the speedo cable drive setup.

My question is: do i program the picaxe to take the speed pulse train from the ABS sensor and 'map' it to a table such that the feedback sensor feeds the correct speed pulses back according to the table and hence motor speed to display the correct speed on the mechanical speedo OR do I set a linear relationship between the speed pulses-in and the feedback pulses to display the correct speed??

Or can you think of a better, simpler or cleverer way of achieving this?!

regards
mark
 

erco

Senior Member
As long as you are modding, just hack the speedometer and use a servo to move the needle. Simple lookup table from your hall effect sensor drives the servo.
 

Jeremy Harris

Senior Member
Magnetic drive mechanical speedos are pretty linear, as they were cable driven at a fixed ratio, so I'd say all you need to do is determine the rpm you need to drive it at for the most accurate point (probably 30mph would be a good choice) and then do a linear map from there to get the speed indication to at least as good as it would have been with the original cable drive.

You used to be able to get in-line cable gearboxes to deal with the change in diff ratios at one time, though, plus some gearboxes had the provision for changing the cable drive gear to allow for this, too.

The picaxe solution seems a reasonable one, though. You may find that you can get a small stepper motor to run fast enough to drive the speedo head - might be an easier option in terms of driving it at the right speed. IIRC the speedo only runs at a few hundred rpm at most, and a small stepper could be driven at around this speed if the torque requirement was low (which I suspect it is).
 

rossko57

Senior Member
Cable drive also drives odometer/trip counter mechanism; servo solution would need some other gubbins, torque loading may vary and glitch.
The motor drive with feedback sounds workable.
 

Pongo

Senior Member
To lighten the load on the processor I would be tempted to do a frequency to voltage conversion of the ABS signal so it can be sampled at whatever rate makes sense for the motor drive program.
 

Changster

New Member
Cheers for the advice guys..
If i did F to V conversion how would i compare the feedback pulses? Is there a 'compare' function that i could F to V the feedback pulses to keep the speed correct to the input pulses?

I tested the rpm for the speedo to read FSD (140mph/225kph) and its around 2000rpm.. Is there stepper motors that rotate this fast?
 

Pongo

Senior Member
Can you tell us the pulse frequency ranges for the ABS and the motor? I think that would help get you the best answers.

As far as I know 2000 rpm will be outside the range of commonly available steppers.
 

Jeremy Harris

Senior Member
This isn't a Picaxe related reply, but have you checked out the range of speedo gears that were made for the BC gearbox? I have a feeling that Ford made a pretty wide range of speedo gears for these gearboxes, that were (IIRC) colour coded. All that was normally needed if you change the diff ratio was to swap out the plastic speedo drive gear in the gearbox for the one that matches the new ratio. Once upon a time Speedy Cables were the people who had all this stuff to hand, and it might well be well giving them a call. I've used them in the past for dealing with issues like this on other cars.
 

Changster

New Member
Hi Jeremy,
I have been down this route before but the reason for building this picaxe speedo controller is the Trans-x differential I've fitted does not leave any room within the casing to fit the std speedo drive mechanism. So this project is to build a replacement 'gadget' to make the std speedo work and to try and exercise my programming and engineering skills!
I've hooked up the motor and set it to run at 56MPH and the feedback sensor is outputting 125Hz.
The input speed frequency from the ABS sensor will vary from 0 to 3000Hz for well over the speed limit! I haven't got the frequency for 56MPH yet as the car is not on the road yet.
I'm still wondering whether it would be better to build a table of input frequency against feedback frequency and interpolate (if possible) adjacent cells to give a smooth motor speed or whether a linear relationship between the two frequencies will offer the best performance/response...?
 

Jeremy Harris

Senior Member
The speedo response is pretty much linear, as in the normal application it's driven at an rpm directly and linearly related to the drive shaft speed. So, all you need is a linear output, no need for any complex maths. I think it'd be best to measure the rpm needed at the speedo for a given reference speed (30mph might be a good choice, as that's where you probably want the best accuracy). Next just set the drive to run at this speed when it's getting 67 Hz from the sensor, and 0 rpm when it's getting 0 Hz.

Some mechanical (really magnetic reluctance) speedos have the cable rpm per mph marked somewhere on them. Older ones often had this on the dial, but others have it hidden somewhere on the mechanism.
 

Changster

New Member
Hi All,

Im trying to get my motor to run at a steady speed with feedback from a set speed but the motor seems to hunt and then it goes into flatout mode as the debug mode shows the variable overflowing. I cant see where to put in the MAX command to stop it. can anyone help?

this is my code:

Code:
init:
		
		symbol setspeed=w1 rem B2
		symbol feedback=w2 rem B4
		symbol speedout=w3 rem B6		
		
		pwmout b.3,15,500 ; set pwm duty
		
		let speedout=0		
		
	main:
	
		rem count c.1,500,setspeed
		
		setspeed=15 ;Debug B2
		
		
		count c.2,200,feedback ;Debug B4				
		
		if feedback>setspeed then let speedout=speedout+setspeed-feedback endif
		
		if setspeed>feedback then let speedout=speedout+setspeed+feedback endif		
				
		debug
		
		pwmduty b.3,speedout ; set pwm duty Debug B6
		
		pause 500 ; pause 0.5 sec		
		
		goto main ; loop back to start
 

Changster

New Member
this seems to work better but can i speed the feedback loop up??

Code:
init:
		
		symbol setspeed=w1 rem B2
		symbol feedback=w2 rem B4
		symbol speedout=w3 rem B6		
		
		
		pwmout b.3,15,500 ; set pwm duty
		
		let speedout=2		
		
	main:
	
		rem count c.1,500,setspeed
		
		setspeed=7 ;Debug B2
		
		
		count c.2,200,feedback ;Debug B4
		
				
		
		if feedback>setspeed then gosub speeddown
		
		if setspeed>feedback then gosub speedup
		
		
				
		debug
		
		pwmduty b.3,speedout ; set pwm duty Debug B6
		
		rem pause 30 ; pause 0.5 sec	
		
		
		
		
		goto main ; loop back to start
		
		
		
	speeddown:
		
		speedout=speedout-1 max 254 min 0
		
		return
		
	speedup:
		
		speedout=speedout+1 max 254 min 0
		
		return
Its just a temporary code as i want it to keep a stable speed during variable voltage found in a car etc so i'm building and testing each bit as I go..
Is there any way of improving the code for speed?
 

AllyCat

Senior Member
Hi,

can i speed the feedback loop up??
Yes, remove the DEBUG and put in a custom SERTXD to show just the variables that are essential to see. Also you can use a higher clock frequency with SETFREQ but will need to change the serial baud rate accordingly.

Note that MIN 0 is never useful because PICaxe maths doesn't recognise any lower (i.e. negative) values, (i.e. -1 is 255 which is positive so >0). Either use MIN 1 or apply it before the subtraction, e.g. speedout = speedout min 1 - 1.

Cheers, Alan.
 

hippy

Technical Support
Staff member
Code:
pwmout b.3,15,500 ; set pwm duty
Note that duty should range from zero to four times period, so for a period of 15 the duty should range from 0 to 60.

It would be worth clarifying what period or range of duty is required because that affects how duty is varied, what any limiting value used should be.

Assuming period is 15, maximum duty is 60, 'n' is the amount to change by, to do it in one line I believe the following will do the job ...

' Subtract n
speedout = speedout MIN n - n

' Add n
speedout = 60 - speedout MAX n + speedout
 

Changster

New Member
Hi All, with regards to the above post from Hippy, when using the picaxe 18 high power board, on power up it spins the motor up to full vcc supply to the motor. Is there a way of disabling the pwm output on switch on as this spins up the speedo unit and flicks the needle right round the scale but after this the circuit works normally... regards Mark
 

Changster

New Member
Hi All

My code so far is:

init:
setfreq m32

symbol setspeed=w1 rem B2
symbol feedback=w2 rem B4
symbol speedout=w3 rem B6

pwmout b.3,100,0 ; set pwm duty

speedout=60

setspeed=12

rem setspeed=2 mph=10
rem setspeed=3 mph=17
rem setspeed=4 mph=22
rem setspeed=5 mph=30
rem setspeed=6 mph=37
rem setspeed=7 mph=44
rem setspeed=8 mph=50
rem setspeed=9 mph=57
rem setspeed=10 mph=64
rem setspeed=11 mph=70
rem setspeed=12 mph=77



main:

rem count c.1,500,setspeed


if pinc.0=1 then gosub addspeed

if pinc.1=1 then gosub subspeed


rem setspeed=15 ;Debug B2 temp speed input


count c.2,550,feedback ;Debug B4 count feedback pulses


if feedback>setspeed then gosub speeddown

if setspeed>feedback then gosub speedup


pwmduty b.3,speedout ; set pwm duty Debug B6

rem pause 30 ; pause 0.5 sec


debug


goto main ; loop back to start



speeddown:

speedout=speedout-1 max 254 min 0

return

speedup:

speedout=speedout+1 max 254 min 0

return




addspeed:

setspeed=setspeed+1

return


subspeed:

setspeed=setspeed-1

return




see my other post about pulse doubling to increase the resolution of the speed..

http://www.picaxeforum.co.uk/showthread.php?26493-Pulse-doubling-within-Picaxe-code-can-it-be-done

Regards
Mark
 
Top