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

Servos with two controllers
http://www.robotc.net/forums/viewtopic.php?f=52&t=881
Page 1 of 1

Author:  118steelhornets [ Mon Nov 03, 2008 11:04 am ]
Post subject:  Servos with two controllers

can anyone show me how to create a program to control three servos and two dc motors on two controllers? (motors on one and servos on the other)

here's what i have so far
Code:
#pragma config(Hubs,  S1, HTMotor,  HTServo,  none,     none)
#pragma config(Motor,  mtr_S1_C1_1,     right,         tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C1_2,     left,          tmotorNormal, openLoop)
#pragma config(Servo,  servo1,          lower_arm_right,      tServoNormal)
#pragma config(Servo,  servo2,          lower_arm_left,       tServoNormal)
#pragma config(Servo,  servo3,          middle_arm,           tServoNormal)
#pragma config(Servo,  servo4,          bucket,               tServoNormal)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "JoystickDriver.c"

task main()
{
   while (true)
   {
        getJoystickSettings(joystick);
        motor[left] = joystick.joy1_y1;
         motor[right] = joystick.joy1_y2;
   }
  while (true)
  {
    getJoystickSettings(joystick);

      if(joy2Btn(4) !=0);
       {
         servoTarget[lower_arm_right] = 150;
       }
       if(joy2Btn(2) !=0)
       {
         servoTarget[lower_arm_right] = 0;
       }
       if(joy2Btn(4) !=0);
       {
         servoTarget[lower_arm_left] = 150;
       }
       if(joy2Btn(2) !=0);
       {
         servoTarget[lower_arm_left] = 0;
       }
       if(joy2Btn(5) !=0);
       {
         servoTarget[middle_arm] = 150;
       }
       if(joy2Btn(7) !=0)
       {
         servoTarget[middle_arm] = 0;
       }
       if(joy2Btn(6) !=0)
       {
         servoTarget[bucket] = 150;
       }
       if(joy2Btn(8) !=0)
       {
         servoTarget[bucket] = 0;
       }
   }
}
//Admin Edit for readability

we need this ASAP

if you can tell me what is wrong would be GREAT!!! or if you want to fix it go ahead!

Author:  starwarslegokid [ Mon Nov 03, 2008 4:41 pm ]
Post subject:  Re: Servos with two controllers

Sounds like you are doing this for FTC, Im going to move this over to that topic section B-)

Scott

Author:  jyoungj [ Wed Nov 05, 2008 3:18 pm ]
Post subject:  Re: Servos with two controllers

in the brackets after servotarget you need to say which servo you want to move unless the name you have in the bracket is the name you gave it. is it? if so just put in: servo# (#=the # of servo) and see if that works :wink: :bigthumb:

Author:  Sunny1261 [ Wed Nov 05, 2008 9:04 pm ]
Post subject:  Re: Servos with two controllers

Uh, 2 things.

1. When you post, try and keep the formatting and use whitespace. It helps the people who are trying to help you.

2. it seems like you have 2 while(true) statements...the 2nd while statement won't run...unless it's some sort of tasking thing that IDK about.

Author:  Jeff McBride [ Thu Nov 06, 2008 12:06 am ]
Post subject:  Re: Servos with two controllers

Change this:
Code:
task main()
{
while (true)
{
getJoystickSettings(joystick);
motor[left] = joystick.joy1_y1;
motor[right] = joystick.joy1_y2;
}
while (true)
{
getJoystickSettings(joystick);

if(joy2Btn(4) !=0);
...


to this:

Code:
task main()
{
while (true)
{
getJoystickSettings(joystick);
motor[left] = joystick.joy1_y1;
motor[right] = joystick.joy1_y2;

if(joy2Btn(4) !=0)
...


Also note that your if() statements that have semicolons on the end are not going to do what you expect.

Author:  tfriez [ Thu Nov 06, 2008 4:36 pm ]
Post subject:  Re: Servos with two controllers

Also getting rid of the "!= 0" and just leaving statements as "joy1Btn(btn)" may help as well.

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