Simplest Code

What is the simplest code we can upload to the robot? I’m quite pressed for memory space. i can’t get both the default code and cordic math libary on their

I believe the simplest code you can download to the robot and have it do something is the default code.

What does “the simplest code” mean? If you just want some joysticks and buttons directly mapped to pwms/relays and don’t have any autonomous code, there is a significant amount you can remove from the default code. There are several functions you can remove from user_routines.c/h. Removing printf_lib.c/h and any calls to it would be another very significant space saver. There is probably more in other files, look for yourself.

well, after adding the cordic libary to the base code, it sweels to 48kb.

Can someone speak up who has actually used CORDIC on the IFI robot controller?

My thought is that the CORDIC implementation you’re using is no good for our application. I’m wondering if the one you’re using uses floating point math. If it does, that would swell the code due to the fact that the math library would have to emulate the floating point operations in software.

Why do you want to add the CORDIC library to your base code anyways?

I did some experimentation with it early on, before we gave up on our optical carpet tracking scheme.

My thought is that the CORDIC implementation you’re using is no good for our application. I’m wondering if the one you’re using uses floating point math. If it does, that would swell the code due to the fact that the math library would have to emulate the floating point operations in software.

CORDIC was devised specifically to avoid floating point operations. It uses addition, subtraction, and bitwise shifts. Doing those with floating point would be, um, pointless.

After some experimentation, it appears that the size of the hex file does not directly correspond to the amount of code that is actually uploaded to the robot controller. The hex file containing the default code has a size of 25 KB, while the hex file with the CORDIC library included (I believe this is the library in question) has a size of 48 KB. Even though this hex file is larger than the PIC’s 32 KB flash memory, it still uploads and executes on my RC without any problem.

So it seems therefore the size of the hex file containing the code is not an accurate measure of how much flash space the code will take up on the RC.

cibressus53, I think your problem lies somewhere else than in the size of your code.

Pat,

In the most general case, a hex file will be more than twice as big as the memory image it loads. This is because each byte of the memory image gets represented by two ascii characters in the hex file. And then there is the overhead of having to store address information, CRC/checksum information, and who knows what else.

I had to completly remove the print_lib to get it down to a small enoguh size (35kb). does anyone know the real max size for the hex file?

You can’t easily judge by the .hex file size. I can create a .hex file that’s 85kb and it fits on the RC just fine.

You know what it does look like though is an IFI_Loader version problem. The original IFI_Loader had a bug that only loaded half the available RC program memory. Check your IFI_Loader version. It should be 1.0.7.

You should use the .map file MPLAB can generate for you to see how much memory your program requires. It tells you exactly how much space your program uses, e.g.,



Program Memory Usage
Start		 End 
--------- ---------
0x000800	0x000805
0x000808	0x006622
0x300000	0x30000d	 
 
**24111 out of 33816 program addresses used, program memory utilization is 71%**

Note however that the program memory will be full when it reads 90%, because that last little bit of memory gets used for IFI stuff.

Good catch. I had forgotten about that. This version is available from Innovation First at http://www.innovationfirst.com/FIRSTRobotics/pdfs/IFI_Loader_1.0.7.zip. I hope that solves the problem for you.