![]() |
Re: counting in seconds for the autonomous mode??
Well, we have had problems when using those generated PWMs, especially if they are called quickly. We've observed fluctuations in the motor we're trying to adjust as well as induced outputs on other PWMs that are generated. Switching to PWMs 1-12 solved these problems.
While it may not be a bad idea in theory to call G_PWMs quickly, for practical application with the robots we are building, its unnecessary and possibly detrimental. Do you really need to update your actual motor output at faster than 38hz? |
Re: counting in seconds for the autonomous mode??
Quote:
Code:
auton_time++; ?! you gotta remember lots of students are struggling just to understand this stuff, and dont normally use uP hardware everyday :^) |
Re: counting in seconds for the autonomous mode??
would this code work u think?? we're going to use a stopwatch to determine how long it actually takes us in average. the only think we are doing in autonomous mod is driving to the 10 pt ball and hopefully noking it down.
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 */ { counter++; Getdata(&rxdata); /* DO NOT DELETE, or you will be stuck here forever! */ /* Add your own autonomous code here. */ // counter calculated as (38*12) if ( counter < 456 ) // still less than 12 seconds have elapsed { if (rc_dig_in01 == 0 && rc_dig_in02 == 0) { pwm13 = pwm14=137; pwm15= pwm16= 137; } if (rc_dig_in01 == 1 && rc_dig_in02 ==0) { pwm13 = pwm14= 128; pwm15= pwm16= 132; } if (rc_dig_in01 ==0 && rc_dig_in02 == 1) { pwm13 = pwm14=132; pwm15= pwm16=128; } } Generate_Pwms(pwm13,pwm14,pwm15,pwm16); Putdata(&txdata); /* DO NOT DELETE, or you will get no PWM outputs! */ } } } |
Re: counting in seconds for the autonomous mode??
Quote:
It isn't a matter of how fast our controller can spit out PWM updates, but a matter of how fast the device at the receiving end is designed to be updated. The victor speed controllers are not designed for a 2ms update rate. I believe they update at 60Hz or 17ms. Use the Generate_Pwms() at the slow-loop 26ms rate or create a separate timing loop to update them at 17ms minimum for fastest updates. [edit] I double checked and the victor does at least one type of update at 60Hz, but IFI notes imply a faster PWM update rate. I haven't been able to discover documentation on what that rate might be, other than 2ms is too fast. |
Re: counting in seconds for the autonomous mode??
Quote:
I might add an initialization for counter, e.g., Code:
void User_Autonomous_Code(void)Even if you initialized counter when you declare it, e.g., static unsigned int counter=0; You'll have trouble during the practice sessions when you run twice in a row. You'd have to be sure to reset the RC between runs. Explicitly setting it before the auto loop avoids this potential pitfall. [edit] Actually "static" isn't required in this case, since you never leave the routine. I only tend to use it as a matter of convention (Our functions aren't written to take control away from the main loop). You can in this case declare "unsigned int counter=0;" in the local routine and be fine. I still prefer explicit initialization though. |
Re: counting in seconds for the autonomous mode??
Quote:
BTW at most regionals they have a carpet setup in a back hallway where you can test your auton code - you usually have to sign up for a time slot, but it really helps to be able to test it, tweak your code, test it again... it looks good - your on the right path. |
Re: counting in seconds for the autonomous mode??
Quote:
Quote:
|
Re: counting in seconds for the autonomous mode??
Regarding pwm13-16: See this thread, and see Kevin Watson's FAQ especially the first really long question.
I stay away from PWM13-16. 38 Hz is fast enough for me! |
| All times are GMT -5. The time now is 20:59. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi