It can happen when the motor position is ever so slightly before the intended target. I am not sure there's a real fix for it other than implementing some code yourself that is a bit more lenient wrt intended motor target, ie stop the motor ithin 1-2% of the intended target. I would submit a ticket with some example code to support@robotc.net just the same.

It may not need to be 50ms, but I am pretty sure it still stands true. It's just how the system works. Resetting the encoders requires a few I2C calls to the controller. I am sure there are few internal things that need to be dealt with, too.

Xander and others: I am also having a problem with the Tetrix motors not stopping using nMotorEncoderTarget[]. The motor continues to run until a timeout I have in my software turns the motor power off.

I added counters to keep track of the motor run state and get many hold and running state counts. No Idle, RampUp or RampDn counts. Even the NXT Devices display shows the state to be running when the motors are all stopped. It is not a matter of not reaching the target, that was last years problem.

I can post the code if desired but even the reduced version is a bit verbose. This all worked with 3.08 but not with 3.51 with the released third party driver package. Below is a snippet of the failing loop and the associated Pragma.

On another subject: Did I read on this thread that if you use a negative target, that the PID is not activated?

I just got a message from RobotC Support regarding my ticket #247104 that they were able to reproduce the problem and will fix it in 3.52.

No additional information so I do not know what the problem is/was. Perhaps someone can provide additional info for the forum readers.

Wouldn't it be nice if this has been the major thorn that a lot of people have been having with nMotorEncoderTarget[].

Wed Oct 17, 2012 12:08 pm

tfriez

Site Admin

Joined: Wed Jan 24, 2007 10:42 amPosts: 619

Re: nMotorEncoderTarget[] not working..

We just stumbled upon this in our test cases - we've been so focused with Compiler issues that this one seemed to get in under the radar.

The issue is probably related to the MATRIX controller integration - we had to go back and modify all of the TETRIX commands to work with MATRIX as well - this is probably when this error was introduced. I haven't had a chance to dig into it to say exactly what the issue is, however.

We should have something available in the next day or so for our internal testers - if you're interested in being apart of this test group, send me an e-mail to tfriez [at] robotc (dot) net and I'll add your e-mail to the list.

The problem with this solution is that the motor always over or undershoots the desired position. The time it takes to read and test the encoder value allows the motor to go way past the intended position.

Did I read on this forum that a negative target prevents the built-in PID from working? That PID prevented last years robot from getting a motor to the desired position by reducing power to the point it would not move. Until those controllers are really programmable as far as the PID is concerned, I think one may have to do their own version of slowing the motor and testing the encoder. "Poor man's working PID"

Wed Oct 17, 2012 12:53 pm

MHTS

Guru

Joined: Sun Nov 15, 2009 5:46 amPosts: 1512

Re: nMotorEncoderTarget[] not working..

Mentor3923 wrote:

The problem with this solution is that the motor always over or undershoots the desired position. The time it takes to read and test the encoder value allows the motor to go way past the intended position.

Did I read on this forum that a negative target prevents the built-in PID from working? That PID prevented last years robot from getting a motor to the desired position by reducing power to the point it would not move. Until those controllers are really programmable as far as the PID is concerned, I think one may have to do their own version of slowing the motor and testing the encoder. "Poor man's working PID"

I don't know what the RobotC bug was but in general, what you said is exactly the problem. Even if there is no bug in RobotC, in general, a Proportional only controller will have a "steady state error" so if you are testing for exact target distance, you will never get there. That's why we gave it a tolerance to account for the steady state error. It may help if we can tune the PID constants and be able to add the Integral and Differential terms of the PID control, but those are not accessible with the built-in PID control. That's why we implemented our own PID controller in our FTC library.

Thu Oct 18, 2012 2:15 am

tfriez

Site Admin

Joined: Wed Jan 24, 2007 10:42 amPosts: 619

Re: nMotorEncoderTarget[] not working..

For the next release (and current private BETA) we have switched ROBOTC's implementation from running our own PID algorithm to using the integrated one in the HiTechnic Controller.

There was an issue when implementing the functionality for Matrix that ended up breaking ROBOTC's implementation. We have resolved this issue for our private BETA (if you wish to try it out, send me an e-mail).

The program I'm using to test is as follows. You can modify the speed, distance and also which port it runs on. I've confirmed this code works with both PID enabled and disabled.

We have a tentative release date set for Friday, November 2nd, but that is subject to change depending what the beta testing reveals. If you absolutely need the patch sooner, you can sign up for the beta by emailing tfriez@robotc.net. Please note, however, that it will be a beta build and as such, may be prone to bugs and issues (which is why we run a beta period; to get all of said bugs worked out before the release).

So now that this is working, how do you use nMotorEncoderTarget to move a TETRIX motor to a position and hold it there against significant deviating forces using PID control? The target position would be changing over time based on joystick input. This is for an arm joint.

We wish to use the built-in hitechnic motor controller's PID capability. We tried rolling our own PID code and haven't been able to get it tuned right.

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum