Reading a speed sensor best method?


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Dec 2007
    Posts
    60

    Default Reading a speed sensor best method?

    I apologise in advance for the stupid questions, but I'm pretty green and haven't been able to find an example of what I want to do in the search.

    I am trying to read a speed signal coming from a gearbox on a car, this is a very siml

  2. #2
    Join Date
    Dec 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Re: Reading a speed sensor best method?

    Apparently I hit enter before I should have before, then I took too long to edit the post. So here is what it was meant to be.....

    I apologise in advance for the stupid questions, but I'm pretty green and haven't been able to find an example of what I want to do in the search.

    I am trying to read a speed signal coming from a gearbox on a car, this is a very simple reed switch in the gearbox that has a magnet on the output shaft. I have a 5V pullup on that line, and have tried a few methods for reading the pin.

    I have tried COUNT but haven't been able to get a consistant result. Not one that increases with the speed of the car anyway.

    I currently use PULSIN to read the tacho squarewave, which works well, but only as I don't have to wait very long. With the car going at slow road speeds, the speedo signal frequency is quite slow, and slows down the whole program. Not to mention, it doesn't seem to give consistant results.

    I feel I should be trying to use the CCP capture command to count pulses in the background, but I have no real experience with the CCP side of things yet, and despite reading the datasheet, and some notes about the CCP, I haven't yet got a grasp on it.

    Does anyone know of a sample of CCP being used in the type of situation I am chasing? I just need to see it working to grasp it I think.


    Thanks in advance...

    Dave

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Reading a speed sensor best method?

    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Dec 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Re: Reading a speed sensor best method?

    Cheers for that Dave, looks like it will help me out a lot. It's pouring rain here so haven't had a chance to jack the back wheels up and test the car out yet.
    But no doubt I will have more questions soon.

    Looking at my post history, I found I originally asked this question in 2009, but didn't really have the time to sort it out, so I programmed the car to change gear based on RPM, not on speed, and then pretty much forgot about it. There was helpful posts in that thread also. Surely I have enough to make some progress now, if only this rain would stop.

    Cheers

  5. #5
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Reading a speed sensor best method?

    Did you put the sensor there yourself? or is it part of the vehicle?
    There should be a logic signal at the ECU.

    But, yeah, anyway, external interrupt on the rising edge of the signal.

    ((variable pulses counted in a second X 3600) / constant pulses per km) X 3600 = Kilometers per hour!

  6. #6
    Join Date
    Dec 2007
    Posts
    60


    Did you find this post helpful? Yes | No

    Default Re: Reading a speed sensor best method?

    It's a factory sensor in the gearbox, but there is more than one. There is also two ECU's, one for the engine, one for the gearbox, that I am replacing, as the engine has been replaced with something more powerful, and now changes gear too soon.

    I haven't been able to work out interrupts yet, do I have to use the CCP1 pin? I haven't used interrupts at all, is there a "dummy's guide" anywhere? haha

    I programmed it today to read with PULSIN. I am reading the tacho, and the speedo now with PULSIN, but the reults are average. There is some 'contact bounce' with the speed sensor, that gives me erratic readings. I have programmed it to take two readings, and only use them if they are similar which is working. But with the PULSIN_MAX @ 10000, reading the RPM, and the SPEEDO, and sometimes having to re-read the speedo, the whole program runs fairly slow until the car speed, and the RPM increase. I would still like to get the capture interrupts working.

    Also, I have run out of program space. It's a project that has grown over time, and now it handles the auto gearbox, monitors engine specs, and does climate control. Also has a setup menu where sensors can be calibrated, and gearbox and air-con settings can be changed. Current pic is a 16F877A.

    From what I can tell, the 18F452 is pin compatible, and has twice the program space. Would it be viable for me to port my code over to the 18F452? I have only used 16F devices before.

    Thanks...

Members who have read this thread : 0

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