|
Page 1 of 1
|
[ 4 posts ] |
|
How to float one motor while braking other two
| Author |
Message |
|
wherman
Rookie
Joined: Sun Mar 04, 2007 3:02 am Posts: 9
|
 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
|
| Sat Mar 17, 2007 12:48 pm |
|
 |
|
starwarslegokid
Moderator
Joined: Wed Jan 31, 2007 3:39 am Posts: 298 Location: San Diego, California. USA
|
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-)
_________________Mmmm Legos B-) My Robot Projects: http://www.freewebs.com/robotprojects/
|
| Sat Mar 17, 2007 5:37 pm |
|
 |
|
wherman
Rookie
Joined: Sun Mar 04, 2007 3:02 am Posts: 9
|
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
|
| Tue Mar 20, 2007 2:28 am |
|
 |
|
starwarslegokid
Moderator
Joined: Wed Jan 31, 2007 3:39 am Posts: 298 Location: San Diego, California. USA
|
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]);
}
}
_________________Mmmm Legos B-) My Robot Projects: http://www.freewebs.com/robotprojects/
|
| Tue Mar 20, 2007 5:24 pm |
|
|
|
Page 1 of 1
|
[ 4 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
|
|