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

Servo's and other motors aren't working
http://robotc.net/forums/viewtopic.php?f=1&t=10405
Page 1 of 1

Author:  frogsam5 [ Thu Jan 29, 2015 8:20 pm ]
Post subject:  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;
}
}
}

Author:  BurningLights [ Tue Feb 03, 2015 10:11 pm ]
Post subject:  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!

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