![]() |
Re: EDU Mini Controller & 2005 Nav Code
Kevin,
Although you probably know already, I tried your edu_gyro code out on the VEX with ver 5 firmware. I have the ADXRS150EB attached and the software worked flawlessly. Jon Mittelman Team236 |
Re: EDU Mini Controller & 2005 Nav Code
Kevin,
Yep, I've spent some time in that ferry line myself! It's a great time to read my Servo Magazine! Yes, I have run just the gyro code on my EDU controller and it worked fine. When I rotated the bot by hand, the gyro angle changed the apprpriate amount. So I know the hardware is all hooked up correctly. BTW I'm using the ADXRS150EB. I knew I was digging deep into the code because I was trying to figure out why the angle (as read by a printf statement of "heading" in cmd_turn() in robot.c) was only showing a -1 or a 0. Could it have anything to do with the fact that in the stand-alone gyro code, you have us read the gyro every cycle in the fast loop i.e. Process_Gyro_Data() is in the fast loop as directed in gyro_readme.txt? In the FRC code, you only read the gyro "on demand". They way I have it currently set up, it's doing both - maybe I'm swamping the controller? prograid, Yes, You are right about the sharing issue. I checked my code and I'm declaring IO1 = INPUT in User_Initialization() in user_routines.c. Manoel, Thanks, I figured I was too liberal with the printf's! The problem was present though before I put in the printf's so I don't think they are a cause. But you are right that maybe it's not telling me the whole story... Everyone, I REALLY appreciate your time and effort!!! |
Re: EDU Mini Controller & 2005 Nav Code
Quote:
-Kevin |
Re: EDU Mini Controller & 2005 Nav Code
Quote:
Most, if not all, of my code will work with the Vex. I don't really advertise it because Vex is more of a commercial enterprise and I'd rather spend my time supporting the FRC. I remember that you had some problems with your encoders this past build season. Did you get the problem resolved and your 'bot working? -Kevin |
Re: EDU Mini Controller & 2005 Nav Code
Quote:
Yes, we had 4 encoders working flawlessly. I thought I had let you know last year! BTW, FIRST is helping to promote the VEX as a way for teams to a) test the robotic waters b) allow programming teams to develop code in parallel with the build phase VEX is certainly cheaper than the Edubot. If it takes a commercial enterprise to help promote FIRST, then so be it! Regards and thanks again Jon |
Re: EDU Mini Controller & 2005 Nav Code
Hi guys,
I sent our code to Kevin and nothing jumped out at him so if anyone has more ideas I'm all ears! My variable gyro_angle will never been anything but 0 or -1. Turning one direction makes it 0, the other direction makes it -1. No matter what the temp_gyro_rate variable is, the result of the following line of code is always 0 or -1. gyro_angle += (long) temp_gyro_rate; |
Re: EDU Mini Controller & 2005 Nav Code
Post the full project zip for us to take a look at.
Bugs draw programmers like honey does flies. |
Re: EDU Mini Controller & 2005 Nav Code
1 Attachment(s)
Ok Mark, here it is. I had to delete some things from the project folder to get under the size limit. Let me know if I deleted anything you need to see! Thanks again for all your input!
Jeff |
Re: EDU Mini Controller & 2005 Nav Code
Jeff,
I know this was mentioned earlier in the thread (by Manoel), but I'm thinking your code may be working fine, but the print statements are misleading. The %d format expects a 16 bit integer and the gyro_angle variable is 32 bits. The compiler is going to place all 4 bytes on the stack when it calls the printf routine and I think what you are seeing is the display of only the high 16 bits of the 32 bit integer. Until the angle gets large enough (positive or negative), the values displayed will only be 0 (0x0000) or -1 (0xFFFF) since the lower 16 bits are ignored. If you haven't already, try modifying the printf to the following and see if that gives you any different results. printf ("gyro_angle = %d\n", (int) gyro_angle); Mike |
Re: EDU Mini Controller & 2005 Nav Code
Quote:
MPLAB wants the file EduCode.mcp. |
Re: EDU Mini Controller & 2005 Nav Code
Quote:
Just use the Project Wizard to make a new project from scratch. The printf is wrong because of the non-standard printf limitation and is causing some of your grief. Put in what Mike suggested and you'll see a difference. %lx will work to an extent, but it too has a bug that will return bad values on odd occasions. Of course with (int) if gyro_angle grows larger than 32,767 you'll suddenly seem to be printing out negative numbers. Here's the output I'm getting. Note I did change your prints to a single line per pass, but I didn't adjust the code to match the gyro I had handy. gyro_rate = 2242, gyro_angle = 0, (int)gyro_angle = 2242 gyro_rate = 2313, gyro_angle = 0, (int)gyro_angle = 4555 gyro_rate = 2372, gyro_angle = 0, (int)gyro_angle = 6927 gyro_rate = 2424, gyro_angle = 0, (int)gyro_angle = 9351 gyro_rate = 2459, gyro_angle = 0, (int)gyro_angle = 11810 gyro_rate = 2480, gyro_angle = 0, (int)gyro_angle = 14290 gyro_rate = 2493, gyro_angle = 0, (int)gyro_angle = 16783 gyro_rate = 2495, gyro_angle = 0, (int)gyro_angle = 19278 gyro_rate = 2490, gyro_angle = 0, (int)gyro_angle = 21768 gyro_rate = 2471, gyro_angle = 0, (int)gyro_angle = 24239 gyro_rate = 2449, gyro_angle = 0, (int)gyro_angle = 26688 gyro_rate = 2425, gyro_angle = 0, (int)gyro_angle = 29113 gyro_rate = 2399, gyro_angle = 0, (int)gyro_angle = 31512 gyro_rate = 2373, gyro_angle = 0, (int)gyro_angle = -31651 gyro_rate = 2335, gyro_angle = 0, (int)gyro_angle = -29316 |
Re: EDU Mini Controller & 2005 Nav Code
Here's a modified version of your project that print's the long value correctly.
|
Re: EDU Mini Controller & 2005 Nav Code
Guys,
I can't thank you all enough! The 0 and -1 problem was keeping me from looking in the right place for the real problem. Your help showed me the gyro code was doing what it was supposed to do (as you all suspected!). Manoel, I'm sorry I did not quite get your point in your earlier email. You were right on! Mark, thanks for tweaking the code! The REAL problem is more embarrasing. When I used the CMD_TURN, the bot would not stop turning, it would just keep going as if the pid routine was not watching it. It turns out my lefts and rights are crossed somehow. When I changed the minus signs in front of TURN_SPEED in the cmd_turn() function, it now works! It kept going because it was looking for a turn in the wrong direction. Thanks again guys for all your patient help!! Jeff |
Re: EDU Mini Controller & 2005 Nav Code
Quote:
-Kevin |
Re: EDU Mini Controller & 2005 Nav Code
It's more fun if you don't have to debug the debug code.;)
|
| All times are GMT -5. The time now is 00:10. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi