![]() |
Re: EDU Mini Controller & 2005 Nav Code
[quote=Mark McLeod]The memory map can be generated by MPLAB whenever you compile your code by going to:
Project -> Build Options... -> Project then click on the "MPLINK Linker" tab, then click on "Generate map file". After you build your project look in your project directory for a text file ending in ".map". You can view it in any text editor. Mark, I've been using the .map file recently thanks to your help. I'm having another problem with my rc variable and when I try to look it up in the .map file (in the symbols-sorted by name) it's not even listed. Shouldn't it be there somewhere or am I looking in the wrong spot? |
Re: EDU Mini Controller & 2005 Nav Code
.map will only list variables with a fixed, permanent location. Those that are declared to be static or are declared within a project or header file, but outside any function.
The way rc is declared (within a function and not static -- int rc) means it doesn't persist between calls to that function, so it doesn't have a permanent location or home so to speak. You'll also notice that rc is actually declared 14 or so times, but these are all really different variables, not the same one. By design the code happens to reuse the name just to make it easier for a reader to trace the data flow. Not having a fixed "home" none of these variables will be explicitly called out in the link map, instead they are dynamically allocated only when the function is active. When the variable is required. When active it will get placed in whatever free data space is available, but the actual location will vary based on what other functions are also active at that particular time. A chunk of Data space is reserved by the linker for these transient variables, but that space is shared by the transient variables of every function. If you really want to see the dynamic location allocated for rc you can add a debug printf within the function to print the address of rc, e.g., printf(" rc address=%dr", &rc); |
Re: EDU Mini Controller & 2005 Nav Code
Mark,
Thanks so much for the continued help! I'll try your suggesion. I know (I think I know) it's an overwrite issue because I can change the value of rc by adding or removing printf's like you mentioned in your previous post. I can't change it to zero or one like it is supposed to be, but rc either equals 10 or 24 depending on what printf's I use. I'll keep trying. Thanks again for your help! |
Re: EDU Mini Controller & 2005 Nav Code
Mark,
Thanks again for your insight and patience! We are off and running again! |
Re: EDU Mini Controller & 2005 Nav Code
Hi Guys,
I hope we are not "debugging the debug code" again, but here is the latest situation: We are trying to modify Kevin's Nav Code (pid.c specifically) to allow a third motor (arm shoulder joint) to be pid controlled using a potentiometer for the feedback device. We have the adc stuff all worked so we are correctly reading the pot and the command.h and robot.c have been modified to include the commands and code for a third motor. But we are currently stuck at the point where robot.c calls the set_pos() function so that pid.c knows where to go. Robot.c is passing the correct motor number and command position to the set_pos function, but when set_pos() function goes to load it into the motor_info structure, the value changes. This change only occurs when we run a command for the third motor. When we use a CMD_DRIVE for example, pos and pos_cmd are always the same value but when we use our CMD_SHOULDER, pos = 760 (correct value) and pos_cmd = 25637. Kevin's Code from pid.c: void set_pos(int motor, long int pos) // pos = encoder counts or pot input) // 256 = 1 rev { motor_info[motor].pid_mode = PID_POS; motor_info[motor].pos_cmd = pos; pid_time = 1; // Start over } Printing the output looks like this: motor = 3 This is correct pos = 760 This is correct pos_cmd = 25637 Not sure what this is pos_cmd & pos should be the same value Any ideas? |
Re: EDU Mini Controller & 2005 Nav Code
Jeff,
Looking at the base EDU PID code, the first two motors, LEFT & RIGHT are defined with values of 0 & 1. I would expect your new motor would have a value of 2 not 3. However, 3 should work fine as long as you've sized the motor_info array with a minimum value of 4. If this is not the problem, perhaps you could post your actual code. This may help isolate the issue. Mike |
Re: EDU Mini Controller & 2005 Nav Code
Mike,
You are right on! I defined our shoulder motor as 3 instead of 2. Thanks man, I knew a set of experienced eyes would catch the problem quickly! Now it's on to find the next problem! Jeff |
| 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