View unanswered posts | View active topics It is currently Thu Jun 21, 2018 9:42 pm

Reply to topic  [ 2 posts ] 
encoder targets 
Author Message

Joined: Mon Dec 14, 2009 8:29 pm
Posts: 6
Post encoder targets
Hey. I've been trying to work this out for awhile now. I have a tetrix mortor that i want to run for about 1 half of a turn, but instead it either goes forever or just randomly runs. If i change the value the motor always moves the same difference just at a different speed. My code looks like this:
    if (joy1Btn(6))                         
      nMotorEncoderTarget[Kicker] = 200;     
      motor[Kicker] = 100;                 
      wait10Msec (1000);                 
      nMotorEncoder[Kicker] = 0;           
      motor[Kicker] = 0;                 

I was hoping someone might be able to help me figure out what im doing wrong. Also, how many encoder counts in a single rotation?

Tue Mar 02, 2010 7:39 pm

Joined: Sat Feb 20, 2010 11:06 pm
Posts: 4
Post Re: encoder targets
I looked at your code and the problems I saw were that if this is an auto mode there can't be a button vaule about the kicker doing different things is because you need to zero out the encoders. here is a simple program showing that hope this helps.


#pragma config(Hubs,  S1, HTMotor,  none,     none,     none)
#pragma config(Motor,  motorA,          ,              tmotorNormal, PIDControl, reversed, encoder)
#pragma config(Motor,  mtr_S1_C1_1,     kicker,        tmotorNormal, PIDControl, encoder)
#pragma config(Motor,  mtr_S1_C1_2,     motorE,        tmotorNormal, PIDControl, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

#include "JoystickDriver.c"  //Include file to "handle" the Bluetooth messages.

void initializeRobot()
   motor[kicker] = 0;


task main()
   //Motor control variables
   int kickerSpeed = 70; // this is the motor speed a vaule under 75 is more consistant but can be changed
   int pauseTime = 100;

   //Variable action list       //this number may be changed depending what you want to do
   int kickForwardCount = 720;

   // the number 720 comes from the number 1440, while using tetrix encoders the vaules are 360 rotations and then multipled by 4.


  waitForStart(); // Wait for the beginning of autonomous phase.

  /////              Kick                /////

  nMotorEncoder[kicker] = 0; // it is important to zero the encoders to get the same results everytime

  while(nMotorEncoder[kicker] < kickForwardCount)
      motor[kicker] = kickerSpeed; // if the kicker is kicking the wrong way change the kickerSpeed to "-70"
   motor[kicker] = 0;



Wed Mar 03, 2010 9:24 pm
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.