View unanswered posts | View active topics It is currently Sun Jun 24, 2018 2:40 pm

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
How to float one motor while braking other two
Author Message
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
Moderator

Joined: Wed Jan 31, 2007 3:39 am
Posts: 299
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;

_________________________________________________________
{

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
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
Moderator

Joined: Wed Jan 31, 2007 3:39 am
Posts: 299
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.

_____________________________________________________________

{

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
Display posts from previous:  Sort by
 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 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

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning