View unanswered posts | View active topics It is currently Mon Jun 24, 2019 8:02 am






Reply to topic  [ 2 posts ] 
Servo's and other motors aren't working 
Author Message
Rookie

Joined: Sun Oct 19, 2014 5:21 pm
Posts: 7
Post Servo's and other motors aren't working
hello, ive been trying to use servos for a program, but they aren't working! I believe that my wiring is correct, and I am configured correctly, so what is the problem! Also,my 2 motors (FrontLeft and scissorlift) aren't working, but Front and back right are. heres my code

#pragma config(Hubs, S1, HTMotor, HTMotor, HTMotor, HTServo)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Sensor, S2, IR, sensorHiTechnicIRSeeker1200)
#pragma config(Motor, mtr_S1_C1_1, ScissorLift, tmotorTetrix, openLoop, reversed)
#pragma config(Motor, mtr_S1_C1_2, FrontLeft, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C2_1, RearRight, tmotorTetrix, openLoop, reversed)
#pragma config(Motor, mtr_S1_C2_2, FrontRight, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C3_1, Street, tmotorTetrix, openLoop)
#pragma config(Motor, mtr_S1_C3_2, RearLeft, tmotorTetrix, openLoop, reversed)
#pragma config(Servo, srvo_S1_C4_1, hooksrvoleft, tServoStandard)
#pragma config(Servo, srvo_S1_C4_2, hooksrvoright, tServoStandard)
#pragma config(Servo, srvo_S1_C4_3, TrapDoor, tServoNone)
#pragma config(Servo, srvo_S1_C4_4, servo4, tServoNone)
#pragma config(Servo, srvo_S1_C4_5, servo5, tServoNone)
#pragma config(Servo, srvo_S1_C4_6, servo6, tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

#include "JoystickDriver.c"

task main()
{
while(true)
{


//getJoystickSettings(joystick);
//nxtDisplayTextLine(0, "U:%s/S:%s", joystick.UserMode ? "True" : "False", joystick.StopPgm ? "True" : "False");
//nxtDisplayTextLine(1, "X1:%d / Y1:%d", joystick.joy1_x1, joystick.joy1_y1);
//nxtDisplayTextLine(2, "X2:%d / Y2:%d", joystick.joy1_x2, joystick.joy1_y2);
//nxtDisplayTextLine(3, "Btn:%d / TH:%d", joystick.joy1_Buttons, joystick.joy1_TopHat);
//nxtDisplayTextLine(4, "Counter: %d", nNoMessageCounter);
//nxtDisplayTextLine(5, "X1:%d / Y1:%d", joystick.joy2_x1, joystick.joy2_y1);
//nxtDisplayTextLine(6, "X2:%d / Y2:%d", joystick.joy2_x2, joystick.joy2_y2);
//nxtDisplayTextLine(7, "Btn:%d / TH:%d", joystick.joy2_Buttons, joystick.joy2_TopHat);
//wait1Msec(20);

getJoystickSettings(joystick);
motor[ScissorLift] = joystick.joy1_y2;
motor[RearRight] = joystick.joy1_y1; //right
motor[FrontLeft] = joystick.joy1_y1;
motor[FrontRight] = joystick.joy1_y1; //right
motor[RearLeft] = joystick.joy1_y1; // no cAble, need a motor cable
motor[Street] = joystick.joy1_x2; //right
if(joy1Btn(1) == 1)
{
servo[hooksrvoleft] = 146;
servo[hooksrvoright] = 146;
wait1Msec(200);
}
if(joy1Btn(0) == 1)
{
servo[hooksrvoleft] = 230;
servo[hooksrvoright] = 230;
wait1Msec(200);
}
if(joy1Btn(2) == 1)
{
servo[TrapDoor]= 146;
}
if(joy1Btn(3)== 1)
{
servo[TrapDoor] = 70;
}
}
}


Thu Jan 29, 2015 8:20 pm
Profile
Professor
User avatar

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Post Re: Servo's and other motors aren't working
Your code looks like it should do something. It looks like there could be a few issues with it, but nothing that should prevent the motors from moving in some way. Your servos look like they should be moving too. Just double check all of your wiring, and make sure your motors aren't burned out. As for your code, here are the minor issues that I spot:
Code:
motor[RearRight] = joystick.joy1_y1; //right
motor[FrontLeft] = joystick.joy1_y1;
motor[FrontRight] = joystick.joy1_y1; //right
motor[RearLeft] = joystick.joy1_y1; // no cAble, need a motor cable


If all four of these are your drive motors, your robot will do nothing but move in a straight line, since you are constantly setting all of them to the same power.

Code:
if(joy1Btn(0) == 1)
{
  servo[hooksrvoleft] = 230;
  servo[hooksrvoright] = 230;
  wait1Msec(200);
}

0 is not used with the joy1Btn function. You use the numbers 1-12, which correspond to buttons 1-12. It might be that you just have all of your button numbers off by one. Other than that, your code looks pretty good to get things started. By the way, also make sure that your configuration in the motors and sensors setup matches the actual configuration on your robot!

_________________
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at http://bluechariotsoffire.com/.


Tue Feb 03, 2015 10:11 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 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.