View unanswered posts | View active topics It is currently Sat Mar 28, 2015 7:51 pm






Reply to topic  [ 5 posts ] 
dual motor drive 
Author Message
Rookie

Joined: Wed Feb 11, 2015 12:22 pm
Posts: 3
Post 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?


Wed Feb 11, 2015 1:06 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1511
Post 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?


Wed Feb 11, 2015 3:24 pm
Profile
Rookie

Joined: Wed Feb 11, 2015 12:22 pm
Posts: 3
Post 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


Wed Feb 11, 2015 4:40 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 670
Post 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.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our updated help documentation and the ROBOTC Forums.


Wed Feb 11, 2015 5:19 pm
Profile
Rookie

Joined: Wed Feb 11, 2015 12:22 pm
Posts: 3
Post Re: dual motor drive
thank ya both! got it fixed, turned out that the correct side was not reversed on both as mentioned above.


Fri Feb 13, 2015 5:17 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.