Autonomous enable/disable

I’m new to the VEX system. I’ve searched through the forums but I haven’t found what I’m looking for. I’m programming the VEX kit using MPLAB. I’m trying to build a personal project using a VEX kit. I’d like the robot operate autonomously unless the RC is turned on. When it detects a good signal from the RC I’d like it to come out of autonomous mode so it can be controlled by the RC.

Is there any easy way to do this? I know that “txdata.user_cmd = 0x02;” enables autonomous mode and disables the RC.

I’ve noticed that VEX has a light to indicate when it has a good signal from the RC. Does anyone know how to detect a good RC signal in software?

Thanks for the help.

Andy

If you are not using one of the channels on the Transmitter to control the robot, offset the trim on that channel, so that the neutral band on that channel is somewhere in the 90s or 160s on the 0-255 PWM scale. Then in the code, program in that if it ever sees a signal coming from that specific channel in the same range where you offset the trim, you know the Transmitter must be on. (Otherwise, everything defaults to 127.)

Clever, it’s like a dead man’s switch. You could make a robot that could identify when it’s been driven out of range and program it to drive back.

For some reason I can’t get it to work. It seems like it stops paying attention to the RC as soon as it loses signal. It won’t drive the motors without an RC signal unless it is actually in autonomous mode.

Anyone else have some ideas?

Andy

The transmitter values come to the Master processor. It then forwards them to you via the GetData call.
When you tell the Master processor you want to be in autonomous mode, using the txdata.user_cmd setting, you are instructing the master processor to ignore the normal inputs it receives from your transmitter. The Master processor will send you a neutral packet of data until your code changes txdata.user_cmd back. No matter what you do with the transmitter from then on you will never again receive any data originating from it. So flipping the transmitter controls will do nothing for you.

I can think of a couple of options to get around this lack of transmitter data.

If you are willing to leave the transmitter on then you can use the signal you guys were talking about. For instance, do autonomous stuff if a channel 6 button is pushed rather than use the txdata.user_cm at all.

If you want to go autonomous when the robot gets cut off from transmissions, then set txdata.user_cmd when your signal value goes to neutral (Master sets it when the transmitter signal is lost), to come out of it you could periodically stop, set txdata.user_c back to the default value temporarily, test for valid transmitter data, then if no signal is received return to autonomous operation. It takes around 15 data packets (or slow loops) for contact to be reestablished though.

P.S.
I seem to remember an interesting side effect of setting txdata.user_cmd on the fly. If your code sets txdata.user_cmd while receiving valid transmitter data, the GetData packet retains the last known transmitter values and your code keeps receiving it. The Master doesn’t set the packet to neutral for some reason.

Thanks for the help. This code is working now. I setup counters to handle the state changes. I have to set the motors to 128 for 5 cycles during the transition to prevent little hiccups. You were also right that it takes about 15 cycles for the controller to find the transmitter. The down side is that the autonomous mode stops for about a 3rd of a second ever few seconds to check for the transmitter. Because it’s easy to detect the loss of transmitter there’s no problem while I’ve got the transmitter on.

Let me know if you think of a way to do this on the fly so I don’t have the downtime in my autonomous mode.

Andy