Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   EDU Mini Controller & 2005 Nav Code (http://www.chiefdelphi.com/forums/showthread.php?t=40352)

Jon236 15-11-2005 21:13

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

jaustin 15-11-2005 23:57

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!!!

Kevin Watson 16-11-2005 00:18

Re: EDU Mini Controller & 2005 Nav Code
 
Quote:

Originally Posted by jaustin
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!!!

Can you zip-up your build directory and e-mail it to me?

-Kevin

Kevin Watson 16-11-2005 00:35

Re: EDU Mini Controller & 2005 Nav Code
 
Quote:

Originally Posted by Jon236
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

Hi Jon,

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

Jon236 20-11-2005 21:32

Re: EDU Mini Controller & 2005 Nav Code
 
Quote:

Originally Posted by Kevin Watson
Hi Jon,

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


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

jaustin 25-11-2005 21:31

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;

Mark McLeod 26-11-2005 08:56

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.

jaustin 26-11-2005 12:37

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

Mike Bortfeldt 26-11-2005 14:00

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

Manoel 26-11-2005 14:02

Re: EDU Mini Controller & 2005 Nav Code
 
Quote:

Originally Posted by jaustin
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

Jeff,

MPLAB wants the file EduCode.mcp.

Mark McLeod 26-11-2005 14:29

Re: EDU Mini Controller & 2005 Nav Code
 
Quote:

Originally Posted by Manoel
Jeff,

MPLAB wants the file EduCode.mcp.

You don't really need that file.
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

Mark McLeod 26-11-2005 16:12

Re: EDU Mini Controller & 2005 Nav Code
 
Here's a modified version of your project that print's the long value correctly.
  • I removed the old IFI printf_lib.c/h files and changed everything to use the mcc18 standard printf instead. Use #include "stdio.h" in whatever files you want to use printfs. Instead of using "n" as a carriage return you now have to use "r". Finally, you need to set MPLAB to ignore type 2066 warnings, or just ignore them when they pop-up during builds.
  • I added a work-around for the printing of the long value. If you continue to use this it would be cleaner to hide the details in new print_routines.c/h files. Everything I added in gyro.c is marked with "// MLM".
  • I did change some of your printfs to remove the "n", so you might want to add those back in as "r".

jaustin 26-11-2005 19:54

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

Kevin Watson 26-11-2005 20:31

Re: EDU Mini Controller & 2005 Nav Code
 
Quote:

Originally Posted by jaustin
...it now works!

Cool. I hope to have a new, cleaned-up version of the scripting code before kick-off. I'll incorporate the latest gyro and encoder code too.

-Kevin

Mark McLeod 27-11-2005 09:56

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