Go to Post Anything is capable of happening in FIRST. - Dorienne [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 21-12-2014, 13:24
FRC Team CC FRC Team CC is offline
Registered User
FRC #6560 (Charging Champions)
 
Join Date: Sep 2014
Rookie Year: 2012
Location: Southern California
Posts: 107
FRC Team CC is an unknown quantity at this point
Arrow [FTC]: FTC Encoder Program with Distance

Hello,

We are trying to program our Autonomous portion using distance with
TETRIX DC Motor encoders. The following is our program:

Code:
#pragma config(Hubs,  S1, HTMotor,  HTMotor,  HTServo,  HTMotor)
#pragma config(Motor,  mtr_S1_C1_2,     leftBottomDrive, tmotorTetrix, openLoop, encoder)
#pragma config(Motor,  mtr_S1_C4_1,     rightBottomDrive, tmotorTetrix, openLoop, reversed, encoder)

//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

task main()
{
	float diameterOfWheel = 3.96;//set the diameter of wheel to 3.96 inches
	float circumfirence = diameterOfWheel*PI;
	
	int distanceToGo = 12;//we want the robot to go one foot, or 12 inches
	float rotations = distanceToGo/circumfirence;
	int degreesToTurn = rotations*360;
	int encoderCounts = degreesToTurn*4;//encoder counts are in quarter degrees, so 4 encoder counts = 1 degree
	
	nMotorEncoder[leftBottomDrive] = 0;//motors do not run
	nMotorEncoder[rightBottomDrive] = 0;
	
	nMotorEncoderTarget[leftBottomDrive] = encoderCounts;//tell motors to go a foot
	nMotorEncoderTarget[rightBottomDrive] = encoderCounts;
	motor[leftBottomDrive] = 50;//go at power 50
	motor[rightBottomDrive] = 50;
	
	while(nMotorRunState[leftBottomDrive] != runStateIdle)
	{
		
	}
	motor[leftBottomDrive] = 0;//turn motors off
	motor[rightBottomDrive] = 0;
}
When testing the program, the motors drove unlimited instead of stopping after one foot.

Regards,

The Charging Champions
Reply With Quote
  #2   Spotlight this post!  
Unread 22-12-2014, 20:29
Sasha Sasha is offline
Registered User
AKA: Alexander Kirillov
FTC #4137 (IslandBots)
Team Role: Coach
 
Join Date: Sep 2010
Rookie Year: 2008
Location: Long Island, NY
Posts: 58
Sasha is just really niceSasha is just really niceSasha is just really niceSasha is just really niceSasha is just really nice
Re: [FTC]: FTC Encoder Program with Distance

In pragma, change
#pragma config(Motor, mtr_S1_C1_2, leftBottomDrive, tmotorTetrix, openLoop, encoder)
to
#pragma config(Motor, mtr_S1_C1_2, leftBottomDrive, tmotorTetrix, PIDControl, encoder)

(or just check the box "PID control" in Motor and sensor setup). Obviously, you need to do this for both motors.
__________________
FTC 4137 "Islandbots"
islandbots.org
Reply With Quote
  #3   Spotlight this post!  
Unread 23-12-2014, 12:48
FRC Team CC FRC Team CC is offline
Registered User
FRC #6560 (Charging Champions)
 
Join Date: Sep 2014
Rookie Year: 2012
Location: Southern California
Posts: 107
FRC Team CC is an unknown quantity at this point
Re: [FTC]: FTC Encoder Program with Distance

Sorry, we forgot to mention that we tried this. It worked on the right wheel, but on the left wheel, it was jerking around and did not move as smoothly.

Is this a building error or a wiring error?

Thanks,
Charging Champions
FTC Team 8660
Reply With Quote
  #4   Spotlight this post!  
Unread 23-12-2014, 15:24
Sasha Sasha is offline
Registered User
AKA: Alexander Kirillov
FTC #4137 (IslandBots)
Team Role: Coach
 
Join Date: Sep 2010
Rookie Year: 2008
Location: Long Island, NY
Posts: 58
Sasha is just really niceSasha is just really niceSasha is just really niceSasha is just really niceSasha is just really nice
Re: [FTC]: FTC Encoder Program with Distance

I'd guess a building error, but can't say without seeing the robot. Or maybe the encoder cable is damaged? if these are Tetrix motors, the encoder cable is very fragile.
__________________
FTC 4137 "Islandbots"
islandbots.org
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:54.

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