![]() | ![]() | ![]() |
| | #61 | |
| Quote:
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 by Kiko; 25th March 2007 at 06:32 PM. | ||
| |
| | #62 | |
| Quote:
| ||
| |
| | #63 |
|
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. | |
| |
| | #64 |
|
Try this friend my mine's site http://www.taximania.net/ | |
| |
| | #65 |
|
Thanks Nigel, The EPE article available on your friends site is excellent. Mike. | |
| |
| | #66 | |
| Quote:
| ||
| |
| | #67 | |
| Quote:
| ||
| |
| | #68 |
|
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? | |
| |
| | #69 |
|
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 | |
| |
| | #70 | |
| Quote:
Last edited by Kiko; 27th March 2007 at 06:35 PM. | ||
| |
| | #71 |
|
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. 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
__________________ digital-diy.com - Hobby microcontroller projects and tutorials. Assembly, PICBasic and C examples. | |
| |
| | #72 | |
| Quote:
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. | ||
| |
| | #73 |
|
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
__________________ digital-diy.com - Hobby microcontroller projects and tutorials. Assembly, PICBasic and C examples. | |
| |
| | #74 |
|
Just noticed that I have ADC_Loops = 200, this could be changed to 5 or somthing smaller so that not as many samples are taken
__________________ digital-diy.com - Hobby microcontroller projects and tutorials. Assembly, PICBasic and C examples. | |
| |
| | #75 | |
| Quote:
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 by Kiko; 29th March 2007 at 03:31 AM. | ||
| |
|
| Tags |
| speedometer |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| digital speedometer using AT90S2313 | fever | Micro Controllers | 57 | 29th January 2008 07:45 PM |
| Speedometer Project Help | ADAM117 | Electronic Projects Design/Ideas/Reviews | 2 | 8th December 2006 06:00 PM |
| Pulse divider for a Speedometer | spestis | Electronic Projects Design/Ideas/Reviews | 3 | 25th July 2006 03:17 AM |
| Tachometer and Speedometer replies | Kiko | Micro Controllers | 0 | 26th April 2004 01:57 AM |
| Electronic Speedometer using stepper motor | roryp | General Electronics Chat | 6 | 10th April 2003 01:06 PM |