View unanswered posts | View active topics It is currently Fri May 29, 2015 2:29 pm

Reply to topic  [ 5 posts ] 
On board RAM 
Author Message

Joined: Sat Feb 17, 2007 11:51 pm
Posts: 2
Post On board RAM
I am currently working on a school project using RobotC and Vex. The premise of the project is that we are building a robot to search through a destroyed building.

I was hoping to write a code section that would enable the robot to detect if signal was lost to the controller and then backtrack till it regains signal.

I would do this by keeping logs of motor output (power,duration) and checking time since the last radio signal was received. I think that I would need 2 short int. variables for each entry and the log would just roll over.

Does anyone know how much RAM the Vex controller has that I could access for this purpose?

Last edited by pingviini on Wed May 09, 2007 5:08 pm, edited 1 time in total.

Tue May 08, 2007 7:49 pm
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:44 am
Posts: 441
Location: Pittsburgh, PA
Here is a link to a good page about the VEX controller. It lists all of the specs of the controller:

From that site, it says that:
Variable Space = 1800 bytes + 1024 bytes EE2
Program Space = 32K

I hope this helps! :)

Vu Nguyen
Software Training Development Team | Webmaster
Need more support? Email ROBOTC Support at to put in a support ticket| Robomatter Store | Robotics Academy | CS2N

Wed May 09, 2007 8:17 am

Joined: Fri Feb 09, 2007 9:21 am
Posts: 616
This sounds like a terrific little program. Good luck on it!

Here's some pointers on how you might want to write it.

Use a array to hold the most recent motor positions and time. Then use an index into the array so that it can behave like a "circular buffer". Say for example, if the array has 50 entries, then it would be indexed by 0 to 49. Every time you write a new entry to the array, you increment an index value to store the item you want. If the new index value is 50 (or higher) then it has "wrapped around" and you set the index to 0.

VU has accurate posted the amount of memory available. This is not all available to user programs. Some of it is used by internal variables, stacks and buffers. The amount of memory available to user programs is found from the following entries in the file "limitDefinitionsViaDefines.h" as
  #define kNumbOfTasks                  ((ubyte) 4)
  #define kNumbOfGlobalVariables        ((uword) 100)
  #define kNumbOfPrograms               ((ubyte) 1)
  #define kNumbOfTaskVariables          ((uword) 0)
  #define kNumbOfRealSensors            ((ubyte) 16)
  #define kNumbOfRealMotors             ((ubyte) 8)
  #define kNumbOfVirtualSensors         ((ubyte) 0)
  #define kNumbOfVirtualMotors          ((ubyte) 0)
  #define kTaskVariablesStart           ((uword) 40)

From above, there is room for 100 user defined variables (each variable is 16 bits).
You probably want to store the power setttings for two motors. You could define two arrays for this. Or you could pack both motor settings in a single 16-bit word since the value for each motor only ranges from -128 to +127. Here pseudo code to do this

int nCombinedPower

// Pack two motor settings in one word

nCombinedPower = (128 + powerA) * 256 + (128 + powerB)

// Unpack motor settings

powerA = (nCombinedPower / 256);
powerB = (nCombinedPower & 0x00FF) - 128;

Wed May 09, 2007 12:00 pm

Joined: Sat Feb 17, 2007 11:51 pm
Posts: 2
Post Would it be better to use pointers?
After thinking about this for some time, I like the suggestions everybody has made.

To preface: I think that the controls to the robot will consist of the x_axis right stick and y_axis left stick. I want to limit the driver to either turning or going forward, but not both at the same time.

That way each data point would be one byte:

- first bit would indicate x-axis movement or y-axis movement
- next three bits would be encoded as { axis-movement/16 + 8 } || -127 < axis-movement < 127 ||
- the remaining bits would be the number of 250Msec ticks that the above three bits remained the same.

I would store these bytes by using an array of char's (I think the standard is >= 8 bits).

I would compress the value of axis-movement by a factor of 16.
I am going to write a quick version of this that would just control the robot directly to see how my driver reacts to loosing that much responsiveness, but I think it will be necessary to have the same input regardless if it is live datat or just being fed off the stored points.

I want to fiddle around with how often I do a data tick, but I think 250Msecs is a good start.

At the rate of 2 data points per word and with 100 words, I would get 200 data points or 50 seconds worth of data, which I think is about ideal.

Do you think that I am compressing the data too much?

Wed May 09, 2007 9:49 pm

Joined: Fri Nov 21, 2008 12:05 am
Posts: 4
Post Re: On board RAM
Simple (perhaps very dumb) question: How does one declare an array in RobotC? What is the syntax?


Mon Dec 08, 2008 10:49 pm
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.