|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#12
|
|||
|
|||
|
Re: The 8.2 (or 8.3) Battery Voltage Bug
Quote:
code, or in the controller chip itself. I don't believe that it is a bug in the camera code per-se, although the use of the camera code increases the severity of the problem. We backed out of all of our interrupt/timer based control at the Portland regional in response to this problem as there was no way we could keep our robot running otherwise. We have seen problems in very simple code. Below are the only lines of custom code, using the recently published default code. At one point whether or not the periodic printf statements appeared on he download console depended upon whether or not we had static int counter; or static int counter = 0; for the declaration of "counter". This problem comes and goes over a day, in the morning it is consistent but when attempting to reproduce it with the same code in the afternoon one can't after several tries. I am presuming that the memory location of "counter" moves between the implicitly initialized segment, from the explicitly initialized segment, with the declaration change and this changed the arrangement of memory. Whether or not memory is actually getting stomped is something a little more random in the controller. An option question is, given the problems with the 2006 controller, whether or not FIRST would be willing to allow the use of the 2005 controller at regional events. We have not seen any of these problems on the 2005 controller. Eugene /************************************************** ***************************** * FUNCTION NAME: Process_Data_From_Master_uP * PURPOSE: Executes every 26.2ms when it gets new data from the master * microprocessor. * CALLED FROM: main.c * ARGUMENTS: none * RETURNS: void ************************************************** *****************************/ struct rpmpower { int rpm; int power; }; /* This table is constructed by using the manual RPM control to set RPM values manually and then reading off the required power for that RPM. */ #define RPMPOWERTABLESIZE 9 struct rpmpower rpmpowertable[RPMPOWERTABLESIZE] = { 1300, 160, 1400, 161, 1500, 167, 1600, 168, 1700, 170, 1800, 177, 1900, 181, 2000, 189, 2100, 193 }; int RPM2Power(int rpm) { int RetPower; int i; if(rpm <= rpmpowertable[0].rpm) return rpmpowertable[0].power; if(rpm >= rpmpowertable[RPMPOWERTABLESIZE-1].rpm) return rpmpowertable[RPMPOWERTABLESIZE-1].power; for(i=0; i<(RPMPOWERTABLESIZE-1); i+=1){ if(rpmpowertable[i].rpm < rpm && rpmpowertable[i+1].rpm >= rpm){ RetPower = rpmpowertable[i].power + ((rpm - rpmpowertable[i].rpm) * (rpmpowertable[i+1].power - rpmpowertable[i].power)) / (rpmpowertable[i+1].rpm - rpmpowertable[i].rpm); break; } } return RetPower; } void Process_Data_From_Master_uP(void) { int Target; int BallWheelPower; static int counter; /* Does not work if not initialized to zero! */ Getdata(&rxdata); /* Control of the drive motors. */ if(rc_dig_in08 == 1) { pwm01 = p1_y; pwm02 = p3_y; pwm03 = p1_y; pwm04 = p3_y; } else { pwm01 = STOP; pwm02 = STOP; pwm03 = STOP; pwm04 = STOP; } /* Pan Control */ if(p3_sw_trig == 1 && rc_dig_in12 == 0) { pwm06 = STOP + 20; } else if(p2_sw_aux2 == 1 && rc_dig_in11 == 0){ pwm06 = STOP - 12; } else{ pwm06 = STOP; } if(rc_dig_in06 == 0){ pwm06 = STOP; } /* Ball lift control. */ if(p2_sw_top == 1 && rc_dig_in07 == 1) { pwm05 = 254; } else if (p2_sw_trig == 1 && rc_dig_in07 == 1){ pwm05 = 1; } else { pwm05 = STOP; } /* Ball wheel speed control. */ Target = (int)1200 + (int)3 * (int)p4_x; BallWheelPower = RPM2Power(Target); if(rc_dig_in10 == 0) { pwm07 = STOP; } else { pwm07 = BallWheelPower; } /* Ball shooter fire control */ if(p2_sw_aux1 == 1 && rc_dig_in09 == 1) { pwm08 = 254; } else { pwm08 = STOP; } if(counter % 40 == 2) { printf("p1_y = %d, p3_y = %d, BWP = %d, TargetRPM = %d, p4_x = %d\r", (int)p1_y, (int)p3_y, (int)BallWheelPower, (int)Target, (int)p4_x); } counter += 1; if (user_display_mode == 0) { if(rc_dig_in12 == 1) { /* Right pan limit. */ Switch1_LED = 1; } else { Switch1_LED = 0; } if(rc_dig_in11 == 1) { /* Left pan limit. */ Switch2_LED = 1; } else { Switch2_LED = 0; } } else { User_Mode_byte = backup_voltage * 10; } Generate_Pwms(pwm13,pwm14,pwm15,pwm16); Putdata(&txdata); /* DO NOT CHANGE! */ } Last edited by eugenebrooks : 04-03-2006 at 23:49. |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Reading battery voltage in software | RbtGal1351 | Programming | 17 | 21-10-2007 13:07 |
| How to obtain battery voltage from within EasyC | DavidSJohnson | Programming | 2 | 14-02-2006 00:05 |
| battery voltage compensation | Rickertsen2 | Programming | 5 | 17-10-2005 22:12 |
| RC Circuits | Melissa Nute | Math and Science | 3 | 25-01-2004 05:02 |
| Battery Chargers | Neal Probert | Electrical | 46 | 16-02-2003 22:31 |