Go to Post Every event that starts with "a little bit of fun" has the potential to end in disaster. Please think about all possible outcomes before you do anything stupid. - sanddrag [more]
Home
Go Back   Chief Delphi > Technical > Control System > FRC Control System
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 28-01-2010, 16:13
Darkknight512 Darkknight512 is offline
Programmer/Electronics
FRC #3375 (North Stars)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Canada
Posts: 26
Darkknight512 is on a distinguished road
Inverted Turning

Our robot goes forward and backwards fine, but right=left and left=right. It appears the speed controllers are wired properly, if did notice however that the LED on the speed controller is flashing green on one and red on one when the stick is pushed forward and the robot is going forward. To verify that it was not an electrical problem i reversed the leads from one of the motors then forward and backward = turn and vice versa.

This is for 2 motor drive, left = PWM 1, right = PWM 2. This is with the simple robot template.

I did verify that the speed controller's + and - are wired correctly and the motor's are wired in the same direction (+ to red and - to black)

I just don't know whats going on. Any help is appreciated, I just got the camera to work and here we are another problem...
Reply With Quote
  #2   Spotlight this post!  
Unread 28-01-2010, 16:27
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Inverted Turning

The reason one speed controller goes green and the other goes red is that the motors need to turn in opposite directions for the wheels to go in the same direction. That's not a problem.

Can you make absolutely certain that the PWM cables are going to the speed controllers they ought to? (If you accidentally swap the cables between PWM1 and PWM2, the robot will behave as you observe.)
Reply With Quote
  #3   Spotlight this post!  
Unread 28-01-2010, 16:32
Darkknight512 Darkknight512 is offline
Programmer/Electronics
FRC #3375 (North Stars)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Canada
Posts: 26
Darkknight512 is on a distinguished road
Re: Inverted Turning

Quote:
Originally Posted by Alan Anderson View Post
The reason one speed controller goes green and the other goes red is that the motors need to turn in opposite directions for the wheels to go in the same direction. That's not a problem.

Can you make absolutely certain that the PWM cables are going to the speed controllers they ought to? (If you accidentally swap the cables between PWM1 and PWM2, the robot will behave as you observe.)
I did swap them to test, and instead of inverting the turning it inverted forward and backward. I tried this in both software and hardware (rebooting the cRIO in between to be sure the code changed, also verified that by changing something in autonomous to confirm the code made it. ).

I'll give it another try tmrw, I just got home, internet at school was a bit funky.

Last edited by Darkknight512 : 28-01-2010 at 16:38.
Reply With Quote
  #4   Spotlight this post!  
Unread 29-01-2010, 09:59
Darkknight512 Darkknight512 is offline
Programmer/Electronics
FRC #3375 (North Stars)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Canada
Posts: 26
Darkknight512 is on a distinguished road
Re: Inverted Turning

I flipped the PWM's again just now, the robot just inverts forward and backwards now.
Reply With Quote
  #5   Spotlight this post!  
Unread 29-01-2010, 10:04
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,567
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Inverted Turning

I find that it's a lot easier to diagnose these issues in tank drive rather then arcade, because it's easier to see the input directly affect the output. In tank mode, once the correct side goes forward at the correct time, then arcade mode will work properly.
Reply With Quote
  #6   Spotlight this post!  
Unread 29-01-2010, 11:01
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Inverted Turning

Quote:
Originally Posted by Darkknight512 View Post
I flipped the PWM's again just now, the robot just inverts forward and backwards now.
Don't just blindly start swapping things around. Look at how the program has the left and right motors defined, and make sure those are the motors actually being controlled by the relevant PWM outputs. You have to make the code consistent with physical reality.

Then, when you find that a motor is going in the direction opposite the way you think it should, change the "Invert" constant for that motor on the Drive Open vi.

(If you have wired the motors the way I think is most natural, the left motor should not be inverted and the right one should be. It's possible that your wiring is backwards from the way I expect, or perhaps your gearboxes are doing an extra reversal from the actual motor direction. It's not really important which one is which, only that the wheels go in the direction you want them to.)
Reply With Quote
  #7   Spotlight this post!  
Unread 29-01-2010, 12:37
Darkknight512 Darkknight512 is offline
Programmer/Electronics
FRC #3375 (North Stars)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Canada
Posts: 26
Darkknight512 is on a distinguished road
Re: Inverted Turning

Quote:
Originally Posted by Alan Anderson View Post
Don't just blindly start swapping things around. Look at how the program has the left and right motors defined, and make sure those are the motors actually being controlled by the relevant PWM outputs. You have to make the code consistent with physical reality.

Then, when you find that a motor is going in the direction opposite the way you think it should, change the "Invert" constant for that motor on the Drive Open vi.

(If you have wired the motors the way I think is most natural, the left motor should not be inverted and the right one should be. It's possible that your wiring is backwards from the way I expect, or perhaps your gearboxes are doing an extra reversal from the actual motor direction. It's not really important which one is which, only that the wheels go in the direction you want them to.)
How would I invert the motors in C++?

By my understanding shoulden't the robot invert its turning if I switch the PWM channels? It doesn't seem to make sense to me that the robot goes backwards when the PWM's are switched.

Last edited by Darkknight512 : 29-01-2010 at 13:33.
Reply With Quote
  #8   Spotlight this post!  
Unread 04-02-2010, 17:39
Darkknight512 Darkknight512 is offline
Programmer/Electronics
FRC #3375 (North Stars)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Canada
Posts: 26
Darkknight512 is on a distinguished road
Re: Inverted Turning

Ive tried to switch the motors and use setinverted motor. It still seems to turn the wrong way, forwards and backwards seems to be right though...
Reply With Quote
  #9   Spotlight this post!  
Unread 04-02-2010, 22:04
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Inverted Turning

Quote:
Originally Posted by Darkknight512 View Post
It doesn't seem to make sense to me that the robot goes backwards when the PWM's are switched.
Think about which way the motors turn in order for the robot to move forwards. Drivetrain designs with both motors going the same direction are vanishingly rare. Almost invariably, one spins clockwise and the other spins counterclockwise.

When you swap the motor control, you're telling each motor to turn the way the other one used to. That runs the robot in the other direction.

Just look at the code, and at the robot wiring, and make sure that the PWM signal configured as the left motor is the same one physically connected to the left motor. Do the same for the right motor. Then if either side of the robot runs in the wrong direction, invert that motor's control in the code.
Reply With Quote
  #10   Spotlight this post!  
Unread 05-02-2010, 19:37
Darkknight512 Darkknight512 is offline
Programmer/Electronics
FRC #3375 (North Stars)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Canada
Posts: 26
Darkknight512 is on a distinguished road
Re: Inverted Turning

Quote:
Originally Posted by Alan Anderson View Post
Think about which way the motors turn in order for the robot to move forwards. Drivetrain designs with both motors going the same direction are vanishingly rare. Almost invariably, one spins clockwise and the other spins counterclockwise.

When you swap the motor control, you're telling each motor to turn the way the other one used to. That runs the robot in the other direction.

Just look at the code, and at the robot wiring, and make sure that the PWM signal configured as the left motor is the same one physically connected to the left motor. Do the same for the right motor. Then if either side of the robot runs in the wrong direction, invert that motor's control in the code.
It appears the motor is turning the right way, I have checked PWM 1 is connected to left motor and PWM 2 is connected to the right motor.

Both motors seems to be turning in the right direction, else the bot would be going backwards. The bot still turns the wrong way.
Reply With Quote
  #11   Spotlight this post!  
Unread 05-02-2010, 23:08
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,112
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Inverted Turning

Quote:
Originally Posted by Darkknight512 View Post
It appears the motor is turning the right way, I have checked PWM 1 is connected to left motor and PWM 2 is connected to the right motor.

Both motors seems to be turning in the right direction, else the bot would be going backwards. The bot still turns the wrong way.
If you're confident that the wiring is correct, then let's go ahead and look at the programming. Have you changed anything from the defaults? Show us how you're initializing the drive motors, and how you're controlling them.
Reply With Quote
  #12   Spotlight this post!  
Unread 06-02-2010, 17:23
Darkknight512 Darkknight512 is offline
Programmer/Electronics
FRC #3375 (North Stars)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Canada
Posts: 26
Darkknight512 is on a distinguished road
Re: Inverted Turning

PWM 1 is connected to the Jaguar controlling the LEFT motor, and PWM is controlling the RIGHT motor

This is the whole program

Quote:
#include "WPILib.h"
#include "vxWorks.h"
#include "Vision/AxisCamera2010.h"
#include "PCVideoServer.h"

class RobotDemo : public SimpleRobot
{
RobotDrive myRobot; // robot drive system
Joystick stick;

Compressor airc;

public:
RobotDemo(void):
myRobot(1, 2), // these must be initialized in the same order
stick(1), // as they are declared above.

airc(1,1)
{

GetWatchdog().SetExpiration(1.0);
GetWatchdog().SetEnabled(false);

AxisCamera &camera = AxisCamera::getInstance();
camera.writeResolution(k640x480);
camera.writeBrightness(10);
camera.writeCompression(25);

airc.Start();
}

void Autonomous(void)
{
GetWatchdog().SetEnabled(false);
Solenoid *s1;
Solenoid *s2;

s1 = new Solenoid(1);
s2 = new Solenoid(2);

Wait(3.000);
s1->Set(true);
s2->Set(false);
Wait(3.000);
s1->Set(false);
s2->Set(true);
}

void OperatorControl(void)
{
GetWatchdog().SetEnabled(true);
while (IsOperatorControl())
{
GetWatchdog().Feed();
myRobot.ArcadeDrive(stick); // drive with arcade style (use right stick)
Wait(0.005); // wait for a motor update time
}
}
};

START_ROBOT_CLASS(RobotDemo);
Reply With Quote
Reply


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
Setting inverted motor help kiettyyyy C/C++ 1 14-01-2009 19:09
pic: lego inverted pendulum colin340 Extra Discussion 6 01-02-2007 14:56
Inverted color mind tricks! thegathering Chit-Chat 19 31-08-2006 18:05
Camera Picture is Inverted winners Programming 2 27-01-2006 20:09
IR signals inverted Atheist Electrical 10 08-02-2004 16:27


All times are GMT -5. The time now is 23:24.

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