Go to Post Every freshman or first time FIRST student comes onto the team with little to no experience. The whole point is that you will get to learn how to do some new things. - engunneer [more]
Home
Go Back   Chief Delphi > Other > FIRST Tech Challenge
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 10-01-2014, 17:02
FTC4211's Avatar
FTC4211 FTC4211 is offline
Registered User
AKA: John Stegeman
FTC #4211 (The Bombers)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2010
Location: Missouri
Posts: 11
FTC4211 is an unknown quantity at this point
Re: [FTC]: Problem with RobotC servo code

Hello,

One of the problems with the code you have listed is that wristHelp and elbowHelp never gets initialized with a value after it is created at the beginning of the loop and as such their values are undefined, yet you use them to assign a value to the servos.


This code does the same thing functionally as what you wanted yours to do.

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);

	if(joystick.joy1_TopHat == 4)
	{
		servo[servoWrist] = ServoValue[servoWrist]+1;
	}
	if(joystick.joy1_TopHat == 0)
	{
		servo[servoWrist] = ServoValue[servoWrist]-1;
	}

	if(joy1Btn(2))
	{
		servo[servoElbow] = ServoValue[servoElbow]+1;
	}
	if(joy1Btn(4))
	{
		servo[servoElbow] = ServoValue[servoElbow]-1;
	}
	wait1Msec(20);
		
  }
}
This code utilizes the built in servo position to increment the servo position. By using the built in variable it skips using all the extra variables minimizing the risk of errors. The delay for your servo movement is now takes care of the movement for both servos and provides a convenient spot to change the servo speeds at one single location rather than having to change it multiple locations.

Hope this works for you,
Team 4211
Reply With Quote
  #2   Spotlight this post!  
Unread 11-01-2014, 14:02
completelycrazy completelycrazy is offline
Registered User
FTC #6085
 
Join Date: Jan 2014
Location: Ohio
Posts: 2
completelycrazy is an unknown quantity at this point
Re: [FTC]: Problem with RobotC servo code

The code started working after restarting our computer. We'd already tried restarting, but apparently we needed to restart one more time. Your code is a much more elegant way of programming the servos though, thanks!
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:41.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi