|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#3
|
||||||
|
||||||
|
Re: Trouble with Autonomous
The problem is with your order of operations.
time = (1000 * (degrees/ 300)); is evaluated in the following order (with degrees being 30). ime = (1000 * (degrees/ 300)); time = (1000 * (30/300)); time = (1000 * 0); time = 0; Since you don't really care what order the operations happen, the following will work for you. time = (1000 * degrees) / 300; time = (1000 * 30) / 300; time = (30000) / 300; time = 100; The only problem with the above example is that if degrees gets above 32, you'd overflow the integer value. You could either declare time as a long, or change your constants, since multiplying by 1000 then dividing by 300 is the same as multiplying by 10 then dividing by 3. |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Trouble with the GTS | Bomberofdoom | Programming | 1 | 04-02-2007 10:13 |
| Has anyone else had trouble staying within the 10 second limit in autonomous? | lkdjm | Programming | 18 | 12-02-2006 18:10 |
| Autonomous Code trouble | The yellowdart | Programming | 16 | 21-01-2006 10:36 |
| My trouble with fund raising. | BaldwinNYRookie | Fundraising | 5 | 03-04-2005 13:34 |
| Trouble with pwm outputs | misterikkit | Programming | 16 | 17-01-2004 10:56 |