we need help with PWM problem in autonomous

We’re getting strange pwm trouble in Autonomous Mode. If I put pwm13 = pwm14 = 127 in User_Autonomous_Code(), the speed controller’s LED are green and motors turn. If I use pwm13 = pwm14 = 0 or if I use pwm13 = pwm14 = 255, both make LEDs turn off and motors spin opposite. If I do this in the default routine, it works right: 127, LEDs are orange; 255,green and 0 red.
Can anyone tell my why the PWMs act different in Default and Autonomous?
here’s the code in User_Autonomous_Code() :

/* Add your own autonomous code here. */

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


void Remote_Controls()

// if Remote # 2 is pressed, stop
if (rc_dig_in02==0)
  pwm13 = pwm14 = 127;
  pwm15 = pwm16 = 127;

// if Remote # 3 is pressed, backup
if (rc_dig_in03==0)
  pwm13 = pwm14 = 0;
  pwm15 = pwm16 = 0;

// if Remote # 4 is pressed, fwd
if (rc_dig_in04==0)
  pwm13 = pwm14 = 255;
  pwm15 = pwm16 = 255;


in your code where it says

if (rc_dig_in13==0)

You need to put == 1 If you are looking for 0 that means you never pressed a button. If you press the stop button with your code it makes it 1, so it skips the if statement you want it to go to, and goes to the reverse one. I think I explained it ok, if I didnt, ley me know.

rc_dig_in13==0 means the switch is closed; on the robot controller’s digital input/output port, the white and black lines are connecting.
But that has nothing to do with why pwm13=127 makes the speed controller go full forward, like I said above.

When you say pwm13=127, is that within one of the IR ifs or just a direct assignment? There should be no reason the code is different in the two functions, it is very strange.

At first in the IR ifs, but when it was acting strange,I began to try it everyway I could think of, finally even with direct assignments, printing out the values to make sure, and it always acted like that. I cut and paste it into Default_Routine() and it was fine. I wonder if somehow I’m generating PWMs to often or something, but I don’t see where.

Oh, sorry I didn’t notice before… Go look at the sticky topic about PWM 13-16 replacement code… Those ones are different from the rest, if you’ll read. Or just change the PWMs to a lower value and see what happens. That’s almost definitely the issue.

The comments in the code seem to indicate that you’re using the IR sensor board. That board doesn’t provide a switch closure to ground. It provides a voltage output: 0 means the signal is not detected, and 1 means it is. If your digital inputs are coming from the IR board, you do have your tests backwards.

Thanks. No, for troubleshooting I was using a jumper on the inputs, no IR reciever connected. That’s why if digtal in ==0.