completed project/version 2//industrial:yaris tach
' {$PBASIC 2.5}
' {$STAMP BS2}
'*************************PROGRAM ABSTRACT**********************************************
'*TACHOMETER PROGRAM FOR 2008 TOYOTA YARIS. *
'*VERSON 2.0 BY STAN CLOYD 5/13/2009. *
'*THIS UPDATE EXPANDS TACHOMETER INDICATION RANGE TO 6,800 PLUS RPM AND RAISES RPM *
'*FLASH WARNING (4 hZ FLASH RATE) TO 6,000 RPM. THE YARIS ECU REPORTEDLY STARTS *
'*LIMITING RPM AT 6,400 RPM AND CAN KEEP CALCULATING ECU OUTPUT VALUES UP TO 7,000 RPM.*
'*PARALLAX BS2 PIN #15 IS USED TO READ TACH SIGNAL FROM THE OBD2 SERVICE CONNECTOR. *
'*INPUT SIGNAL IS ATTENUATED FROM A 0-12 VOLT SQUARE WAVE TO A 0-5 VOLT SQUARE WAVE BY *
'*A 100 K CURRENT LIMITING RESISTER AND A 5.01 VOLT ZENER DIODE. OUTPUT PINS #s 0-14 *
'*ARE IMPEDANCE MATCHED TO THE LED LOADS BY LM342-N OP-AMP QUAD PACKS IN A UNITY GAIN *
'*CONFIGURATION. *
'*PULL DOWN RESISTERS WITH A VALUE OF 47 K ARE USED TO KEEP THE PROCESSOR OUTPUTS *
'*FROM FLOATING HIGH WHEN THE LOGIC HAS THEM OFF. COMPARISON OF RPM TO A COMMERCIAL *
'*DIGITAL TACHOMETER SHOWED A 1 % DIFFERANCE AT 650 RPM AND A 1/2 % DIFFERANCE AT *
'*3,200 RPM. CALIBRATION INTEGERS USED ARE FOR A 4 CYLINDER 4-CYCLE ENGINE ONLY. *
'*EEPROM DATA BELOW STORES THE RPM LIMIT VALUES THAT TURN ON AND OFF EACH DISPLAY LED. *
'***************************************************************************************
DATA Word 540, Word 950, Word 1400, Word 1850, Word 2300 'EPROM DATA *
DATA Word 2750, Word 3200, Word 3650, Word 4100, Word 4550 'EPROM DATA *
DATA Word 5000, Word 5450, Word 5900, Word 6350, Word 6800 'EPROM DATA *
'***************************************************************************************
'************************DECLARATIONS & INITIALIZATIONS*********************************
SAMPLE_L VAR Word '*INPUT SQUARE WAVE TIME-LOW COUNT *
SAMPLE_H VAR Word '*INPUT SQUARE WAVE TIME-HIGH COUNT *
PERIOD VAR Word '*TOTAL SQUARE WAVE PERIOD COUNT (INVERSE OF FREQUENCY) *
RPM VAR Word '*REVOLUTIONS PER MINUTE (CRANKSHAFT RPM) *
RPM_L VAR Word '*RPM CELL LIMITS READ FROM EEPROM TABLE *
INDEX VAR Byte '*OUTPUT PIN INDEX # *
CAL1 VAR Byte '*SCALING CONSTANT TO KEEP CAL2 BELOW INTEGER OVERFLOW LIMIT*
CAL2 VAR Word '* *
CAL1=230 '*FOUR CYLINDER ENGINE-SPECIFIC CALIBRATION VALUE *
CAL2=63050 '*FOUR CYLINDER ENGINE-SPECIFIC CALIBRATION VALUE *
START: '* *
PERIOD = 0 '*RESET/CLEAR LAST SCAN-LOOP VALUES *
SAMPLE_L= 0 '* *
SAMPLE_H= 0 '* *
RPM = 0 '* *
'* *
PULSIN 15, 0, SAMPLE_L '*SAMPLE PIN #15 LOW COUNT AT ZERO VOLTS *
PULSIN 15, 1, SAMPLE_H '*SAMPLE PIN #15 HIGH COUNT AT 5 VOLTS *
PERIOD = SAMPLE_L+SAMPLE_H '*CALCULATE TOTAL PERIOD COUNT *
PERIOD = PERIOD/CAL1 '*SCALING FACTOR TO PREVENT POSITIVE INTEGER OVERFLOW *
RPM = CAL2/PERIOD '*CALULATE RPM *
'* *
IF RPM>6000 THEN '*FLASH LEDS ON AND OFF AT 4 HZ WHEN RPM EXCEEDS 6000 RPM *
'*(SHIFT WARNING). *
FOR INDEX=0 TO 14 '************************************************************
LOW INDEX
NEXT
PAUSE 25
ENDIF
FOR INDEX=0 TO 28 STEP 2 '*TURN ON CORRECT LEDS FOR ANALOG DISPLAY *
READ INDEX, RPM_L.LOWBYTE '*INDICATION(ENGINE-RUNNING CONDITION ONLY). *
READ (INDEX+1), RPM_L.HIGHBYTE
IF RPM>RPM_L THEN
HIGH (INDEX/2)
ELSEIF RPM<RPM_L THEN
LOW (INDEX/2)
ENDIF
NEXT
DO WHILE PERIOD=0 '*REVERSING STROBE FLASH SEQUENCE WHEN *
FOR INDEX=0 TO 14 '*IGNITION KEY IS ON BUT ENGINE IS NOT *
HIGH INDEX '*RUNNING (HARDWARE DIAGNOSTIC, AKA CYLON EYES). *
PAUSE 20
LOW INDEX
PAUSE 20
NEXT
FOR INDEX=14 TO 0
HIGH INDEX
PAUSE 20
LOW INDEX
PAUSE 20
NEXT
LOOP
GOTO START
This is version 2 of the firmware. New things are the 12,000 to 16,000 MCD clear LEDs and the dimmer knob so night vision is protected. At full intensity each LED is pulling 30 milli-amps at 5 volts.
" border="0">
one more
end
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
MOORE'S LAW: The capabilities of electronics shall double every 18 months.
cloyd's corollary: Hardware is easy, software is hard.
Post Edited (yarisboy) : 12/21/2009 3:14:33 AM GMT
Comments
how u do it
I bought a couple of EM456's(?) to talk to my Jeep....but it seems I only ever "rediscover" that project in the middle of winter!!
Looks cool!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<FONT>Steve
What's the best thing to do in a lightning storm? "take a one iron out the bag and hold it straight up above your head, even God cant hit a one iron!"
Lee Travino after the second time being hit by lightning!