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.
fxvxca said:
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?

If you want only gear indication you can take signal from the GPS (Gear Position Switch) and use a 7 segment display or may be one led for each gear, which is in my opnion the easiest way. You can use a pic 16F876 as well as the code that Gramo has posted earlier with little modifications.

But if you prefer to use speed and rpm signals you need to wait some guy to post the little math to do that, but I'm not sure if this way is a reliable way to show the gear you are in. So if you have an OEM gear switch (I think all Suzuki have it) why not use it.
 
Last edited:
fxvxca said:
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?

Attached there are two simple circuits that can be used to show the gear position using signal from GPS (gear position switch).
 

Attachments

  • schem1.JPG
    schem1.JPG
    38.2 KB · Views: 401
  • schem2.JPG
    schem2.JPG
    37.1 KB · Views: 416
For all of the circuits presented here, it would make sense to replace the 16F876 with a 16F88. This is a much smaller chip (18 pin) but has all the required peripherals plus it has an internal 8MHz clock.

It probably won't be able to handle the graphical display. BTW, if you find a good site explaining interfacing and programming the graphical displays, can you post it here. Thanks.

Mike.
 
Thanks Nigel,

The EPE article available on your friends site is excellent.

Mike.
 
Pommie said:
For all of the circuits presented here, it would make sense to replace the 16F876 with a 16F88. This is a much smaller chip (18 pin) but has all the required peripherals plus it has an internal 8MHz clock.

It probably won't be able to handle the graphical display. BTW, if you find a good site explaining interfacing and programming the graphical displays, can you post it here. Thanks.

Mike.

Thank you Mike
 
I'll get the Gear thing going once I get the speed and rev counter working.
I've got the maths and the programming covered. Its the electronics I'm no good at. And wiring a 5v pic to a 12v bike scares the hell out of me. So I'm really interested in the schematics that connect directly into the bikes loom. to give me a good clean speed and rev pulse. Was there not talk of a Zenner diode in here somewhere?
 
If anyone is intersted here is the maths required to derive the Gear:

First you need a number of facts about your motorbike:

1) PriRatio = Primary reduction ratio
2) SecRatio = Secondary reduction ratio (rear sprocket / front)
3) GearRatio = A lookup of all your internal gear ratios

all these can be found in your manual.

4) TyreCirc = Rolling tyre diameter (measure a piece of string once around the trye)

.....................................................1
GearRatio = --------------------------------------------------------- X Revs(r/min)
.................Speed(kph) X 1000 / 60 / TyreCirc(m) X SecRatio X PriRatio

Then just lookup your gear ratio +/- 0.1 or so. Neutral is any ratio outside the upper or lower bounds of your lookup
 
quickrik said:
I'll get the Gear thing going once I get the speed and rev counter working.
I've got the maths and the programming covered. Its the electronics I'm no good at. And wiring a 5v pic to a 12v bike scares the hell out of me. So I'm really interested in the schematics that connect directly into the bikes loom. to give me a good clean speed and rev pulse. Was there not talk of a Zenner diode in here somewhere?

Like I post before I'm now using it in my bike with no problem. The circuit is working nice and smoth. I'm using a 7805 voltage regulator and changed the LCD from 8X2 to 20X2 that have enough room for Speed (Km/h and MPH), RPM and gear indication and I'm thinking about to add a temp sensor to display the OAT.
 
Last edited:
Nice work Kiko, I'm glad to see a whole project pan out so well, if you decide to throw in a temp sensor, maybe this will help

The datasheet shows many ways to use the LM35DZ, but I'm using the example on page 7 in the datasheet, with the -55 to +150 degree C application. It requires 3 additional components, 2 * 1N914 (Or 1N4148), and 1 * 18K resistor.


**broken link removed**

Code:
Device 16F877A
Declare XTAL 4

DECLARE ADIN_RES 10               ' 10-bit result required
DECLARE ADIN_TAD 8_FOSC      ' Set the ADC's clock source
DECLARE ADIN_STIME 50            ' Allow 50us sample time

Declare LCD_TYPE 0                   ' Type of LCD Used is Alpha
Declare LCD_DTPIN PORTB.4     ' The control bits B4,B5,B6,B7
Declare LCD_RSPIN PORTB.2     ' RS pin on B2
Declare LCD_ENPIN PORTB.3     ' E pin on B3
Declare LCD_INTERFACE 4         ' Interface method is 4 bit

Dim ADC_Result As Float
Dim ADC_Total As Float
Dim Temp_Float as Float
Dim ADC_Channel as Byte
Dim ADC_Loops as Word
Dim Temp as Word


Dim Last_Result1 As Float
Dim Last_Result2 As Float

ADCON1 = %10000000                     ' Set all to analogue inputs (PORTA)
TRISA = $FF                                    ' Declare porta as all inputs

Delayms 150
Cls

Print $FE,$40,$07,$05,$07,$00,$00,$00,$00,$00 ' Custom character for Degree

ADC_Loops = 200

Main:

ADC_Channel = 1                     ' ADC on first reference
Gosub ADC_Average                ' Perform an averaging to enhance accuracy

Temp_Float = ADC_Result        ' Store the result

ADC_Channel = 0                     ' ADC on second reference
Gosub ADC_Average                ' Perform an averaging to enhance accuracy

ADC_Result = ADC_Result * 5000 / 1023           ' Convert values into Volts (with a scale of 1000)
Temp_Float = Temp_Float * 5000 / 1023            ' to reduce decimal error
ADC_Result = ADC_Result - Temp_Float           ' And calculate difference

ADC_Result = ADC_Result / 10                        ' Scale back down remembering 10mV = 1 Deg C

If ADC_Result <> Last_Result1 Then               ' Check if the data has changed
Print At 1,1, Dec1 ADC_Result, 0, "C "             ' and only update display if it has
Last_Result1 = ADC_Result                              ' Store new data
Endif

Goto Main                                                       ' Loop for ever


ADC_Average:                                                  ' Perform an averaging on ADC conversions
                                                                       '  to reduce errors
ADC_Total = 0                                                  ' Clear summing register
For Temp = 1 To ADC_Loops                            ' Loop for a pre-determined number of times
ADC_Result = ADIN ADC_Channel                    ' Grab a new ADC value
ADC_Total = ADC_Total + ADC_Result              ' Sum it to the total register
Delayus 1                                                        ' Allow internal capacitors to discharge
Next Temp

ADC_Result = ADC_Total / ADC_Loops              ' Determin the average of all the equations

Return

The comments went all over the place, but you should be able to ge tthe jist of it
 
gramo said:
Nice work Kiko, I'm glad to see a whole project pan out so well, if you decide to throw in a temp sensor, maybe this will help

The datasheet shows many ways to use the LM35DZ, but I'm using the example on page 7 in the datasheet, with the -55 to +150 degree C application. It requires 3 additional components, 2 * 1N914 (Or 1N4148), and 1 * 18K resistor.


**broken link removed**

Code:
Device 16F877A
Declare XTAL 4

DECLARE ADIN_RES 10               ' 10-bit result required
DECLARE ADIN_TAD 8_FOSC      ' Set the ADC's clock source
DECLARE ADIN_STIME 50            ' Allow 50us sample time

Declare LCD_TYPE 0                   ' Type of LCD Used is Alpha
Declare LCD_DTPIN PORTB.4     ' The control bits B4,B5,B6,B7
Declare LCD_RSPIN PORTB.2     ' RS pin on B2
Declare LCD_ENPIN PORTB.3     ' E pin on B3
Declare LCD_INTERFACE 4         ' Interface method is 4 bit

Dim ADC_Result As Float
Dim ADC_Total As Float
Dim Temp_Float as Float
Dim ADC_Channel as Byte
Dim ADC_Loops as Word
Dim Temp as Word


Dim Last_Result1 As Float
Dim Last_Result2 As Float

ADCON1 = %10000000                     ' Set all to analogue inputs (PORTA)
TRISA = $FF                                    ' Declare porta as all inputs

Delayms 150
Cls

Print $FE,$40,$07,$05,$07,$00,$00,$00,$00,$00 ' Custom character for Degree

ADC_Loops = 200

Main:

ADC_Channel = 1                     ' ADC on first reference
Gosub ADC_Average                ' Perform an averaging to enhance accuracy

Temp_Float = ADC_Result        ' Store the result

ADC_Channel = 0                     ' ADC on second reference
Gosub ADC_Average                ' Perform an averaging to enhance accuracy

ADC_Result = ADC_Result * 5000 / 1023           ' Convert values into Volts (with a scale of 1000)
Temp_Float = Temp_Float * 5000 / 1023            ' to reduce decimal error
ADC_Result = ADC_Result - Temp_Float           ' And calculate difference

ADC_Result = ADC_Result / 10                        ' Scale back down remembering 10mV = 1 Deg C

If ADC_Result <> Last_Result1 Then               ' Check if the data has changed
Print At 1,1, Dec1 ADC_Result, 0, "C "             ' and only update display if it has
Last_Result1 = ADC_Result                              ' Store new data
Endif

Goto Main                                                       ' Loop for ever


ADC_Average:                                                  ' Perform an averaging on ADC conversions
                                                                       '  to reduce errors
ADC_Total = 0                                                  ' Clear summing register
For Temp = 1 To ADC_Loops                            ' Loop for a pre-determined number of times
ADC_Result = ADIN ADC_Channel                    ' Grab a new ADC value
ADC_Total = ADC_Total + ADC_Result              ' Sum it to the total register
Delayus 1                                                        ' Allow internal capacitors to discharge
Next Temp

ADC_Result = ADC_Total / ADC_Loops              ' Determin the average of all the equations

Return

The comments went all over the place, but you should be able to ge tthe jist of it

All right Sir thanks a lot for your help, That's the help I want to see in the forum. I really apreciate it.

But I have in hands a Dallas 18B20 temp sensor and I think I'm going to use it, with the code below (just for example).

DIM Temp AS WORD 'Holds the temperature value
DIM C AS BYTE 'Holds the counts remaining value
DIM CPerD AS BYTE 'Holds the Counts per degree C value
Deg CON 223 'Shows the symbol Deg °

OWRITE DQ, 1, [$CC, $44] ' Send Calculate Temperature command
REPEAT
DELAYMS 25 'Wait until conversion is complete
OREAD DQ, 4, [C] 'Keep reading low pulses until
UNTIL C<>0 'the DS1820 is finished.
OWRITE DQ, 1, [$CC, $BE] 'Send Read ScratchPad command
OREAD DQ, 2,[Temp.LOWBYTE, Temp.HIGHBYTE, C, C, C, C, C, CPerD]
'Calculate the temperature in degrees Centigrade
Temp=(((Temp>>1)*100)-25)+(((CPerD-C)*100)/CPerD)

PRINT AT 2, 11, "OAT=", DEC Temp/1000, ".", DEC1 Temp, deg, "C "

Thank you again and I will post as soon as I can this project using a Graphic LCD.
 
I was going to say that one, but being a speed sensitive program, performing many things at once, I thought it may take to long between samples

The LM35 has an analogue output, and it takes as long as the sample time to grab the temperature, the DS18B20 takes up to 750mS to perform a conversion, and more time is required within the 1-wire commands as well
 
fxvxca said:
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?

Here is the code you asked for a 7 segment display schematic I posted earlier. Note that this is a modified program posted by Gramo.

Device 16F876A
Declare XTAL 20
ALL_DIGITAL=TRUE
DECLARE ADIN_RES 10
DECLARE ADIN_TAD FRC
DECLARE ADIN_STIME 50
PORTB_PULLUPS True
Dim Result As Word
Dim Total As Float
Dim X As Byte
SYMBOL seg1=PORTC.0
SYMBOL seg2=PORTC.1
SYMBOL seg3=PORTC.2
SYMBOL seg4=PORTC.3
SYMBOL seg5=PORTC.4
SYMBOL seg6=PORTC.5
SYMBOL seg7=PORTC.6
Delayms 500
TRISA=%0000001
ADCON1=%10000000
high PORTC 'Display segment test
Delayms 1000
low PORTC
Start:
Result=0
Total=0
X=0
Repeat
DelaymS 1
Result=ADIN 0
Result=Result*2
Total=Total+Result
Inc X
Until X=100
Total=Total/100
Total=Total*5/1023
Delayms 100
Select Total
Case 1.000 to 2.025 '1st gear
low seg1
high seg2
high seg3
low seg4
low seg5
low seg6
low seg7
Case 2.026 to 2.700 '2nd gear
high seg1
high seg2
low seg3
high seg4
high seg5
low seg6
high seg7
Case 2.701 to 3.329 '3rd gear
high seg1
high seg2
high seg3
high seg4
low seg5
low seg6
high seg7
Case 3.330 to 3.700 '4th gear
low seg1
high seg2
high seg3
low seg4
low seg5
high seg6
high seg7
Case 3.699 to 4.190 '5th gear
high seg1
low seg2
high seg3
high seg4
low seg5
high seg6
high seg7
Case 4.191 to 4.470 '6th gear
high seg1
low seg2
high seg3
high seg4
high seg5
high seg6
high seg7
Case 4.471 to 5.500 'Normal
high seg1
high seg2
high seg3
high seg4
high seg5
high seg6
low seg7
Case Else 'ERROR (NO VOLTAGE)
high seg1
low seg2
low seg3
high seg4
high seg5
high seg6
high seg7
EndSelect
GoTo Start


I don't know why it was not indented...
 
Last edited:
i saw that n the code you already put voltage in the program.. in this case i don't have to chet it again?
 
fxvxca said:
i saw that n the code you already put voltage in the program.. in this case i don't have to chet it again?

Sorry, let me see if I understood. The voltages I put in the program are for my bike and I don't know if the voltages of your bike are the same, so I think it's better you measure the voltages from the GPS before you program your PIC, just to make sure or tell me what is the model of your bike and I can make a research.
 
sorry but i was typing on a broken keyboard :p

yes it's correct i have a gsx-r 600 k4 (2004) in case what should i have to use for the measurement?
 
fxvxca said:
sorry but i was typing on a broken keyboard :p

yes it's correct i have a gsx-r 600 k4 (2004) in case what should i have to use for the measurement?

You will need a voltmeter and them you have to tap the signal from the GPS then run your bike on a jack and measure the voltage for each gear.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top