Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   PWMs not outputting in Autonomous (http://www.chiefdelphi.com/forums/showthread.php?t=53612)

937Programmers 06-02-2007 21:22

PWMs not outputting in Autonomous
 
Hello! I don't know if this question has been answered yet, but I didn't seem to find an answer anywhere.

When we are trying to run autonomous code, PWMs 1-12 aren't doing anything, and the speed controllers that are hooked up into those PWMs are blinking yellow. We think that the PWMs aren't being enabled, but we're not quite sure how to do that in the autonomous code. We have the drivetrain motors in PWMs 13-16, and those are working fine. Nothing else, however, will work. :(

// If it might be part of the problem, we're using Kevin's streamlined code as a base.

Please help as soon as possible! Thanks!

meatmanek 06-02-2007 21:25

Re: PWMs not outputting in Autonomous
 
Perhaps you deleted this line:

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

which goes after Generate_Pwms

937Programmers 06-02-2007 21:28

Re: PWMs not outputting in Autonomous
 
Quote:

Originally Posted by meatmanek (Post 573277)
Perhaps you deleted this line:

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

which goes after Generate_Pwms

No, that's not the issue. I made sure that I didn't delete any lines when I wrote the code. I just double checked, and that line is definitely where it's supposed to be.

Anything else that might be the problem?

meatmanek 06-02-2007 21:41

Re: PWMs not outputting in Autonomous
 
Mind posting your User_Autonomous_Code?

EHaskins 06-02-2007 22:10

Re: PWMs not outputting in Autonomous
 
If you leave the robot in autonomous mode do you get a code error light?

937Programmers 06-02-2007 23:32

Re: PWMs not outputting in Autonomous
 
Quote:

Originally Posted by EHaskins (Post 573315)
If you leave the robot in autonomous mode do you get a code error light?

Surprisingly, no. It runs like it's supposed to as I watched the terminal window, but nothing from 1-12 actually runs.

As for posting my code, I'll get to that ASAP. I should be able to get it up tomorrow.

Jared Russell 07-02-2007 00:21

Re: PWMs not outputting in Autonomous
 
Blinking yellow speed controllers usually indicate a connectivity problem with the signal...I'm assuming they work under human operation?

Are you calling something that might modify the PWM values before you call PutData()? Try printing out the values RIGHT before you PutData().

Inverted 07-02-2007 13:27

Re: PWMs not outputting in Autonomous
 
I had the same problem with my motor output during autonomous. I changed the "Generate Pwms" function to his "PWM" function and everything worked. Hope the problem is as simple as that.

Aaron_H 07-02-2007 13:56

Re: PWMs not outputting in Autonomous
 
Make sure that your PWM outputs are not 127 by default. At the top of the autonomous loop, all the PWMs are set to 127 by default, this may have something to do with it.

937Programmers 08-02-2007 19:12

Re: PWMs not outputting in Autonomous
 
Well, all the motors work under human operation, and I haven't gotten around to messing with it yet today (I just got here :p )

Anyways, here's my autonomous function before modification today:

Code:

void User_Autonomous_Code(void)
{
  /* Initialize all PWMs and Relays when entering Autonomous mode, or else it
    will be stuck with the last values mapped from the joysticks.  Remember,
    even when Disabled it is reading inputs from the Operator Interface.
  */
  pwm01 = pwm02 = pwm03 = pwm04 = pwm05 = pwm06 = pwm07 = pwm08 = 127;
  pwm09 = pwm10 = pwm11 = pwm12 = pwm13 = pwm14 = pwm15 = pwm16 = 127;
  relay1_fwd = relay1_rev = relay2_fwd = relay2_rev = 0;
  relay3_fwd = relay3_rev = relay4_fwd = relay4_rev = 0;
  relay5_fwd = relay5_rev = relay6_fwd = relay6_rev = 0;
  relay7_fwd = relay7_rev = relay8_fwd = relay8_rev = 0;

  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. */
                // STEP 1 - Initialize the Camera
                Tracking_Info_Terminal();
                Camera_Handler();
                Servo_Track();

                if(Get_Tracking_State() >= TARGET_IN_VIEW)
                {
                        // STEP 2 - Make Robot Face the Light
                        if((((int)PAN_SERVO-124)*65)/124 < 0)
                        {
                                pwm13 = pwm14 = 62;
                                pwm15 = pwm16 = 192;
                                centered = 0;
                        }
                        else if((((int)PAN_SERVO-124)*65)/124 > 0)
                        {
                                pwm13 = pwm14 = 192;
                                pwm15 = pwm16 = 62;
                                centered = 0;
                        }
                        else
                        {
                                pwm13 = pwm14 = pwm15 = pwm16 = 127;
                                centered = 1;
                        }
               
                        // STEP 3 - Drive Robot forward until 4 feet in front of Rack

                        if((((int)TILT_SERVO-144)*25)/50 < 67 && centered == 1)
                        {
                                pwm13 = pwm14 = pwm15 = pwm16 = 192;
                        }
                       
                        if(centered == 1 && (((int)TILT_SERVO-144)*25)/50 >= 67)
                        {
                                pwm13 = pwm14 = pwm15 = pwm16 = 127;
                               
                                // STEP 4 - Move the arm to the center position
                                if(counter < 624 && arminpos == 0)
                                {
                                        pwm08 = 254;
                                        counter++;
                                        if(counter == 624)
                                        {
                                                arminpos = 1;
                                        }
                                }       
                        }
                        counter = 0;

                        // STEP 5 - Place the tube on the leg
                        if(arminpos == 1)
                        {
                                pwm13 = pwm14 = pwm15 = pwm16 = 192;
                                counter++;
                                if(counter == 26)
                                {
                                        overdisk = 1;
                                        pwm13 = pwm14 = pwm15 = pwm16 = 127;
                                }               
                       
                                if(counter < 208 && clawopen == 0)
                                {
                                        pwm05 = 192;
                                        if(overdisk == 1)
                                        {
                                                counter++;
                                        }
                                }

                                if(counter == 208)
                                {
                                        clawopen = 1;  counter = 0;  pwm05 = 127;
                                }
                        }

                        if(clawopen == 1)
                        {
                                pwm13 = pwm14 = pwm15 = pwm16 = 62;
                        }
                        // END AUTONOMOUS CODE
                }

            PWM(pwm13,pwm14,pwm15,pwm16);

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

Thanks for the help. Hopefully this gets fixed today.

wingnut1705 08-02-2007 19:49

Re: PWMs not outputting in Autonomous
 
[quote=937Programmers;574561]

PWM(pwm13,pwm14,pwm15,pwm16);

In the line when you generate the pwm's, make sure that any pwm that you are using is included in that list. That should solve your problem

937Programmers 08-02-2007 20:10

Re: PWMs not outputting in Autonomous
 
You mean like this?
Code:

PWM(pwm01,pwm02,pwm05,pwm08,pwm13,pwm14,pwm15,pwm16);
Or this?
Code:

PWM(pwm01,pwm02,pwm05,pwm08);
PWM(pwm13,pwm14,pwm15,pwm16);

If we do the first one, then there's an error saying there's too many calls in the argument. The second one doesn't work either because apparently the PWM() function only affects 13-16. I think I have an idea, though, and I'll see if it works.

Edit: Yeah, I didn't think it would. I thought the problem may have been PWM vs. Generate_Pwms, but that's not the issue.

gnirts 08-02-2007 20:35

Re: PWMs not outputting in Autonomous
 
No, the PWM() only deals with 13-16. Try setting all your PWMs to 254 (disconnect any motors first!) and then power up and go into autonomous. Take the PWM cable coming from your Victor and move it up from 1 through 12, and see if the light on the Victor stays blinking orange or if it changes to green or red. If so, then one of your outputs may be bad. If not, switch cables and repeat. I have encountered several bad cables this year. If none of your cables working, switch Victors. The connection from the cable to the Victor is commonly loose on our 'bot this year too.

If none of these work, use the dashboard program (either IFI's or Sean Witte (sp?)) and see if they read 254 or not.

I take it that the PWMs work fine in Teleoperated mode?

Good luck,
Robinson

937Programmers 08-02-2007 20:54

Re: PWMs not outputting in Autonomous
 
Quote:

Originally Posted by gnirts (Post 574603)
No, the PWM() only deals with 13-16. Try setting all your PWMs to 254 (disconnect any motors first!) and then power up and go into autonomous. Take the PWM cable coming from your Victor and move it up from 1 through 12, and see if the light on the Victor stays blinking orange or if it changes to green or red. If so, then one of your outputs may be bad. If not, switch cables and repeat. I have encountered several bad cables this year. If none of your cables working, switch Victors. The connection from the cable to the Victor is commonly loose on our 'bot this year too.

If none of these work, use the dashboard program (either IFI's or Sean Witte (sp?)) and see if they read 254 or not.

I take it that the PWMs work fine in Teleoperated mode?

Good luck,
Robinson

Yes, the PWMs work fine in Teleoperated mode.

Anyway, using that test, the Victor was blinking yellow from PWMs 1 - 12, but it was green from PWMs 13 - 16, and yet all 16 of them were reading 254, so we think it has to be initialization or something to that effect. Thanks for the suggestion.

gnirts 08-02-2007 21:08

Re: PWMs not outputting in Autonomous
 
Quote:

Originally Posted by 937Programmers (Post 574615)
Yes, the PWMs work fine in Teleoperated mode.

Anyway, using that test, the Victor was blinking yellow from PWMs 1 - 12, but it was green from PWMs 13 - 16, and yet all 16 of them were reading 254, so we think it has to be initialization or something to that effect. Thanks for the suggestion.

If they read 254 on the Dashboard then I would hazard that it is an electrical problem, not strictly software. Did you use this Dashboard, plugged into your OI, to test?

On last possible test I can think of would be to try this year's FRC plugged into some of the Victors on last year's 'bot. I am assuming at this point that everything else about autonomous work? (eg. analog inputs, digital in/outputs, etc.)

If you happen to be in charge of electrical as well, I'm sorry, but I can't really tell you how to proceed from here, other than maybe trying this year's speed controllers on last year's bot.

Good luck again (it's starting to sound like you need it),
Robinson

937Programmers 08-02-2007 21:25

Re: PWMs not outputting in Autonomous
 
Quote:

Originally Posted by gnirts (Post 574626)
If they read 254 on the Dashboard then I would hazard that it is an electrical problem, not strictly software. Did you use this Dashboard, plugged into your OI, to test?

On last possible test I can think of would be to try this year's FRC plugged into some of the Victors on last year's 'bot. I am assuming at this point that everything else about autonomous work? (eg. analog inputs, digital in/outputs, etc.)

If you happen to be in charge of electrical as well, I'm sorry, but I can't really tell you how to proceed from here, other than maybe trying this year's speed controllers on last year's bot.

Good luck again (it's starting to sound like you need it),
Robinson

Well, I don't know much about the electrical side, either, so you're not alone. :p I'll have to ask the electrical team to look at it. Thanks for your advice, at least it's narrowed down the problem. If it actually isn't the problem, then (I'm going to regret this) I may have to drop the autonomous mode (which would not be good...). Thanks, anyway.


All times are GMT -5. The time now is 14:30.

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