Autonomous help please

Following all the information I can find, it appears that having the robot execute something in autonomous mode is as simple as placing the code, such as *pwm01 = 200; * into the autonomous portion of the default code (where it indicates, place autonomous code here) in fast user routines. My team has a dongle built up to switch the robot between user and autonomous mode (I know this switch works as indicated by a blinking disable light on the operator interface). I have written small changes to the default code and successufully uploaded them to the robot, so no problems getting the code to the robot. All I was trying to do is confirm some kind of autonomous operation of the robot, such as: pwm01=pwm02=200; but I got nothing :ahh: . Any help anyone can provide would be greatly appreciated. I did search the forums, but could not find anyone else having similar problems.



Could you post what your code says in user_routines? My guess is that you have something located in the wrong place. Have you tried using debug statements to print the current values of those PWMs on the output screen, and/or used the Dashboard viewer? If you post the code I’d know more about what your problem is.

There is really no code to show. In the user routines fast, there is a statement to put your autonomous code here. I place pwm## = 200;. I load the code into the robot. I put the robot into autonomous mode (using the switch built up as instructed, and it does work) and nothing happens (i.e. the motors programmed to drive forward do nothing). Im just at a loss, as to why the autonomous code does not execute. :ahh: :confused: :ahh: :frowning: :ahh:

I suppose it sounds obvious … but are you sure you have the motors hooked up to pwm##? Try putting that same code in the Default_Routine function in user_routines.c, and see if it works without messing with autonomous mode. And still, it might be worthwhile to see the exact code you have … I know from experience, that it is easy to overlook something simple if you aren’t looking specifically for it.

**from user_routines.c ** (this is just the default 1 stick drive) we have our base built and are currently driving it around, so I know the PWMs are hooked up accordingly.

pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);
pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);

from user_routines_fast.c:

void User_Autonomous_Code(void)
while (autonomous_mode) /* DO NOT CHANGE! /
if (statusflag.NEW_SPI_DATA) /
26.2ms loop area /
Getdata(&rxdata); /
DO NOT DELETE, or you will be stuck here forever! */

    /* Add your own autonomous code here. */
	pwm13 = pwm14 = 200;
	pwm15 = pwm16 = 200;

    Putdata(&txdata);   /* DO NOT DELETE, or you will get no PWM outputs! */


you can see from above, all I did was tell the robot to drive foward if in autonomous, but nothing happened :ahh: . Thanks for any help you can provide. Has anyone else had this problem?


Are you sure the robot is in autonomous mode and isn’t disabled? The RC LED should be yellow and blinking. I know you said it blinks, just making sure its yellow. Which PWMs are you using?

In User_Autonomous_Code() they left out a call to Generate_Pwms(). That function sets the outputs for pwm13 - 16. If you’re using one of those outputs then the value you set isn’t getting sent to the motor. Insert the line “Generate_Pwms(pwm13,pwm14,pwm15,pwm16);” right before
“Putdata(&txdata);” in User_Autonomous_Code().

If that doesn’t work, try putting a printf() in User_Autonomous_Code() to make sure that function is being executed.

I think you nailed it Sean, thanks. The blinking light is yellow. I wasn’t aware of the Generate_Pwm() function. I will give that a try. Thanks.