Program help

I am coaching a team for the first time this year. We have been to one competition and have our second this weekend. We have finally got to the point of being able to run autonomous but we have the program messed up. I have two errors that I can’t figure out. If anyone can lend some assistance we would appreciate it!

Thanks in advance.
program 1.jpg

Wrong picture, this one is what the error reads.
Capture2.jpg

You are showing errors in the competition template. You should have two tasks in the code you wrote with the same names, these are normally setup for you when you create a new competition file. Something like this

task usercontrol()
{
	// User control code here, inside the loop

	while (true)
	{
	  // This is the main execution loop for the user control program. Each time through the loop
	  // your program should update motor + servo values based on feedback from the joysticks.

	  // .....................................................................................
	  // Insert user code here. This is where you use the joystick values to update your motors, etc.
	  // .....................................................................................

	  UserControlCodePlaceholderForTesting(); // Remove this function call once you have "real" code.
	}
}

Are you compiling the correct file?
Can you post your code so we can see what’s going on?

I attached the actual programs. I have three, I think these are the three that I am using. The program with the errors is not the one I am trying to compile. The program works fine with the remote attached to the robot but when we try to use the VEXnet keys it has the VEXnet and Game LED flashing red.
Competition Programnew.c (3.71 KB)




Let me check this.
edit:
You deleted the pre_auton function, add that back in.

void pre_auton()
{
  bStopTasksBetweenModes = true;
}

This is a different problem. Are you sure it’s Vexnet and Game leds? Sounds like a firmware mis-match. Which VEXnet keys do you have, black or white?

See this post and compare with your problem.
VEXnet 2.0, Oct-2014 firmware - readme

We have the white keys. When I put in the code you posted for me it takes away the two errors but then gives me

Warning:Unreferenced function ‘pre_auton’

which is a yellow X. What do I do for it?

Where do I go to update my VEXnet Keys?

So you placed that function in the file that was attached in post #4, no typos or anything?

You mentioned three programs, not sure what you meant by that. You should have one program (the one you attached was called Competition Programnew.c) this includes one file called “Vex_Competition_Includes.c” that has the main task and the competition control code - do not change Vex_Competition_Includes.c or try and compile that included file, it will give errors. The code in Vex_Competition_Includes.c will call the function pre_auton() when it first initializes and then start either usercontrol() or autonomous() tasks as necessary. So what is the third program you are referring to?

When I add the pre_auton function back into the code you attached I do not get any warnings other than the usual one about UserControlCodePlaceholderForTesting and AutonomousCodePlaceholderForTesting, you can ignore these. There should not be a warning about pre_auton unless you have deleted that call from the Vex_Competition_Includes.c file for some reason, it should be near the top.

task main()
{
	// Master CPU will not let competition start until powered on for at least 2-seconds
	clearLCDLine(0);
	clearLCDLine(1);
	displayLCDPos(0, 0);
	displayNextLCDString("Startup");
	wait1Msec(2000);


	pre_auton();

	//wait1Msec(500);


	while (true)
	{

Again, you really should not mess with this file as it’s a system file and is used in all ROBOTC competition template based programs.

If you have white keys then check firmware versions are all correct (cortex, joystick and both keys) if they are not working.

Now this is the errors that I get.
capture 3.jpg

It may be the keys or it may be the cortex and joystick.

You can check the cortex using the ROBOTC software inspection menu (may need to enable “expert menus” first under the window menu) or using the VEX firmware upgrade utility.

All VEX firmware is on the wiki here.
http://www.vexrobotics.com/wiki/Software_Downloads#2_-_Update_Firmware_on_Cortex_Microcontroller.2C_VEXnet_Joystick.2C_and_VEXnet_Key_2.0

I updated the cortex and joystick, that is when I started having issues.So I assume its the Keys.

Can you attach the file you have with no errors?
When I copy and past what you posted into my program it gave me several more errors.

I feel like you are still trying to compile Vex_Competition_Includes.c, you don’t need to do that, only compile your competition code file. It also looks like Vex_Competition_Includes.c has been messed with as I don’t see the prototype for the pre_auton function above the usercontrol prototype. Normally the top of this file would look like…

void allMotorsOff();
void allTasksStop();
void pre_auton();
task autonomous();
task usercontrol();

int nTimeXX = 0;
bool bStopTasksBetweenModes = true;

So lets back up, which version of ROBOTC are you using? Have you changed Vex_Competition_Includes.c? Are you trying to compile more than one source file?

Can you post the program file you have of mine with no errors. When I paste the auton you posted into the file it gave me several more errors. I am working on updating the keys now. I already had the joystick and cortex updated that is why I believe its the keys.

I really appreciate the help!

I am using the newest version 4.X. I understand the difference now between the two programs. Thanks for clearing that up. So the program I need to compile is competition programnew. the error it has is a yellow X that says:

Warning:Unreferenced function ‘pre_auton’

No problem, here it is.

Yes, but I think someone has changed the Vex_Competition_Includes.c file which is why you have errors.
Competition Programnew_r1.c (4.19 KB)

I see the same Warning:Unreferenced function ‘pre_auton’ on yours. Is that due to having no pre_auton?

Attached is a standard Vex_Competition_Includes.c from a clean copy of ROBOTC V4.27.

On my system this is in the folder.
C:\Program Files (x86)\Robomatter Inc\ROBOTC Development Environment 4.X\Includes

Compare with what you have and replace if you feel it’s necessary.

When compiling your source file you will still normally see two warnings.

File ".\SourceFile002.c" compiled on Jan 09 2015 09:26:19
*Warning*:Unreferenced function 'UserControlCodePlaceholderForTesting'
*Warning*:Unreferenced function 'AutonomousCodePlaceholderForTesting'

But that’s ok, you can generally ignore warnings anyway.

In fact. the warning about pre_auton you could probably also ignore, it just worries me that other things in the competition template may have been changed. Is there any chance this is a special version just for PLTW?

Alternative, just delete the pre_auton function (ie. back to what you started with) and that warning will go away, in which case your original problem was just compiling the competition includes file when that’s not necessary.
Vex_Competition_Includes.c (5.74 KB)

I know we all do. :smiley:

Thanks for all your help. I think that the program is working properly now. The flashing LED’s I have are for GAME and VEXnet but they are not on the controller they are on the cortex. Both the cortex and controller are updated. Is this what happens when the keys are needing the update?

Yes, it’s a bit weird, starts out with robot and VEXnet flashing red then changes to vexnet and game flashing red if the joystick is turned on, not sure why that happens, I didn’t notice that before.

Just update the keys if the cortex has been updated to V4.23 already. It’s real easy and takes just a few seconds using the VEXnet 2.0 update utility I linked to earlier.

Thanks for that useful gem of wisdom Griffin.