This would be for Easy C, 1.x , 2.x, or 3.x??
Remember that EasyC is just a Drag and Drop User Interface, that creates a “proper” ‘C’ source Code file and Header File that is “compiled and linked” by the mcc18 compiler using a “makefile”.
I have not tried this yet, So MAKE BACKUPS!!!
It appears that the UserAPI.h is “Hard Coded” into the Easy C Project for EasyC 1.x. and IIRC EasyC 2.x. Not sure about EasyC 3.x (Pro Version). But, the UserAPI.h is just a regular “.h” file, it should be possible to ADD definitions to it, or better yet, Add “#includes” to it that have your custom definitions in it…
Possibly… (Also, Floating Point math on the PIC Processor is REAL SLOW, be very careful, you might get your Vex Controller “running” TOO SLOW)
Sin, Cos, Tan are defined in the math.h file, (in the “h” directory under the mcc18 compiler) and in the library’s clib.lib, clib_e.lib and each of the Micro-Chip specific libraries (in the “lib” directory under the mcc18 compiler)… Depending on how the Linker works, the compiler might complain about not knowing the Definitions of Sin, Cos, Tan etc…, but the Linker still might be able to Resolve the entries in the Libraries and create a “final” output file… Of course, if you have the parameters wrong in the call to Sin, Cos, Tan etc… without the Definitions for the compiler to check, you might get some very strange results…
I would BACK UP, then Edit the UserAPI.h file with “#include <math.h>” right after the “#define user_api_h” line. UserAPI.h is located the “Intelitek\easyC\VeX\UserAPI” directory. IF, the Include files are done CORRECTLY, they will add Nothing to the size of your executable program, unless you “make a call” to a function defined in the Include File or create an Instance of a Data Type from the Include File.
For those who want to know:
Variable Space 1800 bytes + 1024 bytes EE2
Program Space 32K
(from Vex Robotics Design System - Vex Micro Controller Specifications)
Like a lot of life’s answers, It Depends…
First, the Program Space is 32,768 WORDS (16 bits for each word). All your Program Code and STATIC Variables should go in this memory.
Second, 1800 bytes (8 bits per byte) are the RAM, but IIRC some is “reserved” for the Machine “stack”.
The Depends part is CHARs take a Byte, INTEGERs take Two Bytes, SHORT LONGs are 3 Bytes, and LONGs are 4 Bytes. FLOATs (and DOUBLEs) take Four Bytes. (From the MPLAB_C18_Users_Guide_51288j.pdf, PDF page 19, Document page 11) (Also note that EasyC does not let you use all of these types) So the more LONGs and FLOATs you use in your program, the fewer total variables you can have.
(Rules of Thumb: Always use the SMALLEST variable you can get by with, if your loop is 0 to 50, use a Unsigned Char)
Third, The RAM is lost (returns to an unknown state) on power loss, but you can keep upto 1024 Bytes of data stored in the Electronically Erasable, Programmable Read-Only Memory (EEPROM or EE2), so if you run “short” of RAM space, you might be able to use the EEPROM, for storage of STATIC VALUES, you should be able to have the values placed into the main Flash… EEPROM is usually slower to access than the RAM, so there might be a Speed Penalty in your program…
Physically, It connects to the Interrupt bank of the Vex Controller. Logically, both are True! There are 90 Holes in the full 360 Degrees. So 45 Holes would be 180 Degrees and 22-23 Holes would be 90 Degrees…
(from the Inventors Guide for the Vex Robotics Optical Shaft Encoder Kit