MPLAB workspace will not open

I having an issue with the MPLAB workspace included in the programming file from vexlabs.com The problem is that I placed the Vex Code folder (as stated in the instruction pdf ) into the c:\mcc18\VexCode\ directory and when I open VexUserCode.mcw from this folder all that comes up in MPLAB is a blank project screen. I opened the user code from other folders downloaded from vexlabs and it worked, but this specific workspace file in the programming docs doesnt work. After I click VexUserCode.mcw then open, the output window flashes and turns blank

Can anyone shine some light on my predicament?

Also, on Page 5 of the pdf wat is the VexFirmwareCode.mcp and where can I get it?

Technic-R-C

Any ideas??? :slight_smile:

Technic-R-C

Sorry, I thought that you had resolved this issue, since this message is Date/Time stamped before the post, Re: Vex On-Line Controller Code v2.x (Available Source Version 0.80 Beta) - Post 11.

Remember to Open Projects from the Project Menu, and Source Code from the File Menu.

What version of the MPLAB IDE are you using?? I started with v7.20, then v7.50 and then v8.10. The Work-Space File Format for v8.10 is different than the v7.x, and once saved, won’t load in v7.50. If this is the case, you should get a message to that effect…

When you are Opening a Project from MPLAB, you should be using the files “VexUserCode.mcp” and “VexUserCode_DDT.mcp” I always show File Extensions, so I know what file I am looking at.

My Paths to the Source Code are fairly long, but lets try a simple experiment (KISS):
Download the Vex Starter Code and unzip it in the Root Directory.

[C:\]unzip VexCode_def_2008.zip
Archive:  VexCode_def_2008.zip
  inflating: VexCode/18f8520user.lkr
  inflating: VexCode/asm_lib.asm
  inflating: VexCode/delays.h
  inflating: VexCode/HowToRunAutonomousMode.pdf
  inflating: VexCode/ifi_aliases.h
  inflating: VexCode/ifi_default.h
  inflating: VexCode/ifi_picdefs.h
  inflating: VexCode/ifi_startup.c
  inflating: VexCode/ifi_utilities.c
  inflating: VexCode/ifi_utilities.h
  inflating: VexCode/main.c
  inflating: VexCode/PicSerialDrv.c
  inflating: VexCode/PicSerialDrv.h
  inflating: VexCode/printf_lib.c
  inflating: VexCode/printf_lib.h
  inflating: VexCode/README.txt
  inflating: VexCode/user_routines.c
  inflating: VexCode/user_routines.h
  inflating: VexCode/user_routines_DDT.c
  inflating: VexCode/user_routines_fast.c
  inflating: VexCode/user_routines_fast_DDT.c
  inflating: VexCode/VexUserCode.mcp
  inflating: VexCode/VexUserCode.mcw
  inflating: VexCode/VexUserCode_DDT.mcp
  inflating: VexCode/VexUserCode_DDT.mcw
  inflating: VexCode/Vex_alltimers.lib
  inflating: VexCode/Vex_alltimers_auton_test.lib
  inflating: VexCode/Vex_alltimers_wauton.lib
  inflating: VexCode/Vex_alltimers_wauton_jmpr.lib
  inflating: VexCode/Vex_default_DDT.hex
  inflating: VexCode/Vex_default_firmware.hex
  inflating: VexCode/Vex_library.lib
  inflating: VexCode/Vex_library_auton_test.lib
  inflating: VexCode/Vex_library_wauton.lib
  inflating: VexCode/Vex_library_wauton_jmpr.lib
  inflating: VexCode/VEX_MASTER_V7.BIN
  inflating: VexCode/Vex_Startup_UserCode.hex
  inflating: VexCode/updating-vex-master-firmware.pdf

[C:\]cd VexCode

[C:\VexCode]dir

 Volume in drive C is Boot Disk      Serial number is 38FC:35B8
 Directory of  C:\VexCode\*

10/11/2008   9:05         <DIR>    .
10/11/2008   9:05         <DIR>    ..
 2/16/2004  10:40           1,435  18f8520user.lkr
 2/01/2005  17:30           5,841  asm_lib.asm
 1/14/2004  15:34           1,887  delays.h
 8/14/2006  13:49          31,738  HowToRunAutonomousMode.pdf
 6/14/2005  10:49          11,795  ifi_aliases.h
 2/16/2005  19:26           9,331  ifi_default.h
 1/14/2004  15:34          36,457  ifi_picdefs.h
 1/14/2004  15:34           4,476  ifi_startup.c
 1/14/2004  15:34           8,434  ifi_utilities.c
 2/16/2005  19:38           2,503  ifi_utilities.h
 2/09/2005  15:01           2,547  main.c
 2/08/2005  14:25          22,967  PicSerialDrv.c
12/16/2004  13:25           4,257  PicSerialDrv.h
 1/19/2005  17:27          12,663  printf_lib.c
 1/14/2004  15:34           1,070  printf_lib.h
 8/14/2006  12:40           2,599  README.txt
 6/17/2008  17:18         101,755  updating-vex-master-firmware.pdf
11/03/2005  16:57          11,672  user_routines.c
 1/14/2004  15:34           3,173  user_routines.h
 2/08/2005  14:25           7,654  user_routines_DDT.c
11/15/2005  18:54           5,352  user_routines_fast.c
 2/08/2005  14:21           4,091  user_routines_fast_DDT.c
 8/14/2006  11:31           1,385  VexUserCode.mcp
 8/14/2006  12:42          22,528  VexUserCode.mcw
 2/08/2005  17:27           1,592  VexUserCode_DDT.mcp
 2/08/2005  17:27          22,528  VexUserCode_DDT.mcw
 4/23/2008  17:31          51,091  Vex_alltimers.lib
 4/23/2008  17:31          53,906  Vex_alltimers_auton_test.lib
 4/23/2008  17:31          51,307  Vex_alltimers_wauton.lib
 4/23/2008  17:31          52,493  Vex_alltimers_wauton_jmpr.lib
 2/09/2005  18:03          33,666  Vex_default_DDT.hex
 4/23/2008  17:31          34,246  Vex_default_firmware.hex
 4/23/2008  17:31          50,957  Vex_library.lib
 4/23/2008  17:31          54,354  Vex_library_auton_test.lib
 4/23/2008  17:31          51,755  Vex_library_wauton.lib
 4/23/2008  17:31          52,941  Vex_library_wauton_jmpr.lib
 8/14/2006  12:34          34,552  VEX_MASTER_V7.BIN
 4/23/2008  17:31          28,179  Vex_Startup_UserCode.hex
        891,177 bytes in 38 files and 2 dirs    966,656 bytes allocated
    277,692,416 bytes free

[C:\VexCode]

Start MPLAB.
Click Project–>Open
Navigate to the “C:\VexCode” directory.
(It should look like this 20081011-001.JPG, with File Extensions turned on)
Double Click on “VexUserCode.mcp”
Your Work Space should look like this 20081011-002.JPG.

By e-mailing VexLabs you can get the Default Firmware (See FAQ Post Vex Robotics Code)
20081011-001.JPG
20081011-002.JPG

Thanks MarkO

This is what I did… double check my work if you can

So I downloaded the Elevation - Appendix D (Programming Guide) folder and placed the MPLAB-Autonomous-Code Rev2 - Vex Code into the c:\mcc18\VexCode\ as stated by the pdf file. I then attempted to open the VexUserCode.mcp and VexUserCode.mcw files however they did not open and displayed only empty screens.

Then I downloaded the Vex Starter Code and put it into the same directory c:\mcc18\VexCode\ (replaced above one) and tried opening VexUserCode.mcp and VexUserCode.mcw and they both opened. (What is the difference between opening the workspace and prject?)

Well since the MPLAB-Autonomous-Code Rev2 - Vex Code should be the correct files for the competition I tried something else. I placed the Vex Starter Code into the C:\ directory and the MPLAB-Autonomous-Code Rev2 - Vex Code into the c:\mcc18\VexCode\ directory. I then proceeded in opening the VexUserCode.mcw from the Starter Code (or .mcp - didnt know if to open project or workspace) and proceeded in deleting the old library files and adding a new one Vex_2008_library.lib from the MPLAB-Autonomous-Code Rev2 - Vex Code (c:\mcc18\VexCode\ directory). After that I saved and overwrote the old VexUserCode.mcw code in the c:\mcc18\VexCode\ directory and now the workspace opens with the Vex_2008_library.lib as the only library file.

Is the only purpose of the Elevation Programming file to provide the Vex_2008_library.lib file?

Is this the correct setup for competition mode?

What is the difference between workspace and project? I’m guessing that you open workspaces and save them as projects that generate HEX files and can be downloaded to the controller.

Is the** Vex_2008_library.lib library** file the only library file that I need? In the Elevation Programming Readme it states that to

Do I need this library file to run motors?

Also… in the pdf is states that

However the file open in the screenshot is an .mcp (project file) not the .mcw (workspace file) Is this a mistake??

I didn’t notice how many I questions I asked until the end :eek:… If you could answer most of them that would be great!

Thanks

Technic-R-C

P.S. I have version 7.20

I have not tried the “MPLAB-Autonomous-Code Rev2”. Let me see what that does…

I will answer you other questions very shortly… :wink:

Eureka!!

“MPLAB-Autonomous-Code Rev2” is fine. MPLAB 7.2 is NOT…

I got the same flashing “Output” window, and then nothing.

Upgrade to at Least MPLAB 7.5.

It might be possible to copy the “VexCode-2008” Work Space and Project over to the “MPLAB-Autonomous-Code Rev2” and add the correct files, but that will take a little more time.

I will answer you other questions very shortly… :wink:

GOOD catch, it opens great now!!! :smiley: I updated to version 8.10

Great

Thanks

Technic-R-C

I downloaded the “Elevation - Appendix D (Programming Guide)” and unziped the “MPLAB-Autonomous-Code Rev2.zip” file (into my VEX Work Directory, but that should not matter). Both the WorkSpace and the Project both worked fine. I wonder if there is an issue with your MPLAB v7.20. I would backup your MPLAB 7.20 and Download MPLAB 7.50, and install it.

The WorkSpace is the Integrated Development Environment’s (IDE’s) Configuration for a Specific “Project”. The Configuration being, How Many Child Windows are Open, where on the Parent Window they are located, and if they are Minimized or not.
The Project is which Source Code Files are being used to make a Program Image, that is then Downloaded to the Vex Controller. The Project File (e.g. VexUserCode.mcp) is specific to the MPLAB IDE, but the Project File concept is used for all kinds of Development Systems.

That sounds reasonable… Can you Compile and Link with no Errors or Warnings??
The Work Space and Project from the VexCode-2008 seems to work with MPLAB v7.20, but the Work Space and Project from the MPLAB-Autonomous-Code Rev2 seems to NOT work with MPLAB v7.20, but WILL work with MPLAB v7.50.

I have not done a File By File compare, but that seems to be the Main Reason. Look at the Last Page of the PDF, the Vex_2008_library.lib provides 4 Different Modes, depending on if there is Jumpers on Interrupts 5 & 6. That is Brand New to the Vex Competitions.

It seems to be…

See description of Workspace and Project above.

Any of the Vex Libraries should let you run the motors.

IIRC, the Generate_Pwms() is used for you the User to Generate the PWM Pulses yourself from the User Processor, rather than let the Master Processor generate the PWM Pulses.

It might be, it also might be a “bug” or MPLAB v7.20… Testing with MPLAB v7.50 and v8.10, if I loaded the Work Space or the Project, it still showed the .mcw in the Project Window.

I hope I have answered most your questions…

Glad that was it…

Once you save the Work Space and Project with MPLAB v8.10, you won’t be able to load the Work Space and Project with MPLAB v7.50.

That makes sense

Yes I can compile without any errors and it all works great now

So how would I make a motor run forward if a limit switch is pressed, i’m having issues with this code in mplab…



#include "ifi_aliases.h"
#include "ifi_default.h"
#include "ifi_utilities.h"
#include "user_routines.h"
#include "printf_lib.h"
#include "ifi_picdefs.h"
#include "delays.h"

void startcode(void)
{ 
	printf("First Project");
	while(1)
	{
		if (IO3 = 0)
		{
			Generate_Pwms(1, 127);  
		}
		else
		{
			Generate_Pwms(1, 255);
		}
	}
}

error: Error [1203] too few arguments in function call after Generate_Pwms(1, 127); command

By the way how do you use the wait command in MPLAB, i’ve looked at the delay.h header file but it didn’t help much

Yeah it most likely is…

I appreciate it!!! :smiley:

Another question:

when I saved my project and tried loading the hex file to the microcontroller the controller was verified however a message in the bottom left of the IFI loader came up and stated

Do you know what this message means?
edit: This morning it worked fine… but for future reference do you know what this means?
Thanks

Technic-R-C

Any ideas of motor control with MPLAB, I tried the best I could to make sense of the sample source code but to no avail…

Technic-R-C

P.S code below

It should be Straight Forward…

I will post a simple example…

and yes, please do post your code.

Thats what i thought, guess not :confused:

That’d be great

It is posted in a post below and also at the bottom of this post


#include "ifi_aliases.h"
#include "ifi_default.h"
#include "ifi_utilities.h"
#include "user_routines.h"
#include "printf_lib.h"
#include "ifi_picdefs.h"
#include "delays.h"

void startcode(void)
{ 

// if sensor is pressed the motor should turn

	printf("First Project");
	while(1)
	{
		if (IO3 = 0)
		{
			Generate_Pwms(1, 127);  
		}
		else
		{
			Generate_Pwms(1, 255);
		}
	}
}

error: Error [1203] too few arguments in function call after Generate_Pwms(1, 127); command

I have some comments. I will post them a little later…

I guess I should reiterate that what is simple in EasyC and what is simple in MPLAB and MCC18 will look different.

EasyC hides many things from you, so as to make it less confusing and overwhelming.

Your Code Below looks a little thin. Can you include the Project File as well??

On the Error Message:

If you use the “Edit–>Find in Files”, and Search for “Generate_Pwms”, you will find the Definition in the file “ifi_utilities.h”:


  /* located in vex_library.lib */
void Generate_Pwms(unsigned char pwm_1,unsigned char pwm_2,
                   unsigned char pwm_3,unsigned char pwm_4,
                   unsigned char pwm_5,unsigned char pwm_6,
                   unsigned char pwm_7,unsigned char pwm_8);

It appears that you need to send Values for ALL 8 of the PWM Outputs, and the same time.

You can start with the VEX Starter Code, and then remove some items, but it much harder to start from scratch and work your way up to a compiling program.

I will post a simple EasyC Program and the equivalent in the straight MCC18. It might take a little bit to trim it down, but I hope this will give you something to work with.

Ok so I got a motor to move with the command

void User_Initialization (void)
{
	while(1)
	{
		printf("start");
		Generate_Pwms(255, 127, 127, 127, 127, 127, 127, 127);
		printf("end");
	}
}

However I could not get the code to delay for 1000 miliseconds and reverse directions because I do not know how to delay… The delay.h file does NOT help due to the fact that all the variables, to me, are impossible to understand. :eek: Can someone shine some light on my problem. If only it was as easy as EASYC Wait command…

Technic-R-C

Sure, for Quick and Dirty delay, use the Functions:

 *         Delay1TCY()
 *               Delay10TCY()  // 17Cxx only
 *               Delay10TCYx()
 *               Delay100TCYx()
 *               Delay1KTCYx()
 *               Delay10KTCYx()

in the file “delay.h”, which is part of the Vex Starter Code.

The delay of “Delay1TCY()” is a NOP (No Operation), Machine Language Instruction, which should be 1 Machine Cycle in time.
Each is additional function is 10 Times longer, if the Value of ‘1’ is passed to the function.
Determining the amount of Machine Cycles in one Second, will determine which delay function to use and what value to pass to it. These Delays just Waste Time by delaying your program by running a loop.

Since the Info on the Vex Robotics Microcontroller says it is 10 Million Instructions Per Second (MIPS). Calling the function “Delay10KTCYx(PARAM_SCLASS unsigned char);” with a Value of Zero (0), should result in a Delay of 2,560,000 cycles, or just over 1/4 (.25) Seconds.

void User_Initialization (void)
{
    while(1)
    {
        printf("start");
        Generate_Pwms(255, 127, 127, 127, 127, 127, 127, 127);
        Delay10KTCYx(0); // Delay ~ .25 Seconds
        Delay10KTCYx(0); // Delay ~ .25 Seconds
        Delay10KTCYx(0); // Delay ~ .25 Seconds
        Delay10KTCYx(0); // Delay ~ .25 Seconds
        Generate_Pwms(127, 127, 127, 127, 127, 127, 127, 127);
        printf("end");
    }
}

The Master Processor acts as a Watchdog timer, and if the Delay functions don’t communicate with the Master Processor, your code might be “hung” or “reset”. You might have to place a call to:


  Getdata(&rxdata);   /* Get fresh data from the master microprocessor. */

in between some or all the “Delay10KTCYx” calls.

A more efficient use of processing power is to use a Timer. You can look at how to use a Timer with this document, Timers White Paper.

I am adding to the Vex On-Line Controller Code v2.x, support for the Wait() function, but a better way is a Wait Flag. I will put an example of that on my Programming Examples list too. :wink:

Thanks for the very detailed info, but once I started looking into timers, I find them much easier and more accurate to use plus I had trouble getting the code to work.

WOW!!!, timers are GREAT :eek:, to tell you the truth I didn’t know the details about interrupts until I read the pdf. These will make life so much easier. I’m still looking into incorporating them into my code but with the detailed pdf file that should not be a problem. :smiley:

Thats great

Quick questions:

When the one second mark, two second, etc. has passed from the timer how would I access the amount of time that has passed by the timer and apply it to a variable in the normal code (new source file, referenced below)?

I do not want to write code in the user_routines.c file due to the excessive amount of code in there already (don’t know wat to delete or keep). I know that I can create a new .c source file but how can I make the code inside that source file to execute? Do I have to call the new source files funtion in the User Initialization potion of the user_routines.c code?

Thanks again

Technic-R-C

The joy of getting something to work in MPLAB is unbelievable (BUILD SUCCEEDED!!!)

Technic-R-C;

You keep revising your posts. Just when I think of something to reply to, you add more. :wink:

I have been slowed down getting back to you, because I have been working on some helps for a Vex Mentor who is wanting to introduce Programming the Vex to Middle School students. Plus the daily work related things…

Ooops sorry about that :o, for every question that I ask I want the question to be worth your time by actually asking something that is very necessary to my current journey through the swamps and bogs of MPLAB. Usually, that is why after I ask a question I tend to change it to better help me solve my current issue. I’ll try my best to post the final questions without revisions.

No problem, take your time, as long as they get answered in the next year or so I’ll be good :smiley: The Elevation competition is on the 6 of December, so I would like to write a working code by that time.

Thanks for the help! :slight_smile:

Technic-R-C