Hi All, greatly appreciate LabView FRC experience on timing/errors
After a lot of reading in Chief Delphi (some from LabView Greg M), I am getting closer to understanding how to structure the Robot Code to avoid lag/errors on field. I still need some clarification, help. Below are some bullets I learned compiling many searches, please feel free to comment because I have seen conflicting messages:
- Teleop is event driven, runs when Data packets are sent, occurs every 20mS
- If you Have code in teleop that will take more than 20mS, will impact/lag communications to robot
*Periodic Task best place to put code that require loops, reading sensors, ect… - You can have as many timed loops in periodic task as want, LabView will split multiple threads
- Periodic task wait Xms in loop, example 10mS, loop will run minimum required time 10mS, but each loop may vary in time
*To have periodic task run similar time each loop, use ‘Wait Until Next Multiple’, this is good for task that need to run very regular intervals - periodic task wait time: do not want to have wait time too small, may force labview priority in CPU time sharing and may override task that need more priority?
- Avoid Local variables (not desirable in parallel sequencing program), Global variables OK, prefer put all in RobotGlobalData.VI
- Since Teleop runs at 50Hz, updating motors outside teleop may happen faster, Jaguars update at 200Hz, Victors at 100Hz
Hope this is correct, a lot of time went into compiling this info… hopefully it will help others that are trying to get this information little by little, great to have confirmation on correctness
Now, after all this, million dollar question, why put anything in teleop? Why not put all code put in multiple loops periodic task?
How many loops should I use and set them all to 10mS???
Other points I read, based on this question, please correct if needed to try and help answer this
*Joystick values show up when new control packets (Teleop) arrive, every 20mS? So teleop would be great place to catch the latest joystick events.
Questions on this point?
If this is the case, why does the framework have joystick code in periodic task? Also, why does does framework code use shift register for this?
If I make all my periodic loops 10mS, minimizing what is each loop, time on these threads will be closely shared, and should not exceed 20mS (DS packet/teleop), so it does not have to be in teleop?
PLEASE help comment? I need to change my team code, would like input, a lot of work to rewrite all this/debug/ect… all on practice robot. Right now, have no choice, way too much in Teleop. This was/is my plan:
- Tank Drive: in Periodic task loop: 10mS Wait: Joystick and motor update, use one button for shifter. None in teleop
- Camera Lock, servo Motor: Separate 10mS periodic task loop: Use Target Global, PID to lock and update servo motor, set global target lock booleans
In this code, instead of using standard 10mS Wait, use 10mS ‘Wait Until Next Multiple’ based on previous bullet in this thread, want smoother
intervals. Right now this is in Teleop (YES I need to move it), camera/servo is jerky trying to lock, will "Wait Until Next Multiple’ help this?
The PID set point is always trying to ‘0’, no real dead band?, this may be reason why? Using LabView PID - Ball Sensors: Use in its own periodic Task Loop?
- Game Pad for shooting, ect… Was going to put Game Pad in teleop; use Global for every button, in RobotGlobalData.VI Have a separate standard
10mS periodic loop, update shooter motors, lift belts collect balls, ect… - Gyro: used for tracking where on field, have button reset, also have option to automatically disable camera lock when camera facing opponent
baskets, do not servo or lock in this case. Can I put in sensor loop, since nothing else in it?
Your professional feedback is appreciated… By the way, I am an Engineer for semi conductor company, not a programmer, just trying to help my sons team.
Last two years my son’s team has run great at the school and had a ton of problems, mainly communications, lag, ect… at competition. I want to optimize there chances of this not happening any more. It is heart breaking to see all the hours and hard work the kids put in, excited have a good Robot at school and at the competition does not run the same.
LAST Question, based on this statement: If running Robot at school, and the drive station diagnostic window not showing errors, why would have errors
at competition? How do you simulate competition communications to know if you have everything correct?
Thank You
Mark…