A while ago I tried modifying Kevin’s encoder code to work with gear tooth sensors. I had a test “robot” set up in my room, with basically a push switch on a digital in and every time I pressed it, it would trigger the interrupt and the count would increase by one.
It took a while to get working(since I’m pretty new at this) and with a little help from everyone on here (thanks guys!) I had it working fine with my practice setup. When we got to our regional, and I put it on the robot, I got a code error, the blinking red light of doom, and I don’t understand why. It was working perfectly on the other processor. Any thoughts or comments?
I’ll post the important parts of the code, maybe you guys can come to my rescue again.
772 is pending for ATL and we’re probably going, so after scoring (very inconsistently) in autonomous maybe 1 sometimes the highest we got was 3, I would like to use the camera in combination with the GTS for better results.
If you have the time, I would really appreciate some feedback to what might be causing the code error. It worked fine at home, honest! lol. Thanks in advance…
If you’re using the 2006 controller, the one with the PIC 8722, don’t forget to get and use the new libraries and other fixes from IFI. And be advised, they don’t work in all cases, they certainly didn’t for me.
I didn’t have any problems before, but I did get the fixes, accutally, that might be the problem, I don’t remember if I tested the code at home with the fixes, I will look into that. And as far as the putdata, I have it called once above it. I’m not sure if that makes a difference or not, but I did comment it back in. I have no way to test (seeying as our robot is on it’s way to ATL) but if anyone has any more suggestions, it is appreciated!
Did not work for my team either, we had the new library and other stuff, and were still stuck on the field as a sitting duck, which was a bit of a shame.
Deniz, it looks like you call Getdata and Putdata each twice (including the commented one) in Process_Data_From_Master_uP(). I’m just taking a guess but I believe there only has to be one call for each in Process_Data_From_Master_uP() (generally Getdata is called at the beginning and Putdata at the end). Anyways, that might be worth a shot.
You’ve commented out the line that informs the compilier that the InterruptHandlerLow routine is an ISR. This is most likely the cause of your problem. Uncomment the following line and it will should at least get rid of the “red light of doom”.
Alright, I have no way to test all this, but they all sound like potential problems.
Andrew, yeah as far as calling those things twice, that’s because I was being careless when I merged my code with the camera code, however I’m pretty sure that’s not the problem, because in my other code I checked and I have the same thing, and we were using that all through the regionals. But I did change it so I call them only once (once at the beginning and the other one at the end, because it can’t hurt).
Mike, I uncommented, and I’m hoping for the best in ATL, maybe I’ll grab another processor again and try it on there.
I hate to nitpick but this is starting to become a growing problem…
* COMMENTS: You are free to use this source code for any non-commercial
* use. Please do not make copies of this source code, modified
* or un-modified, publicly available on the internet or
* elsewhere without permission. Thanks.
He’s explained his reasoning several times already, and I know you did not mean harm but it would probably be best to only post the relevant parts (i.e. your changes from the supplied versions) in the future.
As far as your problem, how repeatable is it? Does the code error happen immediately? If so it may not be a problem with the interrupts, since they wouldn’t get called unless you spun a wheel. Except I believe the ISR is shared between the digital IO interrupts and the communication interrupts with the camera, so check your pragma.
That tells it to save more than what your line saves, we had some red-light problems when our interrupts were overwriting data we needed because the ISR didn’t preserve it.
Good luck!
The error was immediate, as soon as the program loaded, I got the red light. As soon as I restarted I got the red light.
I’ll try what you suggested though. Thanks.
As far as posting Kevin’s code…
I read Kevin’s reasoning behind not wanting it being posted, I didn’t mean any harm, but I did alot of deleting to the encoder.c, so it would be kind of hard to show the changes without showing the whole thing. (it’s alot easier to look at the code as a whole, for my at least)
I posted it because I needed help, not to distribute, it’s easier to look over the code and find my errors instead of guessing.
That’s just my reasoning for what I did, if it was wrong, then I’m sorry.