Go to Post FIRST is just a single step in a multi-step process. Rome wasn't built in a day, and neither are solutions to the world's problems. - Tim Baird [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 12-03-2008, 00:32
willson.thomas willson.thomas is offline
Registered User
FRC #1595
 
Join Date: Feb 2008
Location: Spokane, WA
Posts: 50
willson.thomas is just really nicewillson.thomas is just really nicewillson.thomas is just really nicewillson.thomas is just really nicewillson.thomas is just really nice
Inverting the direction of a Motor

I know this has probably been answered several times elsewhere in the forums, but I can't for the life of me find where.

I am trying to reverse a motor in software. I have two motors connected to a single axle and want to reverse one of them. I want to use the y axis of joystick no. 2.

I realize that the same thing could be accomplished by reversing the + and - wires on one of the motors but IMHO it is better to do this in the code.

Thanks,
Tom
  #2   Spotlight this post!  
Unread 12-03-2008, 00:40
GRS GRS is offline
Registered User
FRC #1764
 
Join Date: Jan 2008
Location: KC, MO
Posts: 34
GRS is an unknown quantity at this point
Re: Inverting the direction of a Motor

pwm01 = 255 - pwm01
  #3   Spotlight this post!  
Unread 12-03-2008, 00:43
willson.thomas willson.thomas is offline
Registered User
FRC #1595
 
Join Date: Feb 2008
Location: Spokane, WA
Posts: 50
willson.thomas is just really nicewillson.thomas is just really nicewillson.thomas is just really nicewillson.thomas is just really nicewillson.thomas is just really nice
Re: Inverting the direction of a Motor

Thank you very much. Knew it should be pretty simple to do.
  #4   Spotlight this post!  
Unread 12-03-2008, 00:47
GRS GRS is offline
Registered User
FRC #1764
 
Join Date: Jan 2008
Location: KC, MO
Posts: 34
GRS is an unknown quantity at this point
Re: Inverting the direction of a Motor

No problem =)
  #5   Spotlight this post!  
Unread 12-03-2008, 01:16
eugenebrooks eugenebrooks is offline
Team Role: Engineer
AKA: Dr. Brooks
no team (WRRF)
 
Join Date: Jan 2004
Rookie Year: 2001
Location: Livermore, CA
Posts: 601
eugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond reputeeugenebrooks has a reputation beyond repute
Re: Inverting the direction of a Motor

An error here and you could release the magic smoke...

Eugene
  #6   Spotlight this post!  
Unread 12-03-2008, 11:06
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: Inverting the direction of a Motor

Quote:
Originally Posted by willson.thomas View Post
I know this has probably been answered several times elsewhere in the forums, but I can't for the life of me find where.

I am trying to reverse a motor in software. I have two motors connected to a single axle and want to reverse one of them. I want to use the y axis of joystick no. 2.

I realize that the same thing could be accomplished by reversing the + and - wires on one of the motors but IMHO it is better to do this in the code.

Thanks,
Tom
These might seem unrelated, but be sure to calibrate your speed controllers when you do this.

The reason is, the Victors don't seem to behave exactly the same backwards and forwards out of the box. We've noticed that setting a PWM to 178 and 78 don't produce close to the same speeds in opposite directions... until you calibrate the Victor.
__________________
In life, what you give, you keep. What you fail to give, you lose forever...
  #7   Spotlight this post!  
Unread 12-03-2008, 11:09
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,186
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: Inverting the direction of a Motor

PHP Code:
pwm01 p2_y;
pwm02 = ~p2_y
This flips all of the bits, so realistically it does the same as (255-p2_y).

Last edited by Tom Bottiglieri : 12-03-2008 at 11:15.
  #8   Spotlight this post!  
Unread 12-03-2008, 11: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: Inverting the direction of a Motor

Quote:
Originally Posted by GRS View Post
pwm01 = 255 - pwm01
That should be 254, not 255. The valid range of pwm values is 0-254, and the "neutral" value is 127.

Quote:
Originally Posted by Tom Bottiglieri View Post
PHP Code:
pwm01 p2_y;
pwm02 = ~p2_y
This flips all of the bits, so realistically it does the same as (255-pwm01).
True, but that's not the desired function.

Quote:
Originally Posted by SlimBoJones View Post
These might seem unrelated, but be sure to calibrate your speed controllers when you do this.

The reason is, the Victors don't seem to behave exactly the same backwards and forwards out of the box. We've noticed that setting a PWM to 178 and 78 don't produce close to the same speeds in opposite directions... until you calibrate the Victor.
Your example numbers aren't quite right. 178 is neutral plus 51, and 78 is neutral minus 49.

But you're right about the problem -- the Victor factory calibration is a little off from the IFI pwm outputs, with its actual neutral point at more like 132. That makes your forward value at plus 46, and your reverse value at minus 54...until you calibrate the Victor.
  #9   Spotlight this post!  
Unread 12-03-2008, 12:05
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,186
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: Inverting the direction of a Motor

Quote:
Originally Posted by Alan Anderson View Post

True, but that's not the desired function.
How is it not? The problem seemed to be very clear. There are 2 motors running on a shaft. One needs to run in the opposite direction of the other. They wanted to attack the problem in software.
  #10   Spotlight this post!  
Unread 12-03-2008, 12:12
Jimmy Cao Jimmy Cao is offline
Registered User
AKA: Jimmy Cao
no team
 
Join Date: Sep 2006
Rookie Year: 2004
Location: San Francisco, CA
Posts: 295
Jimmy Cao has a brilliant futureJimmy Cao has a brilliant futureJimmy Cao has a brilliant futureJimmy Cao has a brilliant futureJimmy Cao has a brilliant futureJimmy Cao has a brilliant futureJimmy Cao has a brilliant futureJimmy Cao has a brilliant futureJimmy Cao has a brilliant futureJimmy Cao has a brilliant futureJimmy Cao has a brilliant future
Re: Inverting the direction of a Motor

I guess it's already been posted, but the following should also work.
(all words in all caps are alliases, as I do not actually know the names of all the values)


Code:
PWM_LEFT_MOTOR = STICK_FOUR_X;
PWM_RIGHT_MOTOR = 254 - STICK_FOUR_X;
__________________
Jimmy Cao

Team 469 2006-2010 Student/Alumni
Team 830 2011-2012 Mentor
  #11   Spotlight this post!  
Unread 12-03-2008, 12:19
T3_1565 T3_1565 is offline
Registered User
AKA: Twitch Drive Designer
FRC #1360
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2005
Location: Burlington, Ontario
Posts: 855
T3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant futureT3_1565 has a brilliant future
Send a message via MSN to T3_1565
Re: Inverting the direction of a Motor

I think switching the wires is the best way to go IMO, just because you don't have to worry so much about calibrating, and any wrong software will do some damage to the motors for sure.... but everything up there seems good lol I would just pwm01 = 254 - pwm01 like was said previous, if you really have a problem switching wires
  #12   Spotlight this post!  
Unread 12-03-2008, 12:38
JesseK's Avatar
JesseK JesseK is offline
Expert Flybot Crasher
FRC #1885 (ILITE)
Team Role: Mentor
 
Join Date: Mar 2007
Rookie Year: 2005
Location: Reston, VA
Posts: 3,632
JesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond reputeJesseK has a reputation beyond repute
Re: Inverting the direction of a Motor

Hmm, nevermind, it appears the Victor Calibration procedures are in the IFI manuals.
__________________

Drive Coach, 1885 (2007-present)
CAD Library Updated 5/1/16 - 2016 Curie/Carver Industrial Design Winner
GitHub

Last edited by JesseK : 12-03-2008 at 12:40.
  #13   Spotlight this post!  
Unread 12-03-2008, 13:17
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: Inverting the direction of a Motor

Quote:
Originally Posted by Alan Anderson View Post
Your example numbers aren't quite right. 178 is neutral plus 51, and 78 is neutral minus 49.
It's force of habit. We do all our logic on signed chars by subtracting 128 from the unsigned chars. It makes us off by 1 here and there, but we don't risk over or underflowing on endpoints.

Slightly off-topic, since the new controllers were introduced in 2004, I haven't had an issue with the full 0-255 range on PWM outputs. 255 seems to be a valid value, has anyone had any issues?

I haven't hit 255 on the OI analog inputs though.
__________________
In life, what you give, you keep. What you fail to give, you lose forever...

Last edited by Mr. Lim : 12-03-2008 at 13:19.
  #14   Spotlight this post!  
Unread 12-03-2008, 13:22
basicxman basicxman is offline
Emily Horsman
FRC #2200 (MMRambotics)
Team Role: Programmer
 
Join Date: Oct 2007
Rookie Year: 2007
Location: Burlington, Ontario
Posts: 971
basicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant futurebasicxman has a brilliant future
Send a message via AIM to basicxman Send a message via MSN to basicxman Send a message via Yahoo to basicxman
Re: Inverting the direction of a Motor

*sigh* that's what i love about H-Bridges, no confusing 0 to 255 just 0's and 1's
  #15   Spotlight this post!  
Unread 12-03-2008, 13:26
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
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,731
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: Inverting the direction of a Motor

Quote:
Originally Posted by SlimBoJones View Post
Slightly off-topic, since the new controllers were introduced in 2004, I haven't had an issue with the full 0-255 range on PWM outputs. 255 seems to be a valid value, has anyone had any issues?

I haven't hit 255 on the OI analog inputs though.
Any 255 set in the user code is converted by the Master to a 254 before it goes anywhere. So using 255 doesn't cause any harm, but it really becomes a 254 as soon as you hand it off via Putdata().

You'll never see an OI value of 255 arrive at your user code, no matter how hard you try.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle
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
CIM Motor Bias Direction jonboy Motors 1 28-01-2008 07:58
Ideas to move in the direction of making FIRST competitions 'fair' KenWittlief General Forum 93 07-11-2006 23:19
Conserving Energy: Stepping in the Right Direction? thegathering Chit-Chat 5 14-09-2006 14:49
Optimal Direction of the Drill and Chips mzitz2k Motors 17 06-02-2004 16:54
Motor Spin Direction archiver 2000 6 23-06-2002 23:43


All times are GMT -5. The time now is 04:44.

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