Go to Post Thank you GDC, for keeping everyone honest! - dtengineering [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 15-02-2006, 14:54
Pittiho Pittiho is offline
Registered User
FRC #1228
 
Join Date: Feb 2006
Location: New Jersey
Posts: 3
Pittiho is an unknown quantity at this point
Re: Control Problems

IN RESPONSE TO:
"When I encounter problems like this where I'm not sure if my logic or formulas are working I create some test cases on paper with real numbers and see what happens. When I do the math on the original code it appears to me that the steering is reversed - based on the comments! But I don't have a working robot in front of me to verify."



Hi my name is Holly, I am a mentor for team 1228, (the team with this problem) and I have taken your advice and plugged these numbers into the formula, and it seems like the formula creates the backward turning that we are experiencing...
If I put in a value for full power to the right (x axis=255) and neutral on fwd/rev (y axis=127). THe values that the program returns are (right motors=full power=255) BUT...that would make the robot go into a LEFT spin (correct)? Because the right wheels are in full forward motion?
  #2   Spotlight this post!  
Unread 15-02-2006, 15:23
Mark Pierce Mark Pierce is offline
Registered User
FRC #0085 (B. O. B.)
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 1999
Location: Zeeland, MI
Posts: 239
Mark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant future
Re: Control Problems

Quote:
If I put in a value for full power to the right (x axis=255)...
I believe that the OI for the Joysticks generate around 255 when pressed to the left, not right. A simple print statement or assigning the user_byte to the p1_x value should confirm this quite quickly.

If the wiring is done such that the motors spin the opposite way from what we want with the Joystick centered left to right, we change the motor wiring. Keeping 254 meaning forward on both sides just makes more sense when debugging.

In looking through this thread it appears to me that in inverted's posts there are signs wrong on the p1_x term. One of the choices presented by Keith Watson in his second post should be the correct solution. It matches what we've done for years.
  #3   Spotlight this post!  
Unread 19-02-2006, 19:28
Keith Watson Keith Watson is offline
Registered User
FRC #0957 (WATSON)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2006
Location: Wilsonville, OR
Posts: 112
Keith Watson is just really niceKeith Watson is just really niceKeith Watson is just really niceKeith Watson is just really nice
Re: Control Problems

Quote:
Originally Posted by Mark Pierce
I believe that the OI for the Joysticks generate around 255 when pressed to the left, not right.
We verified this yesterday during testing. Y forward is 255 and X left is 255.
__________________
Keith Watson - Professional Software Engineer
No relation to "Kevin" Watson, who created the camera tracking code.
  #4   Spotlight this post!  
Unread 15-02-2006, 15:28
Mark McLeod's Avatar
Mark McLeod Mark McLeod is online now
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,792
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Control Problems

It sounds like your y-axis is correct (forward is forward, back is back), but your x-axis, which controls the turn, needs to be reversed.

Prior to the mixing equation you can use p1_x = 254 - p1_x to reverse the direction of your turn.

e.g.,
Code:
p1_x = 254 - p1_x;
pwm13 = pwm14 = Limit_Mix(2000 + p1_y + p1_x - 127);
pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 15-02-2006 at 15:40.
  #5   Spotlight this post!  
Unread 15-02-2006, 18:53
Keith Watson Keith Watson is offline
Registered User
FRC #0957 (WATSON)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2006
Location: Wilsonville, OR
Posts: 112
Keith Watson is just really niceKeith Watson is just really niceKeith Watson is just really niceKeith Watson is just really nice
Re: Control Problems

Quote:
Originally Posted by Pittiho
...and I have taken your advice and plugged these numbers into the formula, and it seems like the formula creates the backward turning that we are experiencing...
That is also what I got from looking at the default code. I cannot check why since it will be a few days before I see the bot again. Maybe our team simply switched the left and right motor wires?

To figure out why though, go through the debug process of checking front to back how things are used. Check the joystick direction as Mark indicated. When we calibrated our joysticks x was not backward. Check if the pwm outputs used in the code for left are really wired to the left motors. Etc.
__________________
Keith Watson - Professional Software Engineer
No relation to "Kevin" Watson, who created the camera tracking code.
  #6   Spotlight this post!  
Unread 20-02-2006, 04:06
jrmarenda jrmarenda is offline
Registered User
AKA: Jason Marenda
FRC #1887 (Russet Robotix)
Team Role: Engineer
 
Join Date: Nov 2004
Rookie Year: 2005
Location: Pocatello, ID
Posts: 8
jrmarenda will become famous soon enough
Re: Control Problems

This shoudl fix your problem:
pwm13 = pwm14 = Limit_Mix(2000 - p1_y - p1_x + 381);
pwm15 = pwm16 = Limit_Mix(2000 + p1_y - p1_x + 127);

I had the same problem, and figured out the answer by simply setting up a table with actual and desired values using the dashboard viewer. I have tried this on our robot and it works. Le t me know if it doesn't work out for you.
  #7   Spotlight this post!  
Unread 20-02-2006, 04:27
Matt Krass's Avatar
Matt Krass Matt Krass is offline
"Old" and Cranky. Get off my lawn!
AKA: Dark Ages
FRC #0263 (Sachem Aftershock)
Team Role: Mentor
 
Join Date: Oct 2002
Rookie Year: 2002
Location: Long Island, NY
Posts: 1,187
Matt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond repute
Send a message via AIM to Matt Krass
Re: Control Problems

I'd also have to recommend moving to different PWMs if there is anyway possible, those are flaky, since they're generated in software rather than hardware, any code lag disrupts them, quite unreliable.
__________________
Matt Krass
If I suggest something to try and fix a problem, and you don't understand what I mean, please PM me!

I'm a FIRST relic of sorts, I remember when we used PBASIC and we got CH Flightsticks in the KoP. In my day we didn't have motorized carts, we pushed our robots uphill, both ways! (Houston 2003!)
  #8   Spotlight this post!  
Unread 15-02-2006, 18:17
Inverted Inverted is offline
Registered User
AKA: Eric P.
FRC #1228 (Robo Tribe)
Team Role: College Student
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Rahway, NJ
Posts: 25
Inverted is an unknown quantity at this point
Send a message via AIM to Inverted
Re: Control Problems

Quote:
Originally Posted by hoag
If anything is moving in the wrong direction, you could just subtract the Limit_Mix result from 254. (To reverse direction)

for the right motor I use
(254-(Limit_Mix(2000 + p1_y + p1_x - 127)));


for the left motor I use
(Limit_Mix(2000 + p1_y - p1_x + 127));


I've used this setup for all of my team's robots.
Just tried it, and that works for me, too. Thanks a lot!

One more quick question. We have a motor on the bot that we don't need on all the time, just to save battery power. I wired a toggle switch so that when it's turned on, it shows up as the trigger button of a joystick being held on. Is there any way I can set a PWM to be equal to the y-axis of a joystick, ONLY when the switch is on, and then neutral when it's off? Here's the idea I had:
Code:
int my_y;

pwm02 = my_y;
if (p3_sw_trig==1){
 my_y = p2_y;
}
else {
 my_y == 127;
}
Chances are it's completely wrong, but...
  #9   Spotlight this post!  
Unread 15-02-2006, 18:37
Keith Watson Keith Watson is offline
Registered User
FRC #0957 (WATSON)
Team Role: Mentor
 
Join Date: Feb 2006
Rookie Year: 2006
Location: Wilsonville, OR
Posts: 112
Keith Watson is just really niceKeith Watson is just really niceKeith Watson is just really niceKeith Watson is just really nice
Re: Control Problems

Quote:
Originally Posted by Inverted
Code:
int my_y;

pwm02 = my_y;
if (p3_sw_trig==1){
 my_y = p2_y;
}
else {
 my_y = 127;
}
Chances are it's completely wrong, but...
That is the right idea. Just change the red thing from comparison to assignment.
__________________
Keith Watson - Professional Software Engineer
No relation to "Kevin" Watson, who created the camera tracking code.
  #10   Spotlight this post!  
Unread 16-02-2006, 09:30
Mark Pierce Mark Pierce is offline
Registered User
FRC #0085 (B. O. B.)
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 1999
Location: Zeeland, MI
Posts: 239
Mark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant futureMark Pierce has a brilliant future
Re: Control Problems

I'd also move the pwm assignment to after the if statement. Otherwise, there will be an additional cycle delay in your response, since the pwm will reflect the old value from the if statement.

The my_y value could be defined as an unsigned character (8 bits) instead of int. It's not essential, but it is good practice to match variable types.

Code:
unsigned char my_y;

if (p3_sw_trig==1) {
    my_y = p2_y;
}
else {
    my_y = 127;
}
pwm02 = my_y;
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
Concept of PID explained ConKbot of Doom Technical Discussion 11 27-01-2008 00:11
Electronic Speed Control Problems DustinB_3 Electrical 9 09-11-2005 23:42
Pre-manufactured control box for FIRST Ben.V.293 Technical Discussion 19 22-08-2005 12:53
2005 RadioShack Innovation In Control Award--What Won? Billfred Control System 8 12-06-2005 01:51
Robot Rodeo - fixing control problems Gary Dillard Off-Season Events 7 26-10-2004 00:46


All times are GMT -5. The time now is 18:01.

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