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?
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.
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)
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!
“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 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.
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!!!
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
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.
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…
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.
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.
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.
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!!!)
You keep revising your posts. Just when I think of something to reply to, you add more.
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 The Elevation competition is on the 6 of December, so I would like to write a working code by that time.