Go to Post We do FRC to inspire and to be inspired. - Basel A [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 04-02-2008, 16:02
bizarospooky bizarospooky is offline
Registered User
FRC #2642 (Falconaters)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2008
Location: North Carolina
Posts: 11
bizarospooky is an unknown quantity at this point
Lag Issue

Our team is having an issue with we hit the joystick forward and then a few seconds later the motors go (like noticeably slower). We are trying to create a function to slowly ramp up the speed, and of course I'm using EasyC. I'm thinking (and have no access to the robot right now) that I know the problem and that it is I should add the variable outside the SetPWM (see the attached code)
Attached Files
File Type: txt FRCcode.txt (2.9 KB, 96 views)
  #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.
  #3   Spotlight this post!  
Unread 04-02-2008, 17:49
ericand's Avatar
ericand ericand is offline
Registered User
AKA: Eric Anderson
FRC #3765 (Terrabots)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: St. Paul, MN
Posts: 148
ericand is a jewel in the roughericand is a jewel in the roughericand is a jewel in the rough
Re: Lag Issue

We found that a lag function as TubaMorg described worked well. We tuned it such that full forward to full reverse took about .5 seconds.

Since you would be setting the PWM value in the slow loop that executes about 38 times/sec, that would give you an adjustment of about 13-14 towards the desired setting. (255/(38/2) = 13.4)

This does help avoid spinning the wheels and slamming the motors back and forth if the joysticks are bumped.
  #4   Spotlight this post!  
Unread 04-02-2008, 20:19
bizarospooky bizarospooky is offline
Registered User
FRC #2642 (Falconaters)
Team Role: Programmer
 
Join Date: Jan 2008
Rookie Year: 2008
Location: North Carolina
Posts: 11
bizarospooky is an unknown quantity at this point
Re: Lag Issue

neat so, baisically ignore the function stuff and do something like in the operator control

If(Joystick_1(that's the desired)>rampspeed(that's the actual? with it starting at 127))
{
rampspeed+=2
SetPWM(1, rampspeed)
}

Something like that?
  #5   Spotlight this post!  
Unread 04-02-2008, 21:28
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

Quote:
Originally Posted by bizarospooky View Post
neat so, baisically ignore the function stuff and do something like in the operator control

If(Joystick_1(that's the desired)>rampspeed(that's the actual? with it starting at 127))
{
rampspeed+=2
SetPWM(1, rampspeed)
}

Something like that?
That will work, but I like how you break the steps out into functions. That's good style and will make it easier to tweak your code. Because you want to add limits (make sure rampspeed stays between 0 and 254), perhaps a deadband (127 +- 10 maybe), or maybe some PID (for greater control). Also consider how your code will handle different situations:

1. If you go from forward to reverse, do you really want to wait for your ramp to count through neutral before it changes direction?

2. If you are going full forward and need to stop (joystick in neutral) do you want to wait for the code to count to neutral?

Good luck!
  #6   Spotlight this post!  
Unread 06-02-2008, 15:59
Alexa Stott's Avatar
Alexa Stott Alexa Stott is offline
All I do is twin.
AKA: elixir
FRC #0025 (Raider Robotix)
Team Role: College Student
 
Join Date: Oct 2005
Rookie Year: 2006
Location: No. Bruns., NJ/College Park, MD
Posts: 781
Alexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond reputeAlexa Stott has a reputation beyond repute
Send a message via AIM to Alexa Stott
Re: Lag Issue

Correct me if I'm wrong, but, because the joysticks are analog devices, couldn't you just have your driver slowly ramp up the speed manually?

It would make your job as a programmer much easier and give your driver something to practice other than making left turns for hours on end.
__________________
|Email:alexastott[at]gmail.com|Facebook|@zelixir|Google+|
[University of Maryland Computer Science, Psychology]
[Brunswick Eruption]
  #7   Spotlight this post!  
Unread 07-02-2008, 12:33
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

Quote:
Originally Posted by Alexa Stott View Post
Correct me if I'm wrong, but, because the joysticks are analog devices, couldn't you just have your driver slowly ramp up the speed manually?

It would make your job as a programmer much easier and give your driver something to practice other than making left turns for hours on end.
You are correct. Joysticks are analog devices, however the analog signal is converted to a digital one which the program passes along as output to the Victor. Ideally you would like motor behavior to be linearly proportional to joystick input, but this isn't the case most of the time. Depending on robot and drive train design a small deflection from neutral joystick position can translate to a high speed reaction. Two-wheel drive robots with 2 motors on a single speed transmission often have this problem. Because of this drivers will find it impossible to have fine control of their robot because it goes from stop to very fast with very little user input.

The solution, therefore, is for the programmers to make the driver's job as easy as possible by providing a range of controllability (when desired) without sacraficing full speed and power. It is our view that controlling the robot should be as intuitive as possible so that robot responds as the driver desires in high-pressure game situations. The programmers on our team take input from the drivers seriously, because in the end they need to feel comfortable with the controls. This applies not only to how it drives, but which buttons should perform which actions.
  #8   Spotlight this post!  
Unread 08-02-2008, 17:31
ericand's Avatar
ericand ericand is offline
Registered User
AKA: Eric Anderson
FRC #3765 (Terrabots)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: St. Paul, MN
Posts: 148
ericand is a jewel in the roughericand is a jewel in the roughericand is a jewel in the rough
Re: Lag Issue

Quote:
Originally Posted by bizarospooky View Post
neat so, baisically ignore the function stuff and do something like in the operator control

If(Joystick_1(that's the desired)>rampspeed(that's the actual? with it starting at 127))
{
rampspeed+=2
SetPWM(1, rampspeed)
}

Something like that?
That is the general idea. We actually did not take the joysticks directly either. We fit the joystick raw value to a curve such that large movements around neutral gave small changes in target speed, and small movements at the extreme ends gave larget changes in target speed.

For those that question ramping through zero on the way to reverse, we did do that, it helped avoid skidding/tipping. We had to work closely with the drivers though because a little ramp helps, but too much response lag makes controll feel mushy (hard to control).
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
digital inputs lag 0.5-1.0 second before registering change colman77 Programming 6 17-02-2006 12:40
Autonomous issue NJ M. Hicken Programming 2 16-02-2005 21:59
Software Issue patTeam241 Programming 0 28-01-2005 17:12
Lead-Lag Compensator eSouL Control System 0 13-08-2004 03:21
Less lag animation. Psy Guy 3D Animation and Competition 6 22-04-2003 00:18


All times are GMT -5. The time now is 19:09.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi