|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools |
Rating:
|
Display Modes |
|
|
|
#1
|
|||
|
|||
|
Programming Vex w/ MPLab
To program the Vex robot for this coming year you will need to buy a programming module (which aren't coming out until mid-august) or to make your own. The software that is going to be put out for programming it is called easyC which is very similar to FLL block programming. This is, for the time being, the only way officially supported for vex programming. EasyC installs in all the libraries and files that you will need to program in MPLab though. It installs the mcc18 compiler under easyC\mcc18\ (imagine that) and all the libs, headers, objects, and linkers under easyC\VeX\.
In order to program in MPLab, you will need to start by creating a new project under Project\Project Wizard and choose PIC18f8520 as your device. This can be found by checking the default linker script found in easyC\VeX\Linker\18f8520user.lkr. Next you must choose microchip C18 ToolSuite. Any tools in the content window with an X next to it should be found in easyC\MCC18. Then choose a name for your project and place to save it. (It is almost always good to keep projects in MPLab very close to your hard drive root directory because it refuses to compile files with location names longer than (62 chars?)) Then add UserAPI.h from easyC\UserAPI\ to the headers in your project. Do the same with 18f8520user.lkr, all the object files, and Vex_library.lib. Everything should be configured correctly now, but there is one more catch. Before you can start coding your main function you must implement void IO_Initialization() with DefineControllerIO(4, etc...). EasyC puts this implementation in $projname + IO.c and the main function implementation in $projectname + .c. The 4 refers to how many of the first inputs are analog, and the rest are 16 1s for input or 0s for output. With all this done, your project should compile perfectly and then just use the ifi vex loader supplied with easyC or downloaded from http://www.vexlabs.com/vex-robotics-downloads.shtml. Brad Miller should be putting up his own library for programming the VeX robots on http://sf.net at some point which is similar but more advanced than the one provided by easyC and will remove any reliance on easyC. Last edited by dababyjebus : 21-07-2005 at 19:51. |
|
#2
|
|||
|
|||
|
Re: Programming Vex w/ MPLab
actually there is information on the vexlabs download about ordering a prototype programmer. there are also downloads of the code for the robot and a simplified source code file which may be modified, compiled with mcc18 and loaded to the vex controller.
it's not hard. i've done it my own self. even without the programmer the simplified source file is useful to understand how the vex kit uses its hardware resources. of course, without the prorammer, who really cares. it's a worthwhile investment at $99, and comes with the cbot environment that i guess is used in the first program. |
|
#3
|
||||
|
||||
|
Re: Programming Vex w/ MPLab
Quote:
I couldn't agree more! I didn't have to jump through all the hoops mentioned by dababyjebus, but then again, I was not using Easy-C. I just used the exact same tools I used for FRC in 2005 with the exception of the newer IFI Loader. You can set anywhere from 0 to 16 channels as Analog inputs, with 2 being the default. Look through the default code, you will see what I mean. |
|
#4
|
|||
|
|||
|
Re: Programming Vex w/ MPLab
yes, its true that you can download the simplified vex source code which is essentially the same as the FRC code from vexlabs, but the purpose of my post was to show how to get mplab to work with the wrapper library of easyC. Radioshack decided that the "simplified vex code" was still too complex for the user base that they were trying to reach with vex and contracted intelitek to create easyC. It does much the same thing as the FRCish code, but is much simpler and easier to code with. The library that Brad is working on is very similar except with a few more advanced features. It really doesn't matter at all which code or libraries one uses -- to each his own.
|
|
#5
|
|||
|
|||
|
Re: Programming Vex w/ MPLab
so are there any further details? project name?
the default code does seem a little weird to me. they seem to use only two interrupts, the spi to communicate between the user and master controllers and timer0 which is used only to keep the pwm generating code from running at the same time as the master and user are doing their communicating. this means that the pwm sisgnals are generated in a timing loop that eats up two out of every 18.5ms. there is not, however, a whole lot of information available as to how this stuff happens. some nice well documented libraries would not be so painful to have. Last edited by foobert : 22-07-2005 at 00:08. Reason: flaky markup |
|
#6
|
||||
|
||||
|
Re: Programming Vex w/ MPLab
First, a big THANKS for this thread. I was able to set up the MPLAB IDE and start programming without too much effort. Well done!
At first, without knowing anything else about the VEX uController I used the displayed C code from a simple EasyC program as a model and wrote my own main() routine in MPLAB, compiled, linked, (using the supplied user_routines.o and user_routines_fast.o) and downloaded it to the robot. It ran as expected. After that, I continued exploring the message threads and found that another approach is to not use your own main() but instead use a pre-coded main() and re-implement User_Initialization(), Process_Data_From_Master_uP(), User_Autonomous_Code(), and Process_Data_From_Local_IO(). Could someone please compare and contrast these two approaches? From what I have read, using the later approach you can have code that is limited in how often it is executed by the Master uP data transfer verses code that isn't. What does that mean when I use the former approach and place all of my code inside my own main() routine? Is there a lot of overhead making multiple GetRxInput() and SetPWM() calls from my main()? Thanks! |
|
#7
|
||||
|
||||
|
Re: Programming Vex w/ MPLab
I am using MPLAB 7.31 and using all the bin executables that came with the CD (their Librarian: mplib.exe , Linker: mplink.exe and Compiler: mcc18.exe ) when I attempt to compile I get the message
Code:
MPLINK 3.90, Linker Copyright (c) 2004 Microchip Technology Inc. Error - Coff file 'C:MCC18lib/c018i.o' does not appear to be a valid COFF file. Errors : 1 Code:
MPLINK 3.90, Linker Copyright (c) 2004 Microchip Technology Inc. Error - Coff file 'AARG.O' does not appear to be a valid COFF file. Error - Could not build member 'AARG.O' in library file 'C:MCC18lib/clib.lib'. Errors : 2 Code:
// $Id: 18f8520i.lkr,v 1.4 2003/03/13 05:02:23 sealep Exp $ // File: 18f8520i.lkr // Sample linker script for the PIC18F8520 processor LIBPATH . //FILES c018i.o FILES clib.lib FILES p18f8520.lib I know for a fact that I had the C18 compiler already installed from other PIC stuff that I do, but I don't know if when I installed the easy-c CD if it installed over that. My question is WHY is it looking there? in 18f8520user.lkr there is reference to the file name only (clib.lib OR c018i.o, you comment out which one, by default it is clib.lib). According to the linker read me this error arises when you are reading a new COFF file with the old linker. Where can I find an old clib.lib and how can I change the reference to it? Thanks in advance. |
|
#8
|
|||||
|
|||||
|
Re: Programming Vex w/ MPLab
Check the version of C18 you have installed and are using.
e.g., C:/mcc18/README.C18 The COFF mismatch is common when attempting to use the newest version (3.0 or greater) of the C18 compiler with the IFI object files or libraries (which were compiled under the older version 2.4). There was a change in the format of the COFF with version 3 that's incompatible with the older object files. You have to use C18 version 2.4 (or earlier). |
|
#9
|
||||
|
||||
|
Re: Programming Vex w/ MPLab
Well, the C18 compiler in C:\mcc18 is version :
Release Notes for MPLAB(R) C18, PICmicro(R) 18Cxx C Compiler v3.02 3 February 2006 But I tell MPLAB to use the tools in C:\Program Files\Intelitek\easyC\Mcc18\bin |
|
#10
|
|||||
|
|||||
|
Re: Programming Vex w/ MPLab
I see, so you are using the v2.4 compiler under the easyC directory but pulling the object file 'C:MCC18lib/c018i.o' from the newer version 3.02 directory which will give you the mismatched COFF error. Your MCC18lib environment variable might be set from installing the 3.02 compiler.
In MPLAB under Project -> Build Options... -> Project what paths do you have for Include and Library? Are they set to: C:\Program Files\Intelitek\easyC\Mcc18\h and C:\Program Files\Intelitek\easyC\Mcc18\lib You'll find older versions of both clib.lib and c018i.o under the easyC/Mcc18/lib directory. Last edited by Mark McLeod : 13-04-2006 at 17:23. |
|
#11
|
||||
|
||||
|
Re: Programming Vex w/ MPLab
Your help is much appreciated, it works fantastically.
|
|
#12
|
|||
|
|||
|
Re: Programming Vex w/ MPLab
Hi all! I just got started programing with vex, and quickly decided to use MPLab because I have some programming experience. I got everything set up following the directions in the first post, but keep getting compile errors:
Executing: "C:\Program Files\Microchip\MPASM Suite\MPLink.exe" /l"C:\Program Files\Intelitek\easyC\Mcc18\lib" "C:\Program Files\Intelitek\easyC\VeX\Linker\18f8520user.lkr" "N:\MPLab\Test.o" "C:\Program Files\Intelitek\easyC\VeX\Object\ifi_startup.o" "C:\Program Files\Intelitek\easyC\VeX\Object\ifi_utilities.o" "C:\Program Files\Intelitek\easyC\VeX\Object\interrupts.o" "C:\Program Files\Intelitek\easyC\VeX\Object\printf_lib.o" "C:\Program Files\Intelitek\easyC\VeX\Object\Start.o" "C:\Program Files\Intelitek\easyC\VeX\Object\user_api.o" "C:\Program Files\Intelitek\easyC\VeX\Object\user_routines.o" "C:\Program Files\Intelitek\easyC\VeX\Object\user_routines_fas t.o" "C:\Program Files\Intelitek\easyC\VeX\Library\Vex_library.lib" /m"Vex Test.map" /o"Vex Test.cof" MPLINK 4.02, Linker Copyright (c) 2006 Microchip Technology Inc. Error - Coff file format for 'N:\MPLab\Test.o' is out of date. Errors : 1 Why is the format for Test.o out of date, and how do I fix this (the main file is named test.c)? Thank you! |
|
#13
|
|||
|
|||
|
Re: Programming Vex w/ MPLab
I'm having a bit of trouble getting this to work.
I set up a new project with the project wizard: Device: PIC18F8520 Active Toolsuite: Microchip C18 Toolsuite MPSAM Assembler: C:\Program Files\Microchip\MPASM Suite\MPAsmWin.exe MPLINK Object Linker: C:\Program Files\Intelitek\easyC\Mcc18\bin\mplink.exe MPLAB C18 Compiler: C:\Program Files\Intelitek\easyC\Mcc18\bin\mcc18.exe MPLIB Librarian: C:\Program Files\Intelitek\easyC\Mcc18\bin\mplib.exe Project Name: Vex Controller Project Directory: C:\Documents and Settings\W4TK3\VexControllerProject and I imported all the files from Vex Starter Code @ http://www.vexlabs.com/vex-robotics-downloads.shtml I get the following output when I go to project>build all: Code:
Clean: Deleting intermediary and output files. Clean: Deleted file "C:\Documents and Settings\W4TK3\VexControllerProject\Vex Controller.mcs". Clean: Done. Executing: "C:\Program Files\Microchip\MPASM Suite\MPAsmWin.exe" /q /p18F8520 "asm_lib.asm" /l"asm_lib.lst" /e"asm_lib.err" /o"asm_lib.o" Executing: "C:\Program Files\Intelitek\easyC\Mcc18\bin\mcc18.exe" -p=18F8520 "ifi_startup.c" -fo="ifi_startup.o" -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- MPLAB C18 v2.40 (feature limited) Copyright 1999-2004 Microchip Technology Inc. This version of MPLAB C18 does not support the extended mode and will not perform all optimizations. To purchase a full copy of MPLAB C18, please contact your local distributor or visit buy.microchip.com. Executing: "C:\Program Files\Intelitek\easyC\Mcc18\bin\mcc18.exe" -p=18F8520 "ifi_utilities.c" -fo="ifi_utilities.o" -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- C:\Documents and Settings\W4TK3\VexControllerProject\ifi_utilities.c:15:Error [1027] unable to locate 'usart.h' C:\Documents and Settings\W4TK3\VexControllerProject\ifi_utilities.c:16:Error [1027] unable to locate 'spi.h' C:\Documents and Settings\W4TK3\VexControllerProject\ifi_utilities.c:17:Error [1027] unable to locate 'adc.h' C:\Documents and Settings\W4TK3\VexControllerProject\ifi_utilities.c:18:Error [1027] unable to locate 'capture.h' C:\Documents and Settings\W4TK3\VexControllerProject\ifi_utilities.c:19:Error [1027] unable to locate 'timers.h' C:\Documents and Settings\W4TK3\VexControllerProject\ifi_utilities.c:20:Error [1027] unable to locate 'string.h' C:\Documents and Settings\W4TK3\VexControllerProject\ifi_utilities.c:21:Error [1027] unable to locate 'pwm.h' C:\Documents and Settings\W4TK3\VexControllerProject\ifi_aliases.h:18:Error [1027] unable to locate 'adc.h' MPLAB C18 v2.40 (feature limited) Copyright 1999-2004 Microchip Technology Inc. This version of MPLAB C18 does not support the extended mode and will not perform all optimizations. To purchase a full copy of MPLAB C18, please contact your local distributor or visit buy.microchip.com. Halting build on first failure as requested. BUILD FAILED: Sat May 13 10:54:45 2006 Last edited by W4TK3 : 13-05-2006 at 11:17. Reason: inadvertantly pressed enter |
|
#14
|
|||||
|
|||||
|
Re: Programming Vex w/ MPLab
Quote:
The MPLAB checks to make shown in post #10 should help. |
|
#15
|
|||
|
|||
|
Re: Programming Vex w/ MPLab
Quote:
Code:
Clean: Deleting intermediary and output files. Clean: Done. Executing: "C:\Program Files\Microchip\MPASM Suite\MPAsmWin.exe" /q /p18F8520 "asm_lib.asm" /l"asm_lib.lst" /e"asm_lib.err" /o"asm_lib.o" Executing: "C:\Program Files\Intelitek\easyC\Mcc18\bin\mcc18.exe" -p=18F8520 /i"C:\Program Files\Intelitek\easyC\Mcc18\h" "ifi_startup.c" -fo="ifi_startup.o" -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- MPLAB C18 v2.40 (feature limited) Copyright 1999-2004 Microchip Technology Inc. This version of MPLAB C18 does not support the extended mode and will not perform all optimizations. To purchase a full copy of MPLAB C18, please contact your local distributor or visit buy.microchip.com. Executing: "C:\Program Files\Intelitek\easyC\Mcc18\bin\mcc18.exe" -p=18F8520 /i"C:\Program Files\Intelitek\easyC\Mcc18\h" "ifi_utilities.c" -fo="ifi_utilities.o" -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- MPLAB C18 v2.40 (feature limited) Copyright 1999-2004 Microchip Technology Inc. This version of MPLAB C18 does not support the extended mode and will not perform all optimizations. To purchase a full copy of MPLAB C18, please contact your local distributor or visit buy.microchip.com. Executing: "C:\Program Files\Intelitek\easyC\Mcc18\bin\mcc18.exe" -p=18F8520 /i"C:\Program Files\Intelitek\easyC\Mcc18\h" "main.c" -fo="main.o" -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- MPLAB C18 v2.40 (feature limited) Copyright 1999-2004 Microchip Technology Inc. This version of MPLAB C18 does not support the extended mode and will not perform all optimizations. To purchase a full copy of MPLAB C18, please contact your local distributor or visit buy.microchip.com. Executing: "C:\Program Files\Intelitek\easyC\Mcc18\bin\mcc18.exe" -p=18F8520 /i"C:\Program Files\Intelitek\easyC\Mcc18\h" "PicSerialDrv.c" -fo="PicSerialDrv.o" -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- MPLAB C18 v2.40 (feature limited) Copyright 1999-2004 Microchip Technology Inc. This version of MPLAB C18 does not support the extended mode and will not perform all optimizations. To purchase a full copy of MPLAB C18, please contact your local distributor or visit buy.microchip.com. Executing: "C:\Program Files\Intelitek\easyC\Mcc18\bin\mcc18.exe" -p=18F8520 /i"C:\Program Files\Intelitek\easyC\Mcc18\h" "printf_lib.c" -fo="printf_lib.o" -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- MPLAB C18 v2.40 (feature limited) Copyright 1999-2004 Microchip Technology Inc. This version of MPLAB C18 does not support the extended mode and will not perform all optimizations. To purchase a full copy of MPLAB C18, please contact your local distributor or visit buy.microchip.com. Executing: "C:\Program Files\Intelitek\easyC\Mcc18\bin\mcc18.exe" -p=18F8520 /i"C:\Program Files\Intelitek\easyC\Mcc18\h" "user_routines.c" -fo="user_routines.o" -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- MPLAB C18 v2.40 (feature limited) Copyright 1999-2004 Microchip Technology Inc. This version of MPLAB C18 does not support the extended mode and will not perform all optimizations. To purchase a full copy of MPLAB C18, please contact your local distributor or visit buy.microchip.com. Executing: "C:\Program Files\Intelitek\easyC\Mcc18\bin\mcc18.exe" -p=18F8520 /i"C:\Program Files\Intelitek\easyC\Mcc18\h" "user_routines_DDT.c" -fo="user_routines_DDT.o" -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- MPLAB C18 v2.40 (feature limited) Copyright 1999-2004 Microchip Technology Inc. This version of MPLAB C18 does not support the extended mode and will not perform all optimizations. To purchase a full copy of MPLAB C18, please contact your local distributor or visit buy.microchip.com. Executing: "C:\Program Files\Intelitek\easyC\Mcc18\bin\mcc18.exe" -p=18F8520 /i"C:\Program Files\Intelitek\easyC\Mcc18\h" "user_routines_fast.c" -fo="user_routines_fast.o" -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- MPLAB C18 v2.40 (feature limited) Copyright 1999-2004 Microchip Technology Inc. This version of MPLAB C18 does not support the extended mode and will not perform all optimizations. To purchase a full copy of MPLAB C18, please contact your local distributor or visit buy.microchip.com. Executing: "C:\Program Files\Intelitek\easyC\Mcc18\bin\mcc18.exe" -p=18F8520 /i"C:\Program Files\Intelitek\easyC\Mcc18\h" "user_routines_fast_DDT.c" -fo="user_routines_fast_DDT.o" -Ou- -Ot- -Ob- -Op- -Or- -Od- -Opa- MPLAB C18 v2.40 (feature limited) Copyright 1999-2004 Microchip Technology Inc. This version of MPLAB C18 does not support the extended mode and will not perform all optimizations. To purchase a full copy of MPLAB C18, please contact your local distributor or visit buy.microchip.com. Executing: "C:\Program Files\Intelitek\easyC\Mcc18\bin\mplink.exe" /l"C:\Program Files\Intelitek\easyC\Mcc18\lib" "C:\Documents and Settings\W4TK3\VexControllerProject\18f8520user.lkr" "C:\Documents and Settings\W4TK3\VexControllerProject\ifi_utilities.o" "C:\Documents and Settings\W4TK3\VexControllerProject\main.o" "C:\Documents and Settings\W4TK3\VexControllerProject\PicSerialDrv.o" "C:\Documents and Settings\W4TK3\VexControllerProject\printf_lib.o" "C:\Documents and Settings\W4TK3\VexControllerProject\user_routines.o" "C:\Documents and Settings\W4TK3\VexControllerProject\user_routines_DDT.o" "C:\Documents and Settings\W4TK3\VexControllerProject\user_routines_fast.o" "C:\Documents and Settings\W4TK3\VexControllerProject\user_routines_fast_DDT.o" "C:\Documents and Settings\W4TK3\VexControllerProject\asm_lib.o" "C:\Documents and Settings\W4TK3\VexControllerProject\ifi_startup.o" "C:\Documents and Settings\W4TK3\Ve xControllerProject\Vex_alltimers.lib" "C:\Documents and Settings\W4TK3\VexControllerProject\Vex_alltimers_auton_debug.lib" "C:\Documents and Settings\W4TK3\VexControllerProject\Vex_alltimers_competition.lib" "C:\Documents and Settings\W4TK3\VexControllerProject\Vex_library.lib" "C:\Documents and Settings\W4TK3\VexControllerProject\Vex_library_auton_debug.lib" "C:\Documents and Settings\W4TK3\VexControllerProject\Vex_library_competition.lib" /o"Vex Controller.cof" /M"Vex Controller.map" MPLINK 3.90, Linker Copyright (c) 2004 Microchip Technology Inc. Error - Coff file 'C:\Documents and Settings\W4TK3\VexControllerProject\asm_lib.o' does not appear to be a valid COFF file. Errors : 1 BUILD FAILED: Sat May 13 18:06:02 2006 |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to build a VEX programming module | bblack7489 | FIRST Tech Challenge | 78 | 09-06-2011 16:03 |
| Programming - Getting Started | Mark McLeod | Programming | 80 | 16-04-2008 23:37 |
| VEX programming | Gene F | Programming | 14 | 08-08-2006 22:21 |
| Vex bot programming Q's | BaldwinNYRookie | Programming | 6 | 09-10-2005 17:45 |
| Vex Programming | foobert | FIRST Tech Challenge | 3 | 24-06-2005 01:09 |