Clutch switch bounce?

Testing and development of Megasquirt 3

Moderators: jsmcortina, muythaibxr

Post Reply
rabid
Experienced MS/Extra'er
Posts: 303
Joined: Mon May 09, 2005 7:44 am

Clutch switch bounce?

Post by rabid »

I'm trying to add some simple code into misc.c that will add 1 to outpc.gear everytime the clutch is pressed. The point of it is, on top of my other changes, that it will target the correct boost per gear before I actually finish shifting gears. The code does what it is suppose to, about 2/3 of the time. I think what is happening is the clutch switch is making intermittent contact during press and again during release. My datalog shows the gear change radically only during press and again during release. When the clutch isn't pressed the normal vss/rpm code is re-enabled and sets is right back to the correct gear.

Code: Select all

//this is code in the do_launch function
            if (!(outpc.status2 & STATUS2_LAUNCHIN)) { // gone from no-press to being pressed
                outpc.status2 |= STATUS2_LAUNCHIN;
		outpc.gear = outpc.gear + 1; // force gear detection to up shift 

Code: Select all

void gearpos()
{
if (outpc.status2 & STATUS2_LAUNCHIN) // prevents code from changing gear during forced up shift in launch code.
{
	return;
}
I was thinking there should be some delay timer that prevents the pin_launch from changing state too quickly. For example if it goes true then it can't go false again for at least 100ms or so. Or maybe the switch needs to be in a state continuously for at least a set time before it is set to that state. Or perhaps this is already the case and I'm missing something.

Here is a graph of what I see the code doing. The car is on jack stands and in 1st gear the whole time. TPS is barely off idle. I press the clutch and it sets to 3rd gear. I release the clutch and it shoots to 5th gear and drops back to 1st. The next two presses work at expected. That last one is 3rd gear.
graph.png
Any insight would be much appreciated.
rabid
Experienced MS/Extra'er
Posts: 303
Joined: Mon May 09, 2005 7:44 am

Re: Clutch switch bounce?

Post by rabid »

I've fully tested this code and it solved the problems I had.

Code: Select all

		launchin_count = launchin_count + 1;		
		if (launchin_count == 4)
		{
			if (outpc.rpm <= ram4.flats_arm)
			{
				if((outpc.gear >= 1) && (outpc.vss1 > 5))
				{
					outpc.gear = outpc.gear - 1;  //down shift
				}
			}
			else
			{
				outpc.gear = outpc.gear + 1; // up shift
			}
		}
Post Reply