No need to add to the parts count. You can achieve the same thing in software, by making a simple change to the interrupt service routine.
Change this;
incf VSSINTS,F ; Increment the VSSINTS ram variable
btfss VSSINTS,6 ; Have we tallied up 64 (0x40) of em yet?
goto IntSvcExit ; No
clrf VSSINTS ; Yes, so restart the counter
comf VSSINT,F ; And toggle the VSSINT flag
To this;
incf VSSINTS,F ; Increment the VSSINTS ram variable
btfss STATUS,Z ; Have we tallied up 256 of em yet?
goto IntSvcExit ; No
comf VSSINT,F ; Yes, so toggle the VSSINT flag
I got to thinking about this some more.
After doing some math last night, I think I'll have to revise this a bit.
Keeping in mind, the software's goal is to determine the number of cycles of the crank sensor, per given number of cycles of the rear wheel sensor (or ABS sensor in your case).
Looking at the ST1100 spec sheet, we have the following gear reductions/ratios
Primary reduction = 1.829
Final reduction = 2.833
1st gear = 2.266
2nd gear = 1.500
3rd gear = 1.142
4th gear = 0.916
5th gear = 0.758
So, in;
- 1st gear, there are (1.829 x 2.833 x 2.266) = 11.74 crank shaft revolutions per rear wheel revolution
- 2nd gear, there are (1.829 x 2.833 x 1.500) = 7.77 crank shaft revolutions per rear wheel revolution
- 3rd gear, there are (1.829 x 2.833 x 1.142) = 5.92 crank shaft revolutions per rear wheel revolution
- 4th gear, there are (1.829 x 2.833 x 0.916) = 4.75 crank shaft revolutions per rear wheel revolution
- 5th gear, there are (1.829 x 2.833 x 0.758) = 3.93 crank shaft revolutions per rear wheel revolution
Each crank shaft revolution produces 12 cycles of the crank shaft position sensor (aka. Ignition Pulse Sensor, aka IPG)
So, in;
- 1st gear, there are (11.74 x 12) = 140 IPG cycles per rear wheel revolution
- 2nd gear, there are (7.77 x 12) = 93 IPG cycles per rear wheel revolution
- 3rd gear, there are (5.92 x 12) = 71 IPG cycles per rear wheel revolution
- 4th gear, there are (4.75 x 12) = 57 IPG cycles per rear wheel revolution
- 5th gear, there are (3.93 x 12) = 47 IPG cycles per rear wheel revolution
Since the register that accumulates the number of IPG cycles is an 8 bit register, we don't want to 'wrap' the counter (ie. exceed 255).
I think you mentioned earlier that there are 120 cycles of the ABS sensor, per rear wheel revolution. Conveniently close enough to 128. Also, interesting is - that's the same as the ST1300.
So, it works out rather nicely... to set the interrupt service routine to divide the ABS sensor's frequency by one rear-wheel's-worth of rotation.
Thus, I would recommend making a simple one line modification to the interrupt service routine, in the source code attached to post # 3 at the beginning of this thread:
Change this;
incf VSSINTS,F ; Increment the VSSINTS ram variable
btfss VSSINTS,6 ; Have we tallied up 64 (0x40, B'01000000') of em yet?
goto IntSvcExit ; No
clrf VSSINTS ; Yes, so restart the counter
comf VSSINT,F ; And toggle the VSSINT flag
to this;
incf VSSINTS,F ; Increment the VSSINTS ram variable
btfss VSSINTS,7 ; Have we tallied up 128 (0x80, B'10000000') of em yet?
goto IntSvcExit ; No
clrf VSSINTS ; Yes, so restart the counter
comf VSSINT,F ; And toggle the VSSINT flag
Hopefully, that made sense.