This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Creating an Independent InstaSpin Project

Other Parts Discussed in Thread: MOTORWARE

This is a post to help anyone else who encounters the same problems I do with the MotorWare directory structure.  I've seen some abstract mentions of this solution, but I haven't seen anyone post a detailed explanation of what to do.  If so, I apologize for the redundant post.

I work on many different projects using InstaSpin.  We've generally liked it so far, and have used it for many different projects beyond simple motor control.  We've implemented it in an automatic voltage regulator for a field-wound generator, have used it for basic power monitoring, and are currently developing a grid-tie inverter using the 28069.  I need at least one separate copy of the main C file for each project, and because of the variety of our projects, I often need to modify other files as well.  Naturally, I cannot have 7 projects referencing the same file, if that file is different for each project.  Also, I cannot simply copy the whole MotorWare directory, because it's over 500MB.  I would run out of disk space.  I also need to share my source code with other people, which is difficult with the native structure.

So, I have been slowly compiling condensed, standalone copies of each InstaSpin Lab.  Whenever I start a new job, I just go find the appropriate condensed lab and copy it into a new folder on my computer.  I start CCS, import the virgin copy, and go to work.  It also makes sharing projects very easy, because I can just copy the single directory to anyone else's computer, into any directory, and it will still work.  Each copy occupies approximately 3.25MB, so they're easy to manage.

If anyone wants the condensed copies I've created so far, I'm happy to send them.  I don't have many; I've started most of my jobs with Lab 4 for the 28069, but I also have 28069 copies for Labs 5b and 11.

Here is how I do it from scratch, when the job requires a Lab that I haven't condensed yet.

1.  Start a new workspace.  I prefer to keep my jobs in separate workspaces.  If you want to keep all the Ti software in the same workspace, this isn't necessary.

2.  Import the lab that I want to use as my template.

3.  Create a new directory with the name you want for your new project.

4.  Copy all the files listed in the project explorer to this new directory.  You can do this by highlighting them in CCS and then dragging them out of CCS and into your folder in your file manager.

5.  I go find the original project directory in the MotorWare tree, and copy the two directories and three files into my new project directory.  Here's an example path:
C:\ti\motorware\motorware_1_01_00_15\sw\solutions\instaspin_foc\boards\boostxldrv8301_revB\f28x\f2806xF\projects\ccs5\proj_lab03a
The directories are .settings and Release, and the files are various project description files.

6.  Open up the file ".project" using a text editor.  I use Notepad++.  Windows Notepad doesn't recognize the line ends, but you aren't doing much modification, so it's not a big deal.  On the third line, you will see this:  <name>proj_lab03a</name>.  Change proj_lab_03a to match the new directory you created.

7.  Back in CCS, import a new project, and select the new folder you just created.  You should see your project name listed.  Import it.

8.  Remember all those files you copied?  Those were linked resources in CCS.  The easiest way to redirect CCS to your new copies is to just highlight them all and hit "Delete".  The list should disappear, but then it will repopulate with the files in your directory.

9.  What follows is the really tedious part.  Create a file in your folder called "headers".

10.  Find all the header files that your project needs in the MotorWare directory, and copy them into your new Headers file.

11.  Fix all the directory references in your .c files.  For example, gpio.c needs gpio.h, but it's given a path to the MotorWare directory.  Change it to #include "headers/gpio.h".

12.  Change all the directory references in your .h files, as well.  Because all your headers are in once place, you can just delete the path.  For example, hal.h also needs gpio.h.  Because they're in the same directory, you can change the appropriate line to #include "gpio.h"

For steps 10-12, I've found that building the project will ferret out all the bad references and paths for you..  CCS will complain about any files it can't find, so I let it tell me what's missing (or what paths need to be changed).  For me it's a faster method than opening all the .c files to find the requisite .h files, etc.

Eventually, you'll get a build that doesn't show any errors.  At this point, you're done.  You might need to change the compiler that's defaulted in your project to one that you actually have installed in CCS, but that happens to me even when I'm using the original projects.  Another issue is that you might get a warning about the "Include" list.  Just open up the project properties, and go under CCS Build>C2000 Compiler>Include Options and delete the two /src items.

One oddity is that you'll encounter a handful of new errors if you ever migrate to the Flash compilation.  First, you'll suddenly be using memCopy.c where you weren't before.  You'll have to fix the reference in memCopy.c to #include "headers/memCopy.h".  You'll also get a complaint about those two /src directories in the Includes path.  Just take them out again.  You'll also get that compiler version warning.  It's the same fix as before.  Finally, when you switch to Flash, CCS automatically activates the appropriate .cmd file, but it doesn't remove f28069F_ram_lnk.cmd.  Just right-click it and select "Exclude from Build".

Another thing I've encountered is that occasionally one or two files won't copy in the first place (specifically the ram linker file has given me trouble twice).  If that happens, just use the original project to track it down and copy it into your new project folder.  It will auto-populate in CCS once you've put it in the project directory.

I hope that helps someone out.  After having some practice, this only takes me about 15 minutes now (I just did a new one this morning, which prompted this post).

Matt