ROBOTC.net forums
http://robotc.net/forums/

dual motor drive
http://robotc.net/forums/viewtopic.php?f=1&t=10516
Page 1 of 1

Author:  ftc_5891 [ Wed Feb 11, 2015 1:06 pm ]
Post subject:  dual motor drive

to drive our robot with 2 motors per side...how to program? i know that you can control "both" by combining wires into same motor port, however, i would like to know how to do it another way. basically 2 motors controlled by same joystick.
#pragma config(Hubs, S1, HTMotor, HTMotor, HTMotor, HTServo)
#pragma config(Hubs, S2, HTMotor, none, none, none)
#pragma config(Motor, mtr_S1_C1_1, driveR1, tmotorTetrix, openLoop, reversed)
#pragma config(Motor, mtr_S1_C1_2, driveR2, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C2_1, driveL1, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C2_2, driveL2, tmotorTetrix, openLoop)

//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

#include "JoystickDriver.c" //Include file to "handle" the Bluetooth messages.
void initializeRobot()
{
return;
}

task main()
{
initializeRobot();

waitForStart(); // wait for start of tele-op phase
int threshold = 20;

while(true)
{
getJoystickSettings(joystick);

if(abs(joystick.joy1_y1) > threshold)
{
motor(driveL1)= joystick.joy1_y1;
motor(driveL2)= joystick.joy1_y1;
}
else
{
motor(driveL1)=0;
motor(driveL2)=0;
}
if(abs(joystick.joy1_y2) > threshold)
{
motor(driveR1)= joystick.joy1_y2;
motor(driveR2)= joystick.joy1_y2;
}
else
{
motor(driveR1)=0;
motor(driveR2)=0;
}

this doesn't work...what can i do?

Author:  MHTS [ Wed Feb 11, 2015 3:24 pm ]
Post subject:  Re: dual motor drive

Aside from the missing of a bunch of closing braces, why would it not work? Please clarify what you meant by not working. Is it compiler error? Or did it compile okay but some motors not running? If so, which motors?

Author:  ftc_5891 [ Wed Feb 11, 2015 4:40 pm ]
Post subject:  Re: dual motor drive

compiles okay..but when we went to test, only the right side moved and the left did not.
y2=right joystick and y1=left joystick
going to check to make sure we have it set up correctly and that all wires are wired correctly into controllers

Author:  JohnWatson [ Wed Feb 11, 2015 5:19 pm ]
Post subject:  Re: dual motor drive

Check your left/right motor #pragmas:

Code:
#pragma config(Motor, mtr_S1_C1_1, driveR1, tmotorTetrix, openLoop, reversed)
#pragma config(Motor, mtr_S1_C1_2, driveR2, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C2_1, driveL1, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C2_2, driveL2, tmotorTetrix, openLoop)


driveR1 is set up as reversed, but driveL1 is not. I'm assuming the four motors are mirroring each other (with driveR1 and driveR2 on the right side, with driveL1 and driveL2 on the left side); what could be happening is that the right motors are being driven opposite directions (forward and backwards) into each other.

If the left side works properly, try unchecking the 'Reversed' checkbox in the Motors and Sensors Setup window for driveR1 to see if that resolves the issue.

Author:  ftc_5891 [ Fri Feb 13, 2015 5:17 pm ]
Post subject:  Re: dual motor drive

thank ya both! got it fixed, turned out that the correct side was not reversed on both as mentioned above.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/