|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: PID vs Normal loops
Your code works in theory, but ties up the processor for the duration of that while loop such that the only thing that works on the robot in the while loop is the dvr variable.
Because of this, and limited previous FRC programming experiences, I believe while loops are not possible on a PIC processor. |
|
#2
|
|||||
|
|||||
|
Re: PID vs Normal loops
Quote:
First of all, it is important to keep in mind that the RC is one application of one particular variant of PIC microprocessor. PICs come in all shapes and sizes and speeds with all sorts of different I/O options. You can program them in many different languages... from assembly to C to Java to BASIC. In FIRST, however, we focus on the PIC in the RC, specifically the user PIC, programmed in C for easy compatibility with the default code provided by IFI (we don't touch the master PIC which handles radio communications and such). You will see in the default code reference to "while(1)" meaning that the code is running in an endless while loop. This is one big difference between programming the RC and programming a PC. In the RC you have a loop that restarts every 17ms, while on a PC you have more flexibility on timing for most applications. So whatever you do... while loops, for next loops, if thens... whatever... needs to be accomplished in 17ms or less. So in this case, you are correct that this particular implementation of a while loop would not be good practice on the RC because there is no guarantee that it will finish within the 17ms period. However that does not mean that PICs are incapable of performing while loops... they can "while" as well as any processor... it is just that the structure within the RC means that you have to be careful about creating any loops that won't finish in 17ms or less. Well... that was supposed to help clear things up... Jason |
|
#3
|
||||
|
||||
|
Re: PID vs Normal loops
Actually, another member of my code team wrote an amazing PID library that will do all of this for you in very few lines of code. I'll see if I can get this to you within the next few days
|
|
#4
|
||||
|
||||
|
Re: PID vs Normal loops
OK so maybe the while statement wouldn't work all too well, but couldn't you use an inverted scale type of thing, that the lower the error, the greater the modifier on it would be? I see the risk of that overshooting, but if it's balanced right I don't see why it should.
But then again, with the code I posted, it won't overshoot it, it will just reach it, VERY VERY VERY slowly. 128 speed isn't much, but then again your error is going to be such that much won't be needed. |
|
#5
|
||||
|
||||
|
Re: PID vs Normal loops
I suggest you go ahead and try it out - you will likely learn a lot in the process. You will most likely find that it won't reach it. Remember, there is a deadband in the Victor speed controllers (sending them a 128 will not cause them to run at all) and with speeds that low the forces of friction in the system will be larger than the value you are sending to the motor.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Hobbies, normal and unusual | Jill1022 | Chit-Chat | 61 | 29-04-2005 08:33 |
| PID control loops - closed loop feedback | KenWittlief | Technical Discussion | 56 | 26-04-2004 21:27 |
| Well, is it normal for me not to be in FIRST Robotics and post here? | JKis6622 | Chit-Chat | 3 | 13-03-2004 15:46 |
| PID Control Loops | ttedrow | Programming | 7 | 05-12-2002 12:03 |
| Programming Loops | Mike o. | Programming | 5 | 26-03-2002 11:24 |