ROBOTC.net forums
http://www.robotc.net/forums/

How to float one motor while braking other two
http://www.robotc.net/forums/viewtopic.php?f=1&t=90
Page 1 of 1

Author:  wherman [ Sat Mar 17, 2007 12:48 pm ]
Post subject:  How to float one motor while braking other two

Is there a way to float one motor, in this case an arm, but still brake the drive motors?

Bill

Author:  starwarslegokid [ Sat Mar 17, 2007 5:37 pm ]
Post subject: 

I think I figured out how to do it for you. When stooping a motor, you need to define whether it will float or brake right before you do the action. You have to do this for each motor you want to operate differently from the previous motors. I made this code to demonstrate how to do it.

Hook a motor to port A and B and the code will alternately float and brake each motor.

I have an idea for the RobotC developers, could you change this command so you can define only once what ports to Brake/Float? This would make programing so much easier for everyone B-)

Example:
bFloatDuringInactiveMotorPWM[motorA] = true;
bFloatDuringInactiveMotorPWM[motorB] = false;

_________________________________________________________
task main()
{

while (true)
{
motor[motorA]= 100;
motor[motorB]= 100;

wait1Msec(500);

bFloatDuringInactiveMotorPWM = true; // float A
motor[motorA]= 0;
bFloatDuringInactiveMotorPWM = false; // Brake B
motor[motorB]= 0;

wait1Msec(2000);

motor[motorA]= 100;
motor[motorB]= 100;

wait1Msec(500);

bFloatDuringInactiveMotorPWM = false; // Brake A
motor[motorA]= 0;
bFloatDuringInactiveMotorPWM = true; // Float B
motor[motorB]= 0;

wait1Msec(2000);


}
}


Hope this helps ya out and good luck B-)

Author:  wherman [ Tue Mar 20, 2007 2:28 am ]
Post subject: 

Unfortunately i think that the float vs brake is universal/global and when you try to change it it jams the arm motor. My program does alot of driving around with B and C motors, then when I want to use the arm I want to float the motor so that gravity can finish the job, thus avoiding a stalled motor if the arm gets hung up. When I try to float the motor with the code below, the motors squeals, if I take out the coast and brake statements then it works. The NXT-G language allows all the coasting/braking every time, so I don't get why this fails

// drop arm
bFloatDuringInactiveMotorPWM = true;
nMotorEncoder[motorA] = 0;
nMotorEncoderTarget[motorA] = 60;
motor[motorA] = 70;
while (nMotorRunState[motorA] != runStateIdle)
{}
bFloatDuringInactiveMotorPWM = false;

strangely enough if I abandon the encoder and just turn A on for .2 sec then the code works

Author:  starwarslegokid [ Tue Mar 20, 2007 5:24 pm ]
Post subject: 

I played with your code and I see the problem. When using the target encoder, it works allot better when the motor is in brake mode than in float mode. I think the reason is when in brake mode, the motor can alter the speed with great control, and with high accuracy. When the motor is in float, the control is hindered with the motors tendency to coast past its encoder target. The encoder is more likely to miss its target and have to backtrack to the specified target.

I made a program to demonstrate the difference in the motor encoder target with the float and brake options. Plug a motor into port A and make sure the motor is not hooked to anything and watch what happens. I set the target to 1000, that gets the motor up to speed and shows how different the two modes are. You will hear the motor squeal when in float mode, what is happening is it is really close to its target and mathematically, it needs to give it a little power to get to the target, but in reality the amount of power is to little to move the motor, causing it to stall and you hear the squeal.

I hope this helps a little bit, as for your arm i might ditch the encoder idea and just have the motor move for half a second and coast down.

_____________________________________________________________

task main()
{

nxtDisplayTextLine(1,"Motor Brake",);
bFloatDuringInactiveMotorPWM = false; // Motor brake and encoder

nxtDisplayTextLine(2,"Target 1000",);
nMotorEncoder[motorA] = 0;
nMotorEncoderTarget[motorA] = 1000;
motor[motorA] = 100;


while (nMotorRunState[motorA] != runStateIdle)
{
nxtDisplayTextLine(3,"Encoder=%d", nMotorEncoder[motorA]);
}

wait1Msec(3000);

nxtDisplayTextLine(1,"Motor Float",);
bFloatDuringInactiveMotorPWM = true; // Motor float and encoder

nxtDisplayTextLine(2,"Target 1000",);
nMotorEncoder[motorA] = 0;
nMotorEncoderTarget[motorA] = 1000;
motor[motorA] = 100;


while (nMotorRunState[motorA] != runStateIdle)
{
nxtDisplayTextLine(3,"Encoder=%d", nMotorEncoder[motorA]);
}

}

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/