View unanswered posts | View active topics It is currently Sun Oct 25, 2020 6:35 am

Reply to topic  [ 1 post ] 
Motors acting without input 
Author Message

Joined: Wed Mar 02, 2011 1:57 pm
Posts: 2
Post Motors acting without input
Hello. Our team has been attempting to develop a program that will allow us to precisely move a motor to a certain angle. We have written the following code. The goal of the program is to have a teleop program where we can hit the up button on the d-pad(Position # 0) and the motor will move from its current position(which will always be relatively the same) to another predetermined position.

The issue we have encountered is that after we have compiled the program and try to run it the motor moves without input or commands. After we hit the Teleop Ready radio button the ArmLift motor applies full power to the motor without the program telling it to do so. This is normal for all of our programs (which is a completly different issue). Normally once we click the Teleop Running radio button the robot behaves normally. However, with these three lines of code for the encoder included the motor continues to run at power despite Teleop Running being enabled. :breakcomputer:

Other programs written work perfectly so we do not believe this to be a hardware issue. We have narrowed down the problem to be the lines of code directing the motor based on encoder position. If these lines are removed the program operates normally.

The program appears to be executing the code related to the encoders out of order and without obeying any logic. We would greatly appreciate any help you could offer as we have a competition tomorrow.

Thank you in advance,
Team 5807

#pragma config(Hubs, S1, HTMotor, HTMotor, HTServo, HTMotor)
#pragma config(Sensor, S1, , sensorI2CMuxController)
#pragma config(Motor, mtr_S1_C1_1, ScissorRight, tmotorNormal, openLoop, reversed)
#pragma config(Motor, mtr_S1_C1_2, ScissorLeft, tmotorNormal, openLoop)
#pragma config(Motor, mtr_S1_C2_1, ArmGrab, tmotorNormal, openLoop)
#pragma config(Motor, mtr_S1_C2_2, ArmLift, tmotorNormal, PIDControl, encoder)
#pragma config(Motor, mtr_S1_C4_1, DriveRight, tmotorNormal, openLoop, reversed)
#pragma config(Motor, mtr_S1_C4_2, DriveLeft, tmotorNormal, openLoop)
#pragma config(Servo, srvo_S1_C3_1, SpinRight, tServoContinuousRotation)
#pragma config(Servo, srvo_S1_C3_2, SpinLeft, tServoContinuousRotation)
#pragma config(Servo, srvo_S1_C3_3, servo3, tServoNone)
#pragma config(Servo, srvo_S1_C3_4, servo4, tServoNone)
#pragma config(Servo, srvo_S1_C3_5, servo5, tServoNone)
#pragma config(Servo, srvo_S1_C3_6, servo6, tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

#include "JoystickDriver.c"

task main()

nMotorEncoderTarget[ArmLift] = 0; //Set encoder value to 0


if(joystick.joy1_TopHat == 4) //When the POV down is pressed lower arm
motor[ArmLift] = -100;
motor[ArmLift] = 5;
motor[ArmLift] = 0;
else // If it isn't pressed, don't do anything.
motor[ArmLift] = 0;

if (joystick.joy1_TopHat == 0) //When POV down is pressed raise arm
nMotorEncoderTarget[ArmLift] = 600;
motor[ArmLift] = 50;
while(nMotorEncoder[ArmLift] <600){}
else // If it isn't pressed, don't do anything.
motor[ArmLift] = 0;


Fri Mar 16, 2012 5:52 pm
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

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.