Thread: Lag Issue
View Single Post
  #2   Spotlight this post!  
Unread 04-02-2008, 16:35
TubaMorg TubaMorg is offline
Programmermechanicalelect ricalcoach
AKA: Dan
FRC #1480 (Robatos Locos)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2005
Location: Houston
Posts: 450
TubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond reputeTubaMorg has a reputation beyond repute
Re: Lag Issue

Look at your ramp functions. You need to rethink how you're doing that. Once you enter a loop, your program has to wait for it to finish before it can continue on, thus you get delays. Try, instead, to maintain a state variable that represents the current PWM input. Your joy values represent the desired PWM input.

psuedo code:

If pwmDesired > pwmActual then pwmActual += 2;
If pwmDesired < pwmActual then pwmActual -=2;

Add in some approprate limits etc. and it should react more quickly to user input.