Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   FIRST Tech Challenge (http://www.chiefdelphi.com/forums/forumdisplay.php?f=146)
-   -   Disabling the Radio Control (http://www.chiefdelphi.com/forums/showthread.php?t=44981)

Guy_E 04-03-2006 03:34

Disabling the Radio Control
 
Hi,
Im programming the VEX using MPLAB.
I have downloaded the Vex's default code, but in this code the robot can't do anything unless the radio transmitter is switched on. I want to disable this option because I don't want to use it at all (My robot is fully autonomous and is not designed for the FVC)

Does anyone know how can I disable The RC?

Thanks,
Guy

Kingofl337 06-03-2006 10:59

Re: Disabling the Radio Control
 
You could try loading MasterCode Version 5

Guy_E 06-03-2006 12:05

Re: Disabling the Radio Control
 
I tried, but it didn't help.
Do I need to change anything in the code itself to make it work?

Im desperate.... :confused:

Mark McLeod 06-03-2006 12:30

Re: Disabling the Radio Control
 
It's pretty simple.
Just add this line to your initialization and the Master processor will ignore the radio.
Do a search, it may already be in there somewhere.
Code:

txdata.user_cmd = 0x02;        /* Tell master you want to be in auton mode. */

Guy_E 06-03-2006 12:53

Re: Disabling the Radio Control
 
Thanks, it did work, but just when my code was in the "User_Autonomous_code" function.
I want to write it in "User_Routines_fast" in the "Process_Data_From_Local_IO" (It's faster, isn't it?)

What do I need to do in order to write it there?
I tried to do that and it didn't work when the transmitter was switched off, while it did work when the code was in the autonomous function.

Mark McLeod 06-03-2006 13:25

Re: Disabling the Radio Control
 
Quote:

Originally Posted by Guy_E
I want to write it in "User_Routines_fast" in the "Process_Data_From_Local_IO" (It's faster, isn't it?)

If I understand your question correctly...

You can only update your controls at the (slower) rate the data packets arrive and leave again, no faster. Those are the GetData/PutData calls you can see in the Autonomous loop. You cannot speed them up.

Process_Data_From_Local_IO runs much faster than the autonomous loop so you can do things like sample sensors. The CPU should be much faster than the rate you change your motors and stuff. You should always be able to think much faster than you can act.

Guy_E 06-03-2006 13:33

Re: Disabling the Radio Control
 
So I should sample my sensors in "Process_from_local_IO" and change the motors in "User_Autonomous_Code"?

I just need to call "Process_from_local_IO" from the "User_Autonomous_Code"?

But can I do it all in the "Process_from_local_IO" or will it "confuse" the CPU?

Mark McLeod 06-03-2006 14:32

Re: Disabling the Radio Control
 
Quote:

Originally Posted by Guy_E
So I should sample my sensors in "Process_from_local_IO" and change the motors in "User_Autonomous_Code"?

I just need to call "Process_from_local_IO" from the "User_Autonomous_Code"?

But can I do it all in the "Process_from_local_IO" or will it "confuse" the CPU?

The way the default Vex code is organized you have to add Process_From_Local_IO to the auto loop in User_Autonomous_Code, if you want it to be called while you're running autonomously. Be careful where you place it though. I actually get rid of this autonomous loop altogether and depend instead upon the main loop in main.c, but that's only a personal choice.
Code:

  while (autonomous_mode)  /* DO NOT CHANGE! */
  {
        if (statusflag.NEW_SPI_DATA)          /* 18.5ms loop area */
        {
          Getdata(&rxdata);  /* DO NOT DELETE, or you will be stuck here forever! */
        /* Add your own code here. */
          printf("%2x : %2x %2x %2x %2x %2x %2x\n",(int)rxdata.rc_receiver_status_byte.allbits,
                (int)PWM_in1,(int)PWM_in2,(int)pwm01,(int)pwm02,(int)pwm03,(int)pwm04);
          Putdata(&txdata);  /* DO NOT DELETE, or you will get no PWM outputs! */
        }
        Process_Data_From_Local_IO();
  }

If you want to you can set the variables used for the motors as fast as you like (in Process_From_Local_IO for instance), just realize only the values in there at the time of the slow loop will be acted upon. If you're constantly setting the motors to the same value then it won't matter to you.

Guy_E 06-03-2006 14:57

Re: Disabling the Radio Control
 
You've helped me so much!

Thanks a lot!


All times are GMT -5. The time now is 17:43.

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