View unanswered posts | View active topics It is currently Mon Sep 01, 2014 7:20 am






Reply to topic  [ 2 posts ] 
Problem with RobotC servo code 
Author Message
Rookie

Joined: Fri Jan 10, 2014 5:09 pm
Posts: 1
Post Problem with RobotC servo code
I'm currently trying to program my team's robot's arm. The arm has two servos. I want each servo to move up or down and then stay in the position it moves to using the d-pad or using the A and B buttons. This is the code I'm using - the part of the code that controls servoWrist works, but the part that controls servoElbow does not. I'm fairly certain it's not a problem with hardware - I've tested three different servos using each section of code and all three work with the servoWrist code, but not with the servoElbow code. I also tried using port three instead of port two for the servoElbow code, but that did not help either, so I believe it's not an issue with the servo controller. I'm currently really confused by this because as far as I can tell, the two sections of code are identical.

Code:
#pragma config(Hubs,  S1, HTMotor,  HTServo,  none,     none)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Motor,  mtr_S1_C1_1,     motorD,        tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C1_2,     motorE,        tmotorTetrix, openLoop)
#pragma config(Servo,  srvo_S1_C2_1,    servoWrist,           tServoStandard)
#pragma config(Servo,  srvo_S1_C2_2,    servoElbow,           tServoStandard)
#pragma config(Servo,  srvo_S1_C2_3,    servo3,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_4,    servo4,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_5,    servo5,               tServoNone)
#pragma config(Servo,  srvo_S1_C2_6,    servo6,               tServoNone)
//*!!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

  while (true)
  {
   getJoystickSettings(joystick);
      int wristVariable;
            int elbowVariable;
      int wristHelp;
      int elbowHelp;

      if(joystick.joy1_TopHat == 4)
      {
         wristVariable = wristHelp;
         wristHelp = wristHelp + 1;
         wait1Msec(10);
      }
      
                if(joystick.joy1_TopHat == 0)
      {
         wristVariable = wristHelp;
         wristHelp = wristHelp - 1;
         wait1Msec(10);
      }

         servo[servoWrist]= wristHelp;

      if(joy1Btn(2))
      {
         elbowVariable = elbowHelp;
         elbowHelp = elbowHelp + 1;
         wait1Msec(10);
      }
      if(joy1Btn(4))
      {
         elbowVariable = elbowHelp;
         elbowHelp = elbowHelp - 1;
         wait1Msec(10);
      }

         servo[servoElbow]= elbowHelp;
  }
}


Fri Jan 10, 2014 5:13 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Problem with RobotC servo code
What do you mean by "not working"? Do you mean the elbow did not move? If so, I would guess the elbow is a lot heavier than the wrist and the servo is not strong enough to raise it. You can easily try it by plugging in a standalone servo to channel two without hooking it up to the arm mechanically. Then run your code and see if the elbow code will move that servo. If it does move the servo but not when it is mechanically hooked to the arm, then you know the code works just not strong enough to lift the elbow.


Sat Jan 11, 2014 6:56 am
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.