How to read Speedo at low speed


Closed Thread
Results 1 to 18 of 18
  1. #1
    Join Date
    Dec 2007
    Posts
    60

    Default How to read Speedo at low speed

    I have built a controller of sorts for my car that does many things. The latest being control the automatic gearbox.

    The problem I'm having is reading the speedo sensor. The sensor gives one pulse per tailshaft revolution, and with 33" tyres and a 4.3:1 ratio diff, that gives me roughly 61cm of travel per tailshaft revolution. (I think haha)

    According to my calculations, sampling every 100ms will not give me either 0 or 1 pulse under 21kph.
    I need to measure slower speeds than this.

    What is the best way to measure this? I currently use pulsein to read the tacho input also, but this obviously takes less time and higher RPM, so I'm looking at changing that also.

    The problem I have is the pic has to act quickly, the engine revs very quickly, and if it spends 1 second counting pulses, it will probably be over-revving by then.

    I assume the best way to handle this is with interrupts, but have not used them yet, so would love to be pointed in the right direction. Any help would be appreciated.



    The unit is based on a 16F877a running at 4mhz (I can run it faster if I have to) It also controls the air-conditioning & thermo fans in a climate control kind of way, aswell as having a 20x4 display that gives me info on engine stats and temperatures.

    Thanks in advance.

    Dave

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


    Did you find this post helpful? Yes | No

    Wink

    Hi,

    The only way is to have " real " pulses ( otherwise ... a PLL Osc would do it !!! )

    So, as a sensor ... you should try the Anti-lock brake sensors ( ABS wheel sensors ) that show teeth , like a gear pinion, but are designed to fit car's wheels ...

    available from junked cars for little cost ...

    And it allows you to add the anti-skid function .... Waaaaahhhh !!!

    Alain
    Last edited by Acetronics2; - 29th September 2009 at 14:09.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Dec 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    Is it not possible to use the factory sensor? As it's already in the gearbox, and it is what the factory auto computer uses.

    I have this setup on my desk at the moment all connected, and by running a piece of metal past the sensor I can read the pulses with the pic. Looking at the pulses on the oscilloscope gives me the indication that it would be ok to use.

    The other issue about using optical sensors is that this is on a 4x4 which will see a lot of mud and water and the like.

  4. #4
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default

    You can use tmr0 to count impulses from gear box, and some kind interupt to read impulese and reset timer. And you should use longer sampling time. So if you use interupt on evry 500ms, minimal speed is about 5KM/h.
    you can use tmr2 with cristal to create interupt or some kind of pauses in progrm or something like that.

  5. #5
    Join Date
    Aug 2009
    Location
    Paso Robles California
    Posts
    153


    Did you find this post helpful? Yes | No

    Default Spedp

    Is it not possible to use the factory sensor? As it's already in the gearbox, and it is what the factory auto computer uses.

    Let me ask why not, two units can read the same factory sensor!!

    You said you had a sensor ( never said what kind of sensor ) you need more pulses how can you use this sensor and get more pulses? what metal are you sensing on the shaft ( hall effect sensor and have magnets ) or is it a gear tooth sensor or what. You could use a hall effect sensor and mount maginets on the shaft you could use 1 or 30 magnets and get the pulses you need.
    if its a gear tooth sensor pull the plug on your rear end and see if you could mount a sensor to sense the teeth on the ring gear, gear tooth sensors are about 35 bucks.

    now back to the factory setup Many of the PCM's have an output that can be used by a PIC, 2000 or 4000 Pulses Per Mile would this be enough.

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    At low speeds, the time between pulses becomes more important than the Number of pulses per second.

    That value is easiest to measure with the CCP module in "Capture" mode, using Timer1.

    This way, the minimum refresh time for the speed value is only limited to the time between pulses, instead of a number of pulses across a fixed time base.

    The low end can be extended by counting an Upper WORD for Timer1, giving a result with a resolution proportional to the circumference of the tires.

    Not easy stuff, but PULSIN or COUNT won't do it.
    <br>
    DT

  7. #7
    Join Date
    Aug 2009
    Location
    Paso Robles California
    Posts
    153


    Did you find this post helpful? Yes | No

    Default speedo

    Darrel
    Most of this is true

    At low speeds, the time between pulses becomes more important than the Number of pulses per second.
    True if your measuring per second maybe not if your measuring a pulse between two teeth and there are a 100 or more per revolution.

    That value is easiest to measure with the CCP module in "Capture" mode, using Timer1.
    This is a great way to do this, and just what the module is made for! I have used these modules in this way for other projects (laser speed trap which included vehicle counting and direction of travel).

    This way, the minimum refresh time for the speed value is only limited to the time between pulses, instead of a number of pulses across a fixed time base.
    This is true for the count command not sure pulsin would affect it as much since it is measuring time between pulses again measuring time between two teeth of hundreds per Rev.

    The low end can be extended by counting an Upper WORD for Timer1, giving a result with a resolution proportional to the circumference of the tires.

    Not easy stuff, but PULSIN or COUNT won't do it.

    I have done a number of Speedos including a calibration setup for different size tires / gear ratio changes, But it was only doing speedo and odom / trip odom and had far less time constraints on it. It could still be done using the current OEM sensor in the transmission / transfercase these are mostly freq out sinewave units which are easly adaptable. This could be done with counter module and timer, or just maybe using pulsin depending on the amount of overhead for the other stuff.

  8. #8
    Join Date
    Aug 2009
    Location
    Paso Robles California
    Posts
    153


    Did you find this post helpful? Yes | No

    Default speedo

    Darrel Yes I am viewing drunk so this may be wrong

    120 mph = .000125uS per pulse
    60 mph = .000250uS per pulse
    10 mph = .001500uS per pulse
    6 mph = .002500uS per pulse

    (needs to be rechecked) this is with 4000 pulses per mile
    now if you use 20 MHz you have .000002uS resolution.

  9. #9
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by l_gaminde View Post
    Darrel Yes I am viewing drunk so this may be wrong
    At least we're on the same page ... but my numbers look a little different.

    If the distance traveled between pulses is 61cm, and there are 100000 cm per kilometer.
    Then there will be 1639 pulses per kilometer (100000 / 61).
    At 120 mph (193 kph) you will recieve ~316327 pulses per hour (1639 * 193)
    That's ~5272 per minute. (316327 / 60)
    Or ~87 per second. (5272 / 60)

    Which leaves each pulse period at 0.011494 Seconds per pulse.

    Hmmm lets see ... compare that against .... 125 pico seconds at 120mph. uuuhhhh, must be Pabst Blue Ribbon.

    120 mph = .000125uS per pulse
    60 mph = .000250uS per pulse
    10 mph = .001500uS per pulse
    6 mph = .002500uS per pulse
    DT

  10. #10
    Join Date
    Aug 2009
    Location
    Paso Robles California
    Posts
    153


    Did you find this post helpful? Yes | No

    Default speedo

    Darrel
    look if your drinking Pabst Blue Ribbon, then you need to redo you calcs in MPH !

  11. #11
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    I thought you were drinking the PBR.

    Cause there's no way you'll get pulse periods of 125 pico seconds (.000125uS). And you wouldn't be able to read them if you did.

    With 4000 pulses per Mile ...

    At 120 MPH, you'll get 480000 pulses per hour (4000 * 120)
    8000 per minute. (480000 / 60)
    133.3 per second (8000 / 60)
    which is a pulse period of .0075 Seconds (1 / 133.3)

    That's 7.5 mS per pulse.<hr>
    However, let's go back and take a look at davewanna's question.

    It's giving 1639 pulses per kilometer.
    Moving at 5 KPH, you'll get 2.28 pulses per second (1639*5/60/60)
    That's a pulse period of 0.439 seconds.

    Now with Pulsin at 20mhz, the resolution is 0.000002 (2 uS).
    The maximum count for Pulsin is 65535 for a total time of 0.131 seconds.

    The Pulsin will have timed out long before it could measure the pulse.

    If we take the longest pulse that Pulsin can read 0.131 sec.
    It would be 7.6 pulses per second (1 / 0.131)
    457 pulses per minute (7.6 * 60)
    27466 pulses per hour (457 * 60)

    Divide that by the pulses/km (27466 / 1639 = 16.75 kph).
    Anything slower than that, and you cannot read it with Pulsin @ 20Mhz.

    Whew,
    I think that deserves a Corona. <hr>

    ADDED:

    But, since davewanna is running at 4 Mhz, the Pulsin resolution is .000010 (10 uS)
    A "full count" for Pulsin would be 0.65535 sec. (65535 * .000010)
    Or 1.5 pulses per second (1 / 0.65535)
    91.5 per minute
    5493 per hour
    For a slowest speed reading of 3.35 KPH.

    At this point, I have to think that the "61cm of travel per tailshaft revolution" may not be correct if you can't read anything below 21kph.
    <br>
    Last edited by Darrel Taylor; - 2nd October 2009 at 00:03. Reason: .
    DT

  12. #12
    Join Date
    Aug 2009
    Location
    Paso Robles California
    Posts
    153


    Did you find this post helpful? Yes | No

    Default speedo

    And now youve got it, thats why he needs more pulses thats why the car companies did it, and he needs more than one per DS rev. It just isn't going to give the resolution you want, how often will he be able to update the speedo with a counter timer setup he will still need to count for over one second to get 2.28 pulses and at two second you have 4.56 so the speeso will jump from 5 kph to 10 kph with nothing in between.

  13. #13
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    I disagree (again).

    It's not counting the pulses.
    It's counting the time between pulses.

    If the pulse period is 0.46 seconds, then that's how often you can update the display. Each pulse period gives you all the information you need when there's only 1 pulse per rev. With more than one, there would be differences between the pulse widths depending on placement of the sensors/magnets/optical whichever is used, and then you would have to average a number of samples to get the correct result. But with 1 pulse per rev, that does not apply, and a single pulse is all you need.

    It would not jump from 5 to 10 kph, and in fact would give a nice linear response with at least 1 decimal.

    If the CCP module were being used, and Timer1 extended to 24 bits, the lowest reading you could get would drop to well under 1 KPH. Of course, at 1 kph, the pulse period is 2.2 seconds, and that's how often you can update the display. But at 1kph, you don't need a faster refresh.

    There's absolutely no reason why davewanna can't use the sensor that he has, and get excellent readings from 1 to 200 kph.
    The car's computer already does it. Why wouldn't the PIC be able to do it too?

    He just needs to find out the real distance per pulse.
    Which can be done easily by driving the car 1km and have the PIC count how many pulses it received. From there, it's just math.
    <br>
    DT

  14. #14
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


    Did you find this post helpful? Yes | No

    Default

    The problem I have is the pic has to act quickly, the engine revs very quickly, and if it spends 1 second counting pulses, it will probably be over-revving by then.
    Of course, at 1 kph, the pulse period is 2.2 seconds, and that's how often you can update the display. But at 1kph, you don't need a faster refresh.
    Hi, folks ...

    Problem is Here, not a display problem ...

    You need quasi " real-time updated speed " ( Cf Post # 2 ) ...

    Alain

    PS, Don't tell " Davewanna" , BUT

    "Dave would have liked to" ... Humour !
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  15. #15
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Problem is Here, not a display problem ...

    You need quasi " real-time updated speed " ( Cf Post # 2 ) ...
    I've tried ... but I don't understand what you mean Alain.

    He's reading the Speedo.

    If the engine revs fast, then so will the speed sensor.
    And you'll no longer be going 1kph.

    BTW, where'd he go.
    <br>
    DT

  16. #16
    Join Date
    Dec 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default sorry

    Sorry all! Something unexpected has come up over the last 2 days. I didn't realise I had this many replies! I haven't even had a chance to read over everyone's suggestions yet... I will go through it all and post again.

    Very thankful for all the assistance!

    Cheers
    Dave

  17. #17
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


    Did you find this post helpful? Yes | No

    Wink The problem terms problem ....

    Quote Originally Posted by Darrel Taylor View Post
    I've tried ... but I don't understand what you mean Alain.

    <br>
    Hi, Darrel

    At school, I just learnt to carefully read the Problem terms :

    sampling every 100ms
    The unit is based on a 16F877a running at 4mhz (I can run it faster if I have to) It also controls the air-conditioning & thermo fans in a climate control kind of way, aswell as having a 20x4 display that gives me info on engine stats and temperatures.
    I do know forumers are not so clear in what they look for ... but I do whith what I have under the eyes ...

    Regards

    Alain
    Last edited by Acetronics2; - 4th October 2009 at 12:29.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  18. #18
    Join Date
    Dec 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default

    Darrel,

    From your advice I guess my quickest easiest way of making this work is with pulsein (seeings I have very little interrupt knowledge yet)

    My reference to 21kph was if I use COUNT to count pulses over a 100ms period.

    I will try this in the next few days, with a pulsein timeout period of about 200ms (to prevent all the other functions from slowing down too much.)

    I still haven't had enough time to go over what everyone has posted. But rest-assured it is appreciated.


    Thanks!

Similar Threads

  1. Cleaning up code
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd December 2009, 08:14
  2. SEROUT WORD variable problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th April 2009, 12:20
  3. Old and beyond help ?
    By DavidFMarks in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 11th December 2008, 16:23
  4. Replies: 14
    Last Post: - 26th September 2007, 06:41
  5. 4-line LCD Help - using PortA instead of B
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 28
    Last Post: - 31st March 2005, 04:14

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts