|
Strange Problem, varible not subtracting?
Ok, this is one of those stupid simple problems that we don't get it. In this post is FIVE screen shots of our code and a zip file of the project in easyC along with the screen shots again.
What we are trying to do is subtract two varibles, then assign it to another varible in easyC. Sounds simple right?
In screen shot #1 you see the varible we are having problems with:
enc_Right_Difference = 10-5
Then in the terminal window, you see enc_Right_Difference = 5. This is correct. No problems here.
In screen shot #2 you see the varible enc_Right_Difference = Count minus 100. And the terminal window reports a 100 difference between the two varible. No problems here.
In screen shot #3 you see the varible enc_Right_Difference = 100 - Old_Count. And the terminal window reports a 100....uh oh problems here....But wait...Shouldn't enc_Right_Old_Count get updated by enc_Right_Count?? Two lines down. Hmm.....It's not updating varible enc_Right_Old_Count so then now enc_Right_Difference is ALWAYS equal to 100. No good.
In screen shot #4 you see enc_Right_Old_Count is now assigned to a constant 50, and the terminal screen shows that indeed that varible is 50, BUT WAIT....just above back up two line for varible enc_Right_Difference = 100 - enc_Right_Old_Count. The controller KNOWS THAT enc_Right_Old_Count is equal to 50, but why isn't it SUBTRACTING????
Are we losing our minds?
In screen shot #5 is our orginal code before doing all this research debugging to a terminal window...
Why won't in screen shot #4 it subtract? It's like that varible gets blown away.
Is it because when it returns a varible at the bottom is loses it's orginal value? Just trying to help our kids understand it and it stumped me too....
__________________
Team T.H.R.U.S.T. 1501
Download all of our past robot's source code here: Repository
Favorite CD quote:
"That can't be their 'bot. not nearly enough (if any) rivets to be a 1501 machine." ~RogerR: Team #1369
|