Pommie said:Is the VSS going to a normal input rather than a schmitt trigger input?
Mike.
Pommie said:Is the VSS going to a normal input rather than a schmitt trigger input?
Mike.
donniedj said:Try inserting a few seconds delay at the beginning of the PIC code assuming the PIC is powered at moment of engine start.
Is the display erratic or just the actual speed values?
mramos1 said:Is the pic working OK, but the readings are wacked out?
Can you blink an LED and see if the pic is stable. That way you which direction to trouble shoot in.
Kiko said:What schmitt trigger circuit (IC) is the best for that application?
Pommie said:What I meant was that some of the input pins on the pic are schmitt triggers. RA4, RB0 (int only) and all of port C are schmitt trigger inputs. Try changing your circuit so it uses one of these inputs.
Mike.
Device 16F876A
Declare XTAL 20
Config XT_OSC , WDT_OFF , PWRTE_ON , BODEN_OFF , LVP_OFF , CPD_OFF, CP_OFF , DEBUG_OFF
ALL_DIGITAL = TRUE
Declare LCD_TYPE 0
Declare LCD_DTPIN PORTB.4
Declare LCD_ENPIN PORTB.3
Declare LCD_RSPIN PORTB.2
Declare LCD_INTERFACE 4
Declare LCD_LINES 2
Dim KMH As Float
Dim Temp_Float As Float
Dim KMHT As DWord
Dim KMH_Last As DWord
TRISC.0 = 1
DelayMS 1000
Cls
Print At 1,5, "KM/Hr"
KMHT = 0
Start:
KMHT = Counter PORTC.0, 250
If KMHT = 0 Then Goto Display
Temp_Float = KMHT
Temp_Float = (Temp_Float * 4) * 7.2
KMH = Temp_Float / 1000
KMHT = KMH
Display:
If KMH_Last <> KMHT Then
Print At 1, 1, DEC3 KMHT
KMH_Last = KMHT
EndIf
GoTo Start
gramo said:There were a couple of things that could have been improved in your program;
- many compilers cant handle cross variable type operations with floats
- you were not polling the info before it was displayed (PIC's work extremely fast, esp @ 20Mhz, and if the value has not changed, why re-write it too the display?
- There is no need to re-write "KM/Hr" over and over
- ALL_DIGITAL = True is a Compiler setting, no need to throw it in the main loop of the program
I modified it a little (you will have to change over the RS and E pins as I've swapped them over - force of habbit as that way they are all connected straight onto the PIC)
Watch the circuit in action here
Code:Device 16F876A Declare XTAL 20 Config XT_OSC , WDT_OFF , PWRTE_ON , BODEN_OFF , LVP_OFF , CPD_OFF, CP_OFF , DEBUG_OFF ALL_DIGITAL = TRUE Declare LCD_TYPE 0 Declare LCD_DTPIN PORTB.4 Declare LCD_ENPIN PORTB.3 Declare LCD_RSPIN PORTB.2 Declare LCD_INTERFACE 4 Declare LCD_LINES 2 Dim KMH As Float Dim Temp_Float As Float Dim KMHT As DWord Dim KMH_Last As DWord TRISC.0 = 1 DelayMS 1000 Cls Print At 1,5, "KM/Hr" KMHT = 0 Start: KMHT = Counter PORTC.0, 250 If KMHT = 0 Then Goto Display Temp_Float = KMHT Temp_Float = (Temp_Float * 4) * 7.2 KMH = Temp_Float / 1000 KMHT = KMH Display: If KMH_Last <> KMHT Then Print At 1, 1, DEC3 KMHT KMH_Last = KMHT EndIf GoTo Start
Notice I do all the Float functions with floats - so theres no multiplying a Word (0 - 65535) by decimal numbers (such as 7.2) as the answer will be calulated in Word format, and the deciamls will be dropped..
I've used a DWord for KMHT as some of the values can get quite high, and this allows storage of extremely large whole numbers. The Data from KMH is transferred to KMHT so that the decimals are dropped, and to allow the DEC3 modifier to always display three whole numbers i.e. 010, 060, 122 not 10.1, 60.5, 122.9 (theres no need to see the decimal place for speed)
7.2 was calulated by just doing the math before hand (0.002 * 3600)
I threw in the config lines just out of force of habbit
Hope this helps improve the program a little
Kiko said:My Suzuki bike has an OEM gear position sensor (GPS) that gives the output voltage as follow:
1st gear = 1.782v
2nd gear = 2.242v
3rd gear = 2.960v
4th gear = 3.630v
5th gear = 4.310v
6th gear = 4.660v
Neutral = 5.000v
Follows are the voltages I've taken running the bike:
1st gear = 1.243v to 2.586v
2nd gear = 2.124v to 3.210v
3rd gear = 3.178v to 3.486v
4th gear = 3.633v to 4.400v
5th gear = 4.215v to 4.887v
6th gear = 4.461v to 4.942v
Neutral = 4.678v to 5.245v
The idea then is to write a routine that whem I'm in 6th (betwen 4.461 and 4.942) the program lock only the reading (6th gear on LCD) but still monitoring the voltages and jump to another gear without interfere with each other.
I don't know if I could explain... But any help will be wellcome.
gramo said:Hmm, over lapping voltages for different gears, leave it with me, I'm sure with enough samples we could calculate the average that would be a lot closer to the actual manufacture's specifications.. Its 2am here, I'll get on it tomorrow and make another program for you
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?