Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   WPIlib beta for VEX (http://www.chiefdelphi.com/forums/showthread.php?t=49305)

Kurt Jensen 05-10-2006 01:44

WPIlib beta for VEX
 
Hi,
I downloaded the Beta version of WPILIB for vex found at
http://users.wpi.edu/~bamiller/WPILib/WPILib060719.zip
during early October 2006. I got it to only sort of work.

Using a mingw makefile and calling the microchip compiler that comes with easyc 1.1 and the vanilla vex programming kit, along with the version of the
makefile that Jeff Garbers had posted awhile back, I managed to get his example to compile, link, download and run motors- so far so good.

I then modified that makefile to point to a directory with the contents of WPILib060719.zip as follows:

#
# makefile to build manually-edited VeX C code using tools from easyC
#
# Originally hacked together by Jeff Garbers (jgarbers@mindspring.com)
# Attempted tweak for use with WPILib for Vex by Kurt Jensen
#


# Project name - this MUST be the name of your primary .C file. If you only
# have one C source module, this should be the only thing you'll need to edit
# to customize this makefile.

PROJ = cvexsample

# Desired project object files - add additional names of source modules here
# if you have split your project into multiple .c files.
#
# Example:
#
# PROJOBJS = $(PROJ).o our_subs.o control_stuff.o

PROJOBJS = $(PROJ).o

# Extra files generated by the compiler; we delete these on a "clean".

BYPRODUCTS = $(PROJ).cod $(PROJ).lst $(PROJ)

# Tool locations. Edit as necessary per your installation; theoretically the
# first one (root directory for easyC installation) should be all you'd need
# to change.
#
# NOTE use of the short pathname "progra~1" instead of "Program Files"
# to avoid problems with spaces and quotes.

EC = c:/progra~1/Intelitek/easyC

MCC18 = $(EC)/mcc18
CXX= $(MCC18)/bin/mcc18.exe
MPLINK= $(MCC18)/bin/mplink.exe
ILOADER= $(EC)/loader/iLoader.exe

# Directories where we look for libraries, header files, and such. Again, unless
# you've moved things around here these definitions should work for you.

MCC18LIB = $(MCC18)/lib
MCC18H = $(MCC18)/h

#VEX = $(EC)/VeX
#VEXOBJ = $(VEX)/Object
#VEXLIB = $(VEX)/Library


# We use the double-backslashes here because MP3LINK doesn't like the forward slashes
# in the link script name, and the linker script lives here...

WPILIB= C:\\Projects\\Vex\\WPIlib

# VeX-stock object files and library as included by easyC.

VEXOBJS = ifi_startup.o ifi_utilities.o printf_lib.o Start.o user_routines.o \
interrupts.o user_routines_fast.o user_api.o
VEXLIBS = Vex_alltimers.lib

WPILIBS = Vex_library.lib WPILibVex.lib

# Compiler flags

CXXFLAGS = -p18F8520 -i$(MCC18H) -i$(WPILIB) -i$(VEX)/UserAPI/ -Oi+

# Linker flags and script

LINKFLAGS = -l$(MCC18LIB) -l$(WPILIB) -o$(PROJ)
LINKSCRIPT = $(WPILIB)\\18f8520.lkr

# Target definition.

TARGET = $(PROJ).hex

# --------------------------------------------------------------------
# Rules start here
# --------------------------------------------------------------------

.c.o:
$(CXX) $(CXXFLAGS) $<

all: $(TARGET)

dl: $(TARGET)
$(ILOADER) /D=$(TARGET) /H /T

clean :
rm -f $(TARGET) $(PROJOBJS) $(BYPRODUCTS)


$(TARGET) : $(PROJOBJS)
$(MPLINK) $(LINKFLAGS) $(LINKSCRIPT) $(PROJOBJS) $(WPILIBS)

This has allowed me to compile and link with no complaints from the microchip compiler. I believe the linker is no longer looking at the libraries originally from vex, but only at the WPIlib libraries and object files. I then compile this code, and download it to the vex controller:

#define _VEX_BOARD
#undef _FRC_BOARD
#include "BuiltIns.h"

void main ( void )
{

TwoWheelDrive(3, 2); // initialize 2 wheel drive
PrintToScreen("Let's Go!\n");
while ( 1 )
{
Drive(50,0);
PrintToScreen("SetPWM\n");
}
}
It runs, and the text output can be seen in the serial terminal window in the downloader application, just as you would expect from the code. However, the motors just do not get any power. I tried calling SetPWM() in a similar fashion with no luck there either.

As a pot-shot, I tried adding this to the c source:

void IO_Initialization(void)
{
DefineControllerIO ( 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 ) ;
}
There are 17 parameters in this call, and it compiles in Jeff Garber's example. The WPIlib prototype for this function seems to takes 18 parameters. I added another 0 into the parameter list, recompiled and downloaded, and got the same result - good serial communications back to the downloader window, but no motors.

I must just be missing something here, but I'm not sure what. Any advice regarding what I might be doing wrong would be appreciated.

Thanks to you guys putting this stuff out for guys like me to use. Your efforts are appreciated!

-Kurt


All times are GMT -5. The time now is 13:49.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi