1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

Speedometer

Discussion in 'Microcontrollers' started by Kiko, Mar 8, 2007.

  1. gramo

    gramo New Member

    Joined:
    Oct 2, 2006
    Messages:
    1,221
    Likes:
    23
    Location:
    Newcastle, Australia
    Code (text):
        Result = 0
        Total = 0
        X = 0
       
        Repeat

              DelaymS 1
       
              Result = ADIN 0
              Result = Result * 2
              Total = Total + Result
             
              Inc X
       
        [B]Until X = 100[/B]
       
        Total = Total / 15
       
        Total = Total * 5 / 1023
    Change the number of samples too 100 like I did above, you could even go higher, but it will slow down your program. This should help smooth the Speedo

    Leave 7.2 in this part, dont round it

    Code (text):

        Temp_Float = KMHT
        Temp_Float = Temp_Float * 4 * 7.2
            KMH =  Temp_Float / 1000
        KMHT = KMH
    The issue with the miss reading could be the impedance is too high for the ADC circuitry in the PIC. The datasheet specifies 2.5K Max impedance. This is to allow the internal capacitors on the PIC to charge and discharge properly, try use 2.2K resistors on the voltage divider.

    Let me know if that helps :)
     
  2. Kiko

    Kiko New Member

    Joined:
    Apr 24, 2004
    Messages:
    79
    Likes:
    1
    Location:
    Brazil
    OK so let me try to explain what the problem is now:

    I'm not having anymore problems with the gear indicator so when I changed the ground the problem has been fixed. The gear indicator is working perfect.

    When I power the circuit installed in the bike the speed indicator is zero as the bike is stoped (no speed).

    When I start the engine the speed indicator shows 10km/hr but it's not smooth and with the increase of the speed it shows incorrect readings like I posted before.

    The speed sensor this bike uses is attached as reference, please see if I took the signal from the correct wire.
     

    Attached Files:

  3. gramo

    gramo New Member

    Joined:
    Oct 2, 2006
    Messages:
    1,221
    Likes:
    23
    Location:
    Newcastle, Australia
    Did you change the voltage divider to use 2.5K resistors?

    Perhaps it’s meant to be the voltage difference between the two wires, or just the one on the right, I have no idea as I don’t have your manual.
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,161
    Likes:
    340
    Location:
    Brisbane Australia

    Am I right in thinking that the ADC part is working correctly and the problem is with the pulsed speed input?

    Assuming I'm correct on the above assumption, it sounds like you are getting noise interference. Try connecting a 1K resistor from the sensor to the pic and a 0.1uF capacitor from pic to ground. If you still get noise then increase the capacitor , if you get no reading then reduce it. If it only works at certain speeds then post back.

    Mike.
     
  6. Kiko

    Kiko New Member

    Joined:
    Apr 24, 2004
    Messages:
    79
    Likes:
    1
    Location:
    Brazil
    Yes Mike you're right... I'll try to do the following (attached) see if you agree.

    What's the max signal amplitude that the PIC can deal with? Because the signal from speed sensor is 0 to about 300 hz 12 Volts pulsed and I think the circuit attached is going to lower the pulsed voltage to 5 V.


    Thanks
     

    Attached Files:

  7. Kiko

    Kiko New Member

    Joined:
    Apr 24, 2004
    Messages:
    79
    Likes:
    1
    Location:
    Brazil
    I didn't change because the voltage divider for gear indicator is working perfect with 10K resistor.

    My problem now is the signal from the speed sensor to digital speed indicator.

    I post previously an attached circuit that I'm going to use to try to lower the voltage signal to 5 V because I think that's is the problem.

    Thanks
     
  8. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,161
    Likes:
    340
    Location:
    Brisbane Australia
    You don't need the 2 diodes as the pic has identical diodes built into it's input pins. Just try a simple RC filter first and see how that works out. I think 100k (+10K) is probably too high to start with. As your only going to 300Hz then 10k and 0.1uf is probably a good starting point.

    Mike.
     
  9. Kiko

    Kiko New Member

    Joined:
    Apr 24, 2004
    Messages:
    79
    Likes:
    1
    Location:
    Brazil
    But do I have to lower the voltage peak to 5V?
     
  10. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,161
    Likes:
    340
    Location:
    Brisbane Australia
    The 10K resistor should take care of that.

    Mike.
     
  11. Kiko

    Kiko New Member

    Joined:
    Apr 24, 2004
    Messages:
    79
    Likes:
    1
    Location:
    Brazil
    Ok I have finished to do that and with the bike on the jack the speedo is working great, no problem anymore, and tomorrow I'll test on the road...

    Thank you

    ps. I have not finished. I have lot of questions coming to finished this project.

    Thank you very much
     
  12. gramo

    gramo New Member

    Joined:
    Oct 2, 2006
    Messages:
    1,221
    Likes:
    23
    Location:
    Newcastle, Australia
    Geez, my bad, I was thinking that the speed was ADC based, sorry
     
  13. Kiko

    Kiko New Member

    Joined:
    Apr 24, 2004
    Messages:
    79
    Likes:
    1
    Location:
    Brazil
    No problem at all as your help was very valuable to me.

    So I made a road test today and the gear indicator is working perfect and the speed indicator is working nice and smooth but at high speed I have some indication discrepancy that is proportional to speed but I think I can fix it changing the values of RC filter (Am I correct?).

    I think now we have here, with help from you guys, a very good starting point for people who want to make a project like that.

    All I can say is thank you very much.

    By the way, do you have or know any guide that I can use to change the alpha LCD to graphic LCD using proton+ basic?

    Rgds
     
  14. quickrik

    quickrik New Member

    Joined:
    Oct 18, 2006
    Messages:
    27
    Likes:
    0
    Hi there,

    This is fascinating, I'm trying to do the same thing with a 16F876A and my Yamaha (it doesn't have a Gear Position Indicator so just speed).

    Kiko could you post your completed schematic because I'm at the stage now where it works on the bench but I fear I may encounter the same problem you had.

    Cheers Rik
     
  15. Kiko

    Kiko New Member

    Joined:
    Apr 24, 2004
    Messages:
    79
    Likes:
    1
    Location:
    Brazil
    Sure don't worry. I will post as soon as I fix my computer because I had a little problem with it and I'm reinstalling everything in it. But the speed and gear indicator is working perfect.

    Since my main goal is to make one with graphic LCD display, I'd like to hear from you guys the display conections as well as the main code (Proton+ Basic) and if it's necessary to use an external eeprom.

    I'm using KS0108 display driver...

    Tks
     
  16. danci1973

    danci1973 New Member

    Joined:
    Nov 3, 2006
    Messages:
    7
    Likes:
    1
    If you add an RPM pickup you could do the Gear Position Indication using a little math.

    D.
     
  17. Pommie

    Pommie Well-Known Member Most Helpful Member

    Joined:
    Mar 18, 2005
    Messages:
    10,161
    Likes:
    340
    Location:
    Brisbane Australia
    Only if the clutch is out :D . I do like that idea though. You could display speed, RPM and gear with just the 2 signals.
     
  18. mramos1

    mramos1 Active Member

    Joined:
    Sep 15, 2005
    Messages:
    2,403
    Likes:
    9
    Location:
    Boynton Beach, Florida USA
    I think it can be done. Just the update might have a little delay while debouncing/calculating the shifts and RPMs.

    Now what to do if you are idle at a stop light. I used to stop and then down-shift into first at times. So you would not get a gear update until moving again.
     
  19. Kiko

    Kiko New Member

    Joined:
    Apr 24, 2004
    Messages:
    79
    Likes:
    1
    Location:
    Brazil
    Could you please post the maths? This way the QUICKRIK can start his project.
     
    Last edited: Mar 24, 2007
  20. Kiko

    Kiko New Member

    Joined:
    Apr 24, 2004
    Messages:
    79
    Likes:
    1
    Location:
    Brazil
    Attached is the schematic that I used, with help from you, for my bike Speedometer and Gear Indicator.

    It's working perfect but as I sad before I'd like to use a graphic LCD instead.

    Thank you
     

    Attached Files:

  21. fxvxca

    fxvxca New Member

    Joined:
    Mar 24, 2007
    Messages:
    6
    Likes:
    0
    hi guys i'm triyng to find a schematic for gear indicator for my gixxer that take signal from speed and rpm signl (plus neutral light for zero) but it seems that it doesn't exist anywhere... do you have any idea?
     

Share This Page