View unanswered posts | View active topics It is currently Tue Sep 16, 2014 5:30 pm






Reply to topic  [ 3 posts ] 
Matrix motors & nMotorEncoderTarget 
Author Message
Rookie

Joined: Mon Jan 27, 2014 7:29 am
Posts: 1
Post Matrix motors & nMotorEncoderTarget
Hi

We are having no end of trouble with our Matrix motors in RobotC. Has anyone been able to get them working at all?
Our test code looks like this
Code:
Code:
#pragma config(Hubs,  S1, MatrxRbtcs, none,     none,     none)
#pragma config(Sensor, S1,     ,               sensorI2CMuxController)
#pragma config(Motor,  motorA,          BeaterLeft,    tmotorNXT, PIDControl, encoder)
#pragma config(Motor,  motorB,          BeaterRight,   tmotorNXT, PIDControl, encoder)
#pragma config(Motor,  motorC,           ,             tmotorNXT, openLoop)
#pragma config(Motor,  mtr_Matrix_S1_1, LiftArm,       tmotorMatrix, PIDControl, encoder)
#pragma config(Motor,  mtr_Matrix_S1_2, motorE,        tmotorMatrix, openLoop)
#pragma config(Motor,  mtr_Matrix_S1_3, motorF,        tmotorMatrix, openLoop)
#pragma config(Motor,  mtr_Matrix_S1_4, motorG,        tmotorMatrix, openLoop)
#pragma config(Servo,  srvo_Matrix_S1_1, servo1,               tServoNone)
#pragma config(Servo,  srvo_Matrix_S1_2, servo2,               tServoNone)
#pragma config(Servo,  srvo_Matrix_S1_3, servo3,               tServoNone)
#pragma config(Servo,  srvo_Matrix_S1_4, servo4,               tServoNone)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

/* Here's where the work is done, main task is what is run when the program starts */
task main(){
   //Initialise starting positions
   nMotorEncoder[LiftArm]=0;
   nMotorEncoderTarget[LiftArm]=-1500;
   wait10Msec(10); //delay while variables are updated

   motor[LiftArm]=-80; //set power to the motor to run to the encoder target
   while (nMotorRunState[LiftArm] != runStateIdle ) {
      //do nothing until the encoder target is reached;
   }
   motor[LiftArm]=0; //stop the motor

   nMotorEncoderTarget[LiftArm]=-200; //set the motor to a new target position
   wait10Msec(10);

   motor[LiftArm]=80;
   while (nMotorRunState[LiftArm] != runStateIdle ) {
      //do nothing
   }
   motor[LiftArm]=0;
}

When the motor is set in PID mode in the pragma it just moves to a location once and sits there, regardless of the change in nMotorEncoderTarget values.
If we change it to OpenLoop the motor Always overshoots the encoder target and we end up trying to 'roll our own' PID style control and have it back up which results in a couple of seconds of shudder trying to find the exact target position.

There doesn't seem to be any reference in the RobotC help either about how to us the encoder target. The examples I've found don't seem to work either as they are waiting for motor state idle which only happens if you set a -ve value in the encoder target.

I'm tearing my hair out trying to make it work as intended, does anyone have any pointers?

Cheers
Cameron


Thu Jan 30, 2014 4:26 am
Profile
Rookie

Joined: Sun Jun 15, 2014 9:37 am
Posts: 1
Post Re: Matrix motors & nMotorEncoderTarget
Hi

Did you figure it out because I am having the same problem?

---------------
Johnnie


Sun Jun 15, 2014 10:23 am
Profile
Rookie
User avatar

Joined: Wed Jan 09, 2013 11:48 pm
Posts: 37
Location: Saint Paul, MN
Post Re: Matrix motors & nMotorEncoderTarget
The nMotorRunState didn't always work well for me. Although I do not use Matrix (I use Tetrix) you could try something analogous to this:
Code:
nMotorEncoder[LiftArm] = 0;
wait1Msec(50);

motor[LiftArm] = -80;
while(nMotorEncoder(LiftArm) >= -1500) {
}
motor[LiftArm]=0;

If it is over shooting by a ton, I would consider lowering the speed, but this worked reliably for me. If you are over shooting but still want some speed, consider changing the speed at different positions, slowing the motor incrementally.

_________________
Head Programmer FTC Team 6699, Tempest

Code:
<Life>
   Fun
</Life>


Mon Jun 16, 2014 12:38 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 3 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.