Continue to Site

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.

  • 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.

Speedometer

Status
Not open for further replies.
Code:
	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:
	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 :)
 
gramo said:
Code:
	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:
	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 :)

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.
 

Attachments

  • speed sensor.JPG
    speed sensor.JPG
    19.8 KB · Views: 363
  • speed sensor test.JPG
    speed sensor test.JPG
    23.2 KB · Views: 473
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.
 
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
 

Attachments

  • input.JPG
    input.JPG
    20.6 KB · Views: 375
gramo said:
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.

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
 
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.
 
Pommie said:
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.

But do I have to lower the voltage peak to 5V?
 
Pommie said:
The 10K resistor should take care of that.

Mike.

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
 
gramo said:
Geez, my bad, I was thinking that the speed was ADC based, sorry

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
 
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
 
quickrik said:
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

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
 
quickrik said:
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
If you add an RPM pickup you could do the Gear Position Indication using a little math.

D.
 
danci1973 said:
If you add an RPM pickup you could do the Gear Position Indication using a little math.
D.

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.
 
Pommie said:
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.

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.
 
mramos1 said:
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.

Could you please post the maths? This way the QUICKRIK can start his project.
 
Last edited:
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
 

Attachments

  • bikespeedgear.JPG
    bikespeedgear.JPG
    41.6 KB · Views: 485
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?
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top