BS2 Speedometer & Odometer.
jknightandkarr
Posts: 234
I'm not having much luck here. I'm using my BS2 homework board to design a speedometer using an instrument cluster from an 87 Firebird to calibrate & the cars vehical speed sensor & the VSS Buffer to operate the stock cluster & send a signal to the BS2. Now the problem is I got the BS2 acting as a speedometer using the Debug command to send it to the pc moniter for now, and according to my stock gauge my cordless drill runs the speedometer up to about 78-78.5 Mph, & the BS2 reads like 84 MPH
Here's my speedometer program
' {$STAMP BS2}
' {$PBASIC 2.5}
Pulse PIN 15
vss VAR Word
Mph VAR Word
DO
COUNT Pulse, 1000, vss
Mph=vss
DEBUG HOME, " MPH = ", DEC Mph
LOOP
Now since my stock instrument cluster is analog, I'm not sure if it's correct or off or what, and I have no other way to calibrate my speedometer program if its off or to tell if it's off. I also need to build an odometer using a 000,000.0 format and unless my stock cluster is correct, I can't calibrate my odometer either, nor do I have an idea how I need to code my program to opperate as a odometer as well. I'll probly use driver chips to operate the 7-segment displays. I'm still learning about the BS2 & programing it. Please help.
Joe
Post Edited (jknightandkarr) : 6/22/2009 6:41:33 PM GMT
Here's my speedometer program
' {$STAMP BS2}
' {$PBASIC 2.5}
Pulse PIN 15
vss VAR Word
Mph VAR Word
DO
COUNT Pulse, 1000, vss
Mph=vss
DEBUG HOME, " MPH = ", DEC Mph
LOOP
Now since my stock instrument cluster is analog, I'm not sure if it's correct or off or what, and I have no other way to calibrate my speedometer program if its off or to tell if it's off. I also need to build an odometer using a 000,000.0 format and unless my stock cluster is correct, I can't calibrate my odometer either, nor do I have an idea how I need to code my program to opperate as a odometer as well. I'll probly use driver chips to operate the 7-segment displays. I'm still learning about the BS2 & programing it. Please help.
Joe
Post Edited (jknightandkarr) : 6/22/2009 6:41:33 PM GMT
Comments
You might try this and see if this changes your value on the BS2 Output
COUNT Pulse, 1000, vss·· to· ·COUNT Pulse, 995, vss ·or COUNT Pluse 1005,·vss
This could be a timing problem in that how long dose it take to run your routine that·you are using
This is only a guess in that I have not use the COUNT Command before and you may have try this alreaady if that is the case
You do not need vss· and MPH if they are going to be the same value
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Joe
Post Edited (jknightandkarr) : 6/22/2009 9:53:37 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
Some cars use 2000 PP Mile and some use 4000 PP Mile GM and there are many different setups
So this is what I see for a 4000 Pulses per Mile
90mph = 6000pulses per minute = 100pulese per second
60mph = 4000ppm = 66.66pps
30mph = 2000ppm = 33.33pps
15mph = 1000ppm = 16.66pps
Your reading of 89pps works out to 80.1 mph
Guess I should add that 90 mph / 6000 pp minute = .015 also 15mph / 1000pp minute =.015
So your pulses 89 times 60 seconds = 5340rpm·Times .015 = 80.1 mph
Post Edited (L_Gaminde) : 6/23/2009 12:44:31 AM GMT
DO
COUNT Pulse, 1000, vss
Mph = vss * 9
DEBUG HOME, " MPH = ", DEC Mph DIG 2, DEC Mph DIG 1
LOOP
I'll take the suggestions into suggestion. Thanks. As for reading the rpms on the drill? I have no idea. but I have an electric Firebird speedometer cluster hooked up at the same time as the BS2 as a test bench, so I'm not too far off. The stock speedo is reading about 78 mph to the BS2's 84 They are close to matching. But I'm not spot on the dot, but if your way gets it there I'll try it. Thanks.
Joe
Tried this, now matching against my Firebird cluster I'm now reading 78 Mph against the Firebirds 80 Mph I'll keep playing with that though. Thanks.
Joe
Post Edited (jknightandkarr) : 6/23/2009 2:37:52 AM GMT
also if it has two speeds put it on low and give it another try
you can have two debugs one with vss the other with mph to compare
Joe
How many pulses per mile is the·instrument cluster rated at ?· this is your calibration !
Lets get this working first correctly then we can move on to Odometer or both will be wrong.
I have an 89 factory Pontiac Firebird dealer manual for my 89 Trans-Am, & It says under the VSS section of the electronics scematics section of book 4000 ppm to the cluster.
You got it exactly now, I am just using my drill to spin the vss, which then sends the signal to the factory cluster from the buffer. I got my cluster, buffer & now even my BS2 all powered from an old 486 computer swichable power supply, which supplies me about 9.8 VDC. I'll try your suggestion of using the BS2 to send a signal to my cluster to get a reading. I tried it before but it didn't work. Maybe it will now since the BS2 & the cluster are both working off the same power supply.
Joe
Joe
67 should give you about 63.809 mph
the reading should be 60 mph so the cluster is fast by about 3 mph ?
so looking back at the program
DO
COUNT Pulse, 1000, vss
Mph = vss * 9
DEBUG HOME, " MPH = ", DEC Mph DIG 2, DEC Mph DIG 1
LOOP
and it was 2 mph slower than the cluster it looks to be dead on !!!
well after playing around with the speedometer's needle at a FREQOUT 15, 5000, 67 The speedometer now reads 60 Mph which is only 20 pulses per mile off which is hardly anything. I thank you for help making my speedometer part of my test bench accurate! Now for the odometer program & then getting my test bench tach to work. lol
Joe
I used four seperate 1 byte varables for my odometer this was done on a pic chip.
ODOM0 VAR BYTE 'MILES 10000 TO 990000
ODOM1 VAR BYTE 'MILES 100 TO 9900
ODOM2 VAR BYTE 'MILES 1 TO 99
ODOM3 VAR BYTE 'MILES .1 TO .9
miles = vss + miles 'This adds up the pulses after each spedo read
if miles = 400 goto odom3 'This checks for 400 ppm and adds one to the tenths place
now you just add one to each varable as the one below it rolls over odom3 then odom2 then odom1 then odom0
Well I added this to my speedo code as well as the variable data, howver for some reason, odom3 isn't getting any changes.
DEBUG " Odometer = ", DEC odom3 DIG 1, CR
DEBUG " Miles = ", DEC miles DIG 3, DEC miles DIG 2, DEC miles DIG 1, CR
miles=vss+miles
IF (miles=400) THEN
odom3=odom3+1
ENDIF
LOOP
I tried several variations of the odometer program. Nothing advances odom3. What am I going wrong? Do I need to make each odom# a separate program off of the main one?
Joe
DO
COUNT Pulse, 1000, vss
Mph = vss * 9
DEBUG HOME, " MPH = ", DEC Mph DIG 2, DEC Mph DIG 1
vss1 = vss + vss1······················································· ·: Keeps tabs on all pulses,··· VSS1 needs to be saved to eprom
IF (vss1 => 400) THEN gosub odom10th·························· : Keeps looking at pulses until you have reached 400 or more
LOOP
odom10th:
vss1=vss1-400····························································: Takes away 400 pulses for 1 tenth, Saves overflow in·VSS1
odom3=odom3+1··························································: This is your tenths,··· needs to be saved to eprom··
if odom3 = 10 then gosub odom_one······························· : Check if tenths = 10 if so goto miles and add one to the miles
return
and just keep going
Post Edited (L_Gaminde) : 6/27/2009 6:38:26 PM GMT
66.66 what you need 67 what you set it for, your only off .34 pulses
.34 pulses x 1.32 feet per pulse =·.4488 feet off or 5.3856 inches per mile
it will take 11,764.7 miles to be off by one mile yea thats close enough
you will be off 1 mile every 3105.88 miles
I think it needs fixin!
should have been .34 x 60 x 1.32 = 20.4" per mile
I'm not sure where the 67 & 66 2/3 comes in, but advancing the odom3 by 1 every 400 pulses will be what I need to use since 4,000/10=400 & 60 mph=1 mile per min=.1 miles per 6 seconds. I used the 67 on the FREQOUT command to generate 67 pulses per sec to calibrate my factoy speedometer cluster. I wasn't using it on my odometer to design it or calibrate it.
Joe
just curious to see if you made it work.
Joe
see if this runs using a drill
' {$STAMP BS2}
·vss VAR Word
·vss1 VAR Word
·Mph VAR Word
·odom3 VAR Word
start:
COUNT pulse, 1000, vss
'vss = 67
Mph = vss * 9
DEBUG HOME, " MPH = ", DEC Mph DIG 2, DEC Mph DIG 1,CR
DEBUG "ODOM = ","000,000,",DEC odom3, CR
vss1 = vss + vss1
IF vss1 >= 400 THEN odom10th······ ' Keeps tabs on all pulses,··· VSS1 needs TO be saved TO eprom
GOTO start························ ' Keeps looking at pulses until you have reached 400 OR more
odom10th:
vss1=vss1 - 400··················· ' Takes away 400 pulses FOR 1 tenth, Saves overflow in VSS1
odom3 = odom3+1··················· ' This is your tenths,··· needs TO be saved TO eprom
IF odom3 = 10 THEN· odom_one······ ' Check IF tenths = 10 IF so GOTO miles AND add one TO the miles
GOTO start
odom_one
DEBUG "done reading"
' {$STAMP BS2}
·vss VAR Word
·vss1 VAR Word
·Mph VAR Word
·odom3 VAR Word
start:
COUNT 1, 1000, vss
vss = 67
Mph = vss * 9
DEBUG HOME, " MPH = ", DEC Mph DIG 3,DEC Mph DIG 2, DEC Mph DIG 1,CR
DEBUG "ODOM = ","000,000,",DEC odom3, CR
vss1 = vss + vss1
IF vss1 >= 400 THEN odom10th······ ' Keeps tabs on all pulses,··· VSS1 needs TO be saved TO eprom
GOTO start························ ' Keeps looking at pulses until you have reached 400 OR more
odom10th:
vss1=vss1 - 400··················· ' Takes away 400 pulses FOR 1 tenth, Saves overflow in VSS1
odom3 = odom3+1··················· ' This is your tenths,··· needs TO be saved TO eprom
IF odom3 = 10 THEN· odom_one······ ' Check IF tenths = 10 IF so GOTO miles AND add one TO the miles
GOTO start
odom_one
DEBUG "done reading"
' {$STAMP BS2}
· vss VAR Word
· vss1 VAR Word
· Mph VAR Word
· odom10 VAR Byte
· odom1· VAR Byte
start:
COUNT 1, 1000, vss
vss = 67
Mph = vss * 9
vss1 = vss + vss1················· ' Keeps tabs on all pulses,··· VSS1 needs TO be saved TO eprom
DEBUG HOME, " MPH = ", DEC Mph DIG 3,DEC Mph DIG 2, DEC Mph DIG 1,CR
DEBUG "ODOM = ","000","/","0",DEC odom1 DIG 1, DEC odom1 DIG 0,"/" ,DEC odom10, CR
IF vss1 >= 400 THEN odom10th
GOTO start························ ' Keeps looking at pulses until you have reached 400 OR more
odom10th:
vss1=vss1 - 400··················· ' Takes away 400 pulses FOR 1 tenth, Saves overflow in VSS1
odom10 = odom10+1················· ' This is your tenths,··· needs TO be saved TO eprom
IF odom10 = 10 THEN· odom_one····· ' Check IF tenths = 10 IF so GOTO miles AND add one TO the miles
GOTO start
odom_one:
odom10 = 0
odom1 = odom1 +1
IF odom1 = 100 THEN odom100
GOTO start
odom100:
DEBUG "done reading"
Joe
I finally tried it, took some time away from my electronics, I needed it. Works great, to use my test bench just remove the "vss=67" line then add the odom100 subprog & odom2 as a var & export the digits to 7 seg displays as well as a couple other minor things.
now the last sub prog should be something like
odom100:
odom_one = 0
odom2 = odom2 +1
IF odom2 = 1000 THEN odom2 = 0 'This line may or may not be needed'
GOTO start
Now I need to export the following variables to eeprom, odom10, odom1 & odom 2, correct? How is this done? I'd add an external eeprom to avoid using the BS2's eeprom & risk wearing that out by storing the odometers variables.
I really appreaciate your help Larry~. Thanks to your last program I see why I had problems with mine. I should have left out the ( ) & should have left out GOSUB as well.
Joe