|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
|||
|
|||
|
Re: Inverting the direction of a Motor
pwm01 = 255 - pwm01
|
|
#3
|
|||
|
|||
|
Re: Inverting the direction of a Motor
Thank you very much. Knew it should be pretty simple to do.
|
|
#4
|
|||
|
|||
|
Re: Inverting the direction of a Motor
No problem =)
|
|
#5
|
|||
|
|||
|
Re: Inverting the direction of a Motor
An error here and you could release the magic smoke...
Eugene |
|
#6
|
||||
|
||||
|
Re: Inverting the direction of a Motor
Quote:
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. |
|
#7
|
|||
|
|||
|
Re: Inverting the direction of a Motor
PHP Code:
Last edited by Tom Bottiglieri : 12-03-2008 at 11:15. |
|
#8
|
|||||
|
|||||
|
Re: Inverting the direction of a Motor
That should be 254, not 255. The valid range of pwm values is 0-254, and the "neutral" value is 127.
Quote:
Quote:
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
|
|||
|
|||
|
Re: Inverting the direction of a Motor
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
|
|||
|
|||
|
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; |
|
#11
|
|||
|
|||
|
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
|
||||
|
||||
|
Re: Inverting the direction of a Motor
Hmm, nevermind, it appears the Victor Calibration procedures are in the IFI manuals.
Last edited by JesseK : 12-03-2008 at 12:40. |
|
#13
|
||||
|
||||
|
Re: Inverting the direction of a Motor
Quote:
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. Last edited by Mr. Lim : 12-03-2008 at 13:19. |
|
#14
|
|||
|
|||
|
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
|
|||||
|
|||||
|
Re: Inverting the direction of a Motor
Quote:
You'll never see an OI value of 255 arrive at your user code, no matter how hard you try. ![]() |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
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 |