Calculating Car Speed

giuseppe

Member
So my goal here is measure a car's speed. Would I have to use a Vehicle Speed Sense wire or the tachometer wire? Also, I really do not what kind of method either one of those wires use to actually send this particular data to a instrument cluster. Does it just send pulses or does it send data through CAN BUS? Anyone ever obtain speed data from a car before?
 

Charliem

Senior Member
I can't say all car VSS are like this just the ones I work on.The VSS outputs a analog pulse.You need to clean it up and condition it for a pic to use it as a input.I would use the VSS (vehicle speed sensor) sensor to obtain the cars speed.Also you will have to factor in the circumference of the tires and the number of pulses in one rotation.Should doable though.
 

papaof2

Senior Member
Speed is from a speed sensor; the tachometer is engine speed which depends on both vehicle speed and the transmission gear which is in use. Ground speed at 3000RPM in first gear is a lot slower than 3000RPM in fourth gear ;-)

You need the wiring diagram for the specific vehicle - it might have a speed sensor (x pulses/MPH or y pulses/km) or that data may only be available via the OBDII connector on the vehicle (1996 and newer).

If the vehicle is old enough, speed sensing is from a mechanical link (cable from transmission or a front wheel [rear-wheel drive vehicle]).

You can also use a GPS to get speed data.

John
 

krypton_john

Senior Member
So my goal here is measure a car's speed. Would I have to use a Vehicle Speed Sense wire or the tachometer wire? Also, I really do not what kind of method either one of those wires use to actually send this particular data to a instrument cluster. Does it just send pulses or does it send data through CAN BUS? Anyone ever obtain speed data from a car before?
You could look at interfacing to the car's OBD-II diagnostic port. Pretty much all cars post late 90's have this port.

http://www.thinkythings.org/obdii/
 

kewakl

Senior Member
if available, the ABS system can give good info about speed. need to know *exact* tire size.
You could compare all tire's ABS pulses. IIRC, this is how some makers detect LowTire.

This ABS info could provide interesting info in curves, over bumps and for spinning tires.
 

hippy

Ex-Staff (retired)
With the usual caveats of vehicles being safety critical systems and the potential for failings in any add-on electronics to compromise a vehicle's own systems, tapping into the ABS would likely be the least advisable mechanism.
 

Dippy

Moderator
giuseppe , firstly what is your level of electronics knowledge? (You sound like a newbie).

Secondly, as suggested by papa, get the workshop manual for the vehicle.

Thirdly, what is the make and age of car?

You could cause a lot of damage to your Dad's car if you get this wrong.
Does he mind his car being a Guinea Pig?

If you don't know what sort of signals are kicking around you will need a 'scope.
On some cars I'm sure you could pick up the pulses going to the speedo.
But you will need to buffer them so you don't affect the speedo.
You will need a 'scope.
Depends on vehicle.

I agree with hippy's sentiments - stay away from the ABS (if it has it :) ).

This may even come under the Category:
If you Need to Ask then You Shouldn't be Trying it.
 

kewakl

Senior Member
I agree with hippy's sentiments - stay away from the ABS (if it has it :) ).

This may even come under the Category:
If you Need to Ask then You Shouldn't be Trying it.
I did not mean the ABS electronics, I meant the ABS data from OBD-II as OBD and CANBus had already been put forward. Sorry.

And, yes, this may be in that category!
 

hippy

Ex-Staff (retired)
@ kewakl : Aha; see what you mean now.

Connecting via ODB II would seem to be the ideal method for any car interfacing as long as done through a proper interface so the vehicle systems are totally protected against any failures outside those.

My main concern would be that it seems ODB II may require requests to be sent to have data returned and sending data has the potential to affect vehicle system integrity. That may be my lack of understanding of ODB II protocols but the safest system would be one which is entirely read-only.
 

86atc250r

New Member
Most vehicles will have an output from the factory computer to the speedometer. This output will likely be a very basic signal that is easy to interface.

In my case, I'm dealing with a late model engine swap into an older vehicle. I wanted to eliminate the factory cable driven speedo drive and replace with a modern electric (stepper) drive - while keeping the gauge face original.

I scoped out the signal and it's a 5v square wave at 4000 pulses per mile - this is a GM PCM from the early 2000's. This pulse rate is actually adjustable via tuning software. I also scoped out a mid 90's toyota and found it's signal to also be a 5v square wave, roughly 1 pulse per second per mph.

You can use this signal to derive speed, seems pretty straight forward - until you get into the integer math.

I got what I needed done for this project without the use of a microcontroller & it worked great, however, later I wanted to play with a digital speed readout.

I had it worked out to be within an MPH or so using a picaxe but it sure seems like there should be an easier way than I was doing it. Unfortunately, I'm going to get the chance to rework mine because all my test software & calculations were lost with a laptop crash (and not saving my work!) --- always save your little quick tools you develop in the event the computer won't wake out of sleep and you have to hard reset :)

If anyone has any thoughts on an accurate & slick way to change a shrinking pulsewidth to a growing speed value, I'm all ears - the division is the killer.
 

LizzieB

Senior Member
Are you serious?
Why not? They used to (maybe still do) sell aftermarket cruise control units in the U.S. that installed that way on pre-electronic speedo vehicles. Never seemed a real good idea to me but there were thousands of them on the road.
 

Dippy

Moderator
Why not?
Well, first we don't know what car.
If FWD there is a lot of movement on the driveshaft so you'd have trouble positioning the sensor.
The sensor would have to have a good range.
Mount it on the gearbox output? Well, there's usually a damned great rubber boot just there.
It would have to be very robust , well attached and well protected.
The wiring ditto.


I would imagine the company that made the after-market cruise control spent a little bit more than 5 bucks on their stuff. And it was probably for RWD where a standard propshaft is a lot easier to deal with.


I'm NOT saying it's impossible, but based on the philosophy-of-cheapness I have seen here over the years I fear that the sticky-tape will come undone after the first puddle and it will fall off and get mangled fairly quickly :).

If you've got pulses going to the speedo and it is easily accessible then that would be a LOT easier to deal with.
 

RexLan

Senior Member
@86atc..

Possibly here:

http://www.picaxeforum.co.uk/showthread.php?t=5150

Perhaps Jeremy or Rex could elaborate further?

e

Forum searching might reveal others.

Code and circuit is here. Feed that pulse into the circuit instead of the tach pulse and select the code for one cylinder. The input circuit is necessary and quite important. May be able to modify the "cylinders" variable for a suitable pick-up point off of a wheel sensor or the actual speed sensor on the car. Most vehicles have one.

Tachometer

The easier solution of course is a small GPS module that Jeremy and I used to build this.
GPS Timer
 

LizzieB

Senior Member
Why not?
Well, first we don't know what car.
If FWD there is a lot of movement on the driveshaft so you'd have trouble positioning the sensor.
The sensor would have to have a good range.
Mount it on the gearbox output? Well, there's usually a damned great rubber boot just there.
It would have to be very robust , well attached and well protected.
The wiring ditto.

I would imagine the company that made the after-market cruise control spent a little bit more than 5 bucks on their stuff. And it was probably for RWD where a standard propshaft is a lot easier to deal with.

I'm NOT saying it's impossible, but based on the philosophy-of-cheapness I have seen here over the years I fear that the sticky-tape will come undone after the first puddle and it will fall off and get mangled fairly quickly :).

If you've got pulses going to the speedo and it is easily accessible then that would be a LOT easier to deal with.
I completely agree with you. I was just making the point that it's not as off-the-wall idea as your original comment implied. JC Whitney, purveyor of all things automotive that you never knew you needed or even existed, does still sell them.
 

papaof2

Senior Member
The aftermarket cruise control (putchased in 2007) for my previous truck (1989 Nissan) had the option of magnets on the drive shaft for use with an automatic transmission. The manual transmission vehicle worked off the tachometer pulse - a slipless drivetrain only needs to maintain engine speed to keep a constant vehicle speed. Using the tachometer pulse also meant that crise control could be used at low speeds, such as in a parade or pulling a wagon for a hayride: set speed in first gear and it will poke along at a steady 5mph. Most factory cruise controls don't work below 35mph or so - the manual usually has something like "use only on open highway".

The aftermarket cruise control also didn't lose its memory when you came to a stop (many factory versions do). If driving on country roads with 55mph speed limit and occasional traffic lights, having the cruise remember the speed is convenient when you get back in 5th gear - just tap Resume.

John
 

giuseppe

Member
giuseppe , firstly what is your level of electronics knowledge? (You sound like a newbie).

Secondly, as suggested by papa, get the workshop manual for the vehicle.

Thirdly, what is the make and age of car?

You could cause a lot of damage to your Dad's car if you get this wrong.
Does he mind his car being a Guinea Pig?

If you don't know what sort of signals are kicking around you will need a 'scope.
On some cars I'm sure you could pick up the pulses going to the speedo.
But you will need to buffer them so you don't affect the speedo.
You will need a 'scope.
Depends on vehicle.

I agree with hippy's sentiments - stay away from the ABS (if it has it :) ).

This may even come under the Category:
If you Need to Ask then You Shouldn't be Trying it.
Well I have a Technician Certification to work on low voltage appliances from Lincoln Technical Institute from Mahwah, NJ and I am currently enrolled at the New Jersey Institute Of Technology for Electrical Engineering and have not been able to take the electronics courses (besides heavy theory in Physics II) since this school will let no EE near an electronics course until they have Calculus II and and Physics II completed. I also worked as a car installer for remote starts, radios, etc.

Next semester I will have the privilege to finally take my major specific classes, Circuits and Systems I and Digital Design. So yes, in essence to the career world and professional electronics, I am of course a newbie but with playing around with electronics, sorry, no. Not as much as a newbie as you think I am. Also please do not jump to conclusions and implicitly think I am child and thinking I am "working on my father's car", its a bit annoying. I have installed things in a car, i know things can go bad very fast. Plus I merely have thoughts in my head and get curious with certain systems, for example, obtaining certain data from a car, I really have no money for parts to attempt it, I just ask for the theory. I just like to try to get ahead in my studies as an EE student by using the PICAXE since its ease of use and versatility and easy programming language. Plus if i never ask questions, I will never learn from people who are more experienced.

For everyone else, thank you for your input, greatly appreciated.
 
Last edited:

nbw

Senior Member
If you knew what gear the car was in, plus the revs, you could premap out a lookup table and then convert with a picaxe... e.g. 3000rpm in 4th might be 105 km/h...
 

MFB

Senior Member
Why not just get the speed information from a cheap GPS module? It would be completely self-contained, with no need to connect to your car wiring (well, maybe just power) or calibration. There is lots of advice on the forum about extracting data from GPS sentances.
 

MikeM100

Member
Losing the Thread

At this point of the thread, what is the question ? I 'think' it's about how to measure vehicle speed ?

If so, I would recommend using the Vehicle Speed Signal as this does 'what it says on the tin'. The difficulty is finding it on the vehicle.

I built a speed warning device some years ago (using PIC +Assembler) that displays a simple multi colour LED 'head up' warning on the windscreen. Works a treat and reminds when I exceed 30, 40,50, 60mph, speed limits.

I have a VW and after a bit of research found the logic level signal on the back of the radio ! (It is used to automatically control the volume with speed)Some simple input protection (clamp diodes) to the PIC input was all that was needed and I had no problem with 'screwing up' the vehicle electronics. I believe there are commercial products that do the same but sound an audible alert and I recall seeing that they had a list of where to find the speed signal on various vehicles ?

However I am intrigued to see what other methods forum members could devise to 'get' an accurate speed signal. Yep, GPS is nice but does it work well in tunnels and what about the cost ? Not so keen on Hall sensors and magnets on wheels/shaft due to required ruggedness ?

Ideas folks ?
 

hippy

Ex-Staff (retired)
Some simple input protection (clamp diodes) to the PIC input was all that was needed and I had no problem with 'screwing up' the vehicle electronics.
Those of us who are ultra-safety conscious would say that, while it has worked so far, there are still possibilities that it may fail and isn't provably 'safe'.

Consider for example if a power surge or glitch caused the PIC / PICAXE to flip its input to an output and pulled that signal permanently high or low. What happens then, what consequences would that actually have ?

In truth few really know. It may just lower the volume, cause the speedo to show the wrong speed, but it may permanently damage whatever's producing the signal or cause some other part of the system to detect a failure and decide to shut the car down.

If such a situation destroys what's producing the signal, what knock-on, domino effects does that have ? Could it in turn take out something which is critical or essential, be extremely adverse when travelling at speed ?

Most disasters grow from a very small and seemingly insignificant seed which is why some of us are ultra-cautious when it comes to dealing with interfacing to vehicles.
 
Last edited:

giuseppe

Member
The reason why i was thinking about obtaining data from a car, specifically the speed, is because I wanted to know if the car was in motion. I am trying think of a better way to replicate something called the "life belt". I saw it on a tv show called shark tank and there was a guy who invented a device that would alert the driver if there seatbelt was taken off and could not start the car unless the seatbelt was on. If the driver refused to put his or her belt back on during a drive then the radio would turn off and would sound an annoying alarm until the driver was fed up and put their seatbelt back on. This is of course targeting to kids driving their parent's cars.

It is US patent number 7,132,934 B2. Long short story short, I looked over the patent and drew up a rough circuit diagram and wrote some code for the picaxe. I just wanted to see if I could replicate and perhaps make it better than the one in the patent. It just seems like the inventor made it too complicated. The only input I need now is the shifter. I need to know if it is in park or not. And there is no signal wire at the park gear near the shifter that is readily available during an installation or easily accessible since it is in the instrument cluster. So i figured if I could get the car's speed, even measure just over 2 mph, it would send an input to the picaxe to detect if the car is in park or not. Gps woud lose signal so that is not the best solution. Vss wire is seeming like a hassle now and would need more interfacing circuitry. I thought about putting a magnet on the shifter and a reed switch at the point where the shifter hits park but that is easily bypassible and I do not want to use rfid (this is already used to sense the seatbelt in my design) because that would rise cost if it where ever to be built plus the magnetic switch idea would not work for all car shifters. I also thought about using an accelerometer to measure acceleration. I read somewhere that someone has done that and then integrated their equation to get velocity but that person claimed that it gave inconsistent results. I guess I could always connect it to the parking brake that is ground triggered but that just seems like a poor design idea and an "easy way" out. Plus one click on some cars of the parking break will give the electrical signal that the brake is on when mechaniclly it really is not fully set and driving is still possible.

So yeah! The only thing stopping me is to know if the car is in park or not and to do it in a well priced, decent installation and universal way!
 
Last edited:

MartinM57

Moderator
I read somewhere that someone has done that and then integrated their equation to get velocity but that person claimed that it gave inconsistent results.
...but you only want to know if there is some velocity i.e. there is some acceleration going on, so wouldn't it just be a matter of detecting accelerometer output above some (small) threshold?
 

hippy

Ex-Staff (retired)
Alternatively you could use a combination of other inputs to determine if the seat belt should be on; seat occupied ( pressure sensor perhaps ), seatbelt not on, ignition on.

A challenge not mentioned so far is how you will detect if the seat belt is on, and hasn't simply been connected behind the driver's back; the usual way to fool these systems.

Altering the seatbelt fittings for switches or to run wire through the webbing could compromise function and safety. One way would be to measure the diameter of the seatbelt take-up reel which would reduce as it's put on and should be able to detect the tucked behind driver's back case.
 

Andrew Cowan

Senior Member
If your car doesn't already have it, I wouldn't start drilling into the seatbelt fittings.

I think the idea of the accelerometer to detect movement is a good one - perhaps you could also monitor engine vibration or something? I'd be very against hacking into the car electronics.

I read somewhere that someone has done that and then integrated their equation to get velocity but that person claimed that it gave inconsistent results.
That requires an equation for the acceleration - an accelerometer outputs a number, and you cannot integrate a number. Acceleration is the rate of change of velocity, so any acceleration indicates the velocity is no longer 0. Possibly even a vibration sensor would be sufficient.

A
 

papaof2

Senior Member
"could not start the car unless the seatbelt was on"
That's already been tried in US cars and found to be non-workable.

GM had a bypass switch under the hood to allow starting the car if there was a problem with the seat belt detection system (and for the mechanic who needs to start the car without driving it). But if there's a problem with the seat belt detection system and it's unsafe to exit your vehicle, the underhood bypass switch made the driver a victim.

Do a little more research before jumping on what may appear to be a great idea.

Don't kill the engine if the seat belt appears to be removed with the vehicle in motion - power steering will be lost and power brakes are typically only useful for one application after the engine dies. Most drivers will not be able to control the vehicle under those conditions. Plus the vehicle would start slowing down with no warning to following drivers...

Try logging the date/time/place of the seat belt event and make the log easily read by the vehicle owner. Taking away driing privileges is a safer way of enforcing seat belt use, albeit after-the-fact.

John
 

giuseppe

Member
Hippy, yes I would only need a small threshold of acceleration to detect it but I am still trying to find something a little cheaper but equally effective before thinking about that route. Even if the driver tries to use cruise control to have an constant velocity to not have acceleration they have to change in speed sooner or later. I can also just wait for the first trigger of when this happens instead of it just polling for each time like say they just try to stay the same speed and for the times they do not they just ignore the system until at constant speed. Yes very unlikely but I like getting all the faults out, even the small chance ones. Like I said, this option is still good but still trying to use alternative methods.

Andrew, yes I know you need an equation, I just read that he tried it. Have no idea where this person managed to work an equation out. Still, if there was a way to get an equation just for the sake of getting velocity where the equation was obvious to get, integrating I thought was pretty clever on that person's part!

RexLan, yes I am afraid I am just concentrating on automatic cars right. I did not even consider the manual types. Even other products, such as remote starts, a majority of such a product designed is intended for automatics since they seem to be the most popular. Also since this is intended for controlling younger drivers to a certain extent, younger drivers usually learn and stick with automatic transmissions. I do like getting all the ends to a project, but for now I am just focusing on the automatics.

Papaof2, yes I have read that it has been tried in the US and yes I do remember the bypass switch they implemented. Maybe I should perhaps do a keypad instead? The keypad seems a bit overkill, I should do more research on this part. Perhaps I did not state it in the previous posts but I was also trying to not exactly emulate the patent I saw, but to improve upon it. So I decided instead of just simply not letting the car start but to have the options to start the car without a seatbelt. The restraint in my idea was to control the shift solenoid so the driver could not shift out of park. No harm done if they are parked somewhere and cannot shift into to drive. Also I did think about the data logging for the event time and place but I was going to think about that after I get the park sensing input out the way and decided with. Also when I do get to that part, I was considering on how to display such data. Maybe make another type of product with another picaxe to retrieve this EEPROM data so the parents could see. Maybe when the event happens, a LED can emit to signal such an event happened so they know when to check for the event. Maybe have a text message sent to the parents phone to know it happened so it can be a little more real time. Dont know yet but definitely something worth considering.

The whole put the seatbelt behind the driver's back I thought I could not solve and perhaps I did not put too much emphasis on it. I thought maybe no one is that bent out of shape to not where a seatbelt but I suppose in retrospect, it might be worthwhile trying to figure it out. I like the whole measure the diamter of the seatbelt to se if it is fastened properly! Never thought of that yet.

The seatbelts are being sensed with ID-12 rfid modules. I chose rfid because they are harder to bypass. In the patent, the inventor used "actuators" which are really just magnets. No changing of the seatbelt is necessary since I can get pill size rfid tags like the ones used in the "chipped" keys.
 

papaof2

Senior Member
Do look for better RFID electronics than Ford uses in their Passive AntiTheft System (PATS). There are many reports of vehicles not recognizing keys - including a key that worked as little as 15 minutes previously. Sometimes the problem is intermittent (as in a friend's 2003 F-150), but other people have total failure - which requires a tow to the dealer and replacement of one or more modules (at $$$ each). The problem is not with the chip in the key but with the sensor electronics in the steering column & dash module.

John
 

nbw

Senior Member
A mercury or similar micro tilt-switch on the underside of the accelerator, securely fastened of course?
 
Top