ORIGINAL: jakestew
If you want to change this then change...
Code:
OPTION_REG = 0b00000000; // pullups on, falling edge, Tmr0
to
OPTION_REG = 0b01000000; // pullups on, rising edge, Tmr0
Also change...
Code:
else if(INTCONbits.INTF){ // ***** GP2 SENSOR INPUT *****
if(GPIObits.GP2 == 0){
to
else if(INTCONbits.INTF){ // ***** GP2 SENSOR INPUT *****
if(GPIObits.GP2 == 1){
Remember that the hall switch is active low, so falling edge = magnet approaching and rising edge = magnet leaving.
I'm not sure why people want to trigger as the magnet leaves the sensor. When the magnet triggers the sensor we know the RPM and the position, that's all we need to know to calculate the delay before firing the spark.
The only thing I can see this change doing is wasting a couple degrees worth of time. If you want to use your existing sensor placement without moving anything it's easy enough to just change the Hall degree setting in the spreadsheet.
It's also not difficult to change the code if you want to trigger with the magnet leaving the sensor. If people really want the option I can write a setting to change this into the code.
The only problem is that in order to keep the timing the same I need to compile in as many variable options as I can, so I use defines to do this and the preprocessor figures out some of the settings at compile time. Because of this, I can't make the spreadsheet produce the hex for some settings because they're compiled in. I want to avoid making the spreadsheet too large and complicated because I have to change and test it for every code revision. Adding multiple hex files and code changing options is sure to result in more work, more errors, or probably both.
I just need to know what the reasoning is behind passing up the first opportunity (magnet triggering the hall) to time the spark in favor of the 2nd opportunity (magnet leaving hall)? It just doesn't seem to make sense to me.
-Jake