Page 1 of 1
[NXC] Servomotor position degrees - accuracy, or lack of...
Posted: 17 Sep 2011, 23:32
by dodgey
Hi - im working on a project that requires quite accurate motor positioning relative to degrees of rotation. In NXC.
I have an NXT ServoMotor (standard) that I want to rotate in increments of wither 90, 180, 270, or 360 degrees. I made the model so that the motor directly drives the item in question, thinking it would keep the programming simple. So I set the motor to rotate 360 degrees, and to my surprise it rotated about 400. I ended up with this to get 360 degrees.
ResetTachoCount(SPINNER);
RotateMotor(SPINNER, 50, 341);
Is this normal for NXT Servo motors? and if so, is the only way to get accuracy to use additional sensors? Does gearing down reduce errors , or does it just introduce more "play" in the system and accentuate them over time (before I try I want to avoid a major rebuild of this component)
Re: [NXC] Servomotor position degrees - accuracy, or lack of...
Posted: 18 Sep 2011, 00:06
by h-g-t
The software tends to keep track of the motors as soon as they are switched on. I found that that if I moved a motor manually before running a program, the program would set the motor back to where it was before I moved it then apply the movements in the program.
I found it best to reset the motors inside the program before commanding any movements.
Re: [NXC] Servomotor position degrees - accuracy, or lack of...
Posted: 18 Sep 2011, 09:13
by dodgey
Indeed - that's why I showed in my post that I'm using resettachocount before each command. I'm now looking at using a touch switch on a cam but I'd still be interested to hear if the innacuracy I'm experiencing is normal. I get it from the moment I turn on the robot.
Re: [NXC] Servomotor position degrees - accuracy, or lack of...
Posted: 18 Sep 2011, 23:12
by linusa
dodgey wrote:Indeed - that's why I showed in my post that I'm using resettachocount before each command. I'm now looking at using a touch switch on a cam but I'd still be interested to hear if the innacuracy I'm experiencing is normal. I get it from the moment I turn on the robot.
Please try this:
Code: Select all
ResetAllTachoCounts(SPINNER);
Wait(1);
RotateMotor(SPINNER, 50, 360);
// if you want, do this to verify the tacho count:
// Wait(100);
// use NumOut or whatever to display TachoCount(SPINNER)
This should give very accurate results. If not, try another port and another motor to be sure it's not a hardware problem.
The Wait(1) is to commit the changes to the firmware before starting the rotation, and there are 3 tacho counters and 1 "tacho goal" that should be cleared before starting a movement.
Re: [NXC] Servomotor position degrees - accuracy, or lack of...
Posted: 20 Sep 2011, 11:44
by dodgey
OK, I tried different ports and different motors, and I included your suggested code to reset the tacho counts and wait.
It makes no difference, and also, I've discovered it is speed related
If I turn the motor 360 degrees at speed 60 it turns too much and reports the tacho count of 385
If I slow it to 40 I get 378 degrees
I have to slow it to around 20 to get 361 degrees (whcih is too low power for my application)
I've tried issuing a stop command directly after. No difference
Re: [NXC] Servomotor position degrees - accuracy, or lack of...
Posted: 20 Sep 2011, 12:07
by dodgey
Update - Got it! I was on NXC Firmware 128 and started testing PID motor control with no change, then I updated to the NXC 131 FW and it works a treat - the motor flies round then corrects itself