What I’d like to do is set a power of 10ish to my lift motors so they can hold their position without over heating. How can I do this? Thanks for the help ahead of time
Any help? Anyone? Lol. I have a competition Saturday and this is very important.
Is there a way to make it so there is always a power of 10 on the lift motors when I’m not pressing the button?
Yes, but it really depends on how you have written it.
Post the current code (or send via PM) and I will send you a revised version (zip the whole project).
It’s in EasyC not robot C. Sorry for being vague
I think I knew that already, without seeing the code I cannot advise on how to change it. The easiest way is to zip up the project and send it to me.
So I will post here rather than a PM as the code is relatively straight forward.
You are using these two lines of code to control the lift.
JoystickDigitalToMotor ( 1 , 6 , 1 , -127 , 2 , 127 , 8 ) ; // right lift
JoystickDigitalToMotor ( 1 , 6 , 1 , 127 , 2 , -127 , 9 ) ; // left lift
Button 6 up and down.
This gets replaced with several blocks that do the same thing except sending a power of 10 (and -10 for the other motor) to the motor when no buttons are pressed. You need to define a couple of variables to hold the state of the up and down buttons and then the code looks like this.
#include "Main.h"
void OperatorControl ( unsigned long ulTime )
{
int LiftUp = 0;
int LiftDown = 0;
while ( 1 ) // Insert Your RC Code Below
{
Arcade4 ( 1 , 2 , 1 , 2 , 4 , 1 , 10 , 1 , 0 , 0 , 1 ) ;
// This is the lift control
LiftUp = GetJoystickDigital ( 1 , 6 , 2 ) ;
LiftDown = GetJoystickDigital ( 1 , 6 , 1 ) ;
if ( LiftUp == 1 )
{
SetMotor ( 8 , 127 ) ;
SetMotor ( 9 , -127 ) ;
}
else if ( LiftDown == 1 )
{
SetMotor ( 8 , -127 ) ;
SetMotor ( 9 , 127 ) ;
}
else
{
SetMotor ( 8 , 10 ) ; // // holding power to lift
SetMotor ( 9 , -10 ) ; // // holding power to lift
}
// These two lines are not used now
//JoystickDigitalToMotor ( 1 , 6 , 1 , -127 , 2 , 127 , 8 ) ; // right lift
//JoystickDigitalToMotor ( 1 , 6 , 1 , 127 , 2 , -127 , 9 ) ; // left lift
JoystickDigitalToMotor ( 1 , 5 , 1 , 127 , 2 , -127 , 6 ) ; // left intake
JoystickDigitalToMotor ( 1 , 5 , 1 , -127 , 2 , 127 , 7 ) ; // right intake
JoystickDigitalToMotor ( 1 , 7 , 1 , 127 , 2 , -127 , 3 ) ;
JoystickDigitalToMotor ( 1 , 5 , 1 , 127 , 2 , -127 , 5 ) ;
JoystickToDigitalLatch ( 1 , 8 , 1 , 9 ) ;
}
}
Hopefully I have the same directional control on the buttons (ie. I may have reversed positive and negative values to the motors).
same thing in block mode
[ATTACH]8075[/ATTACH]
Ok thank you so much! You’re a life saver
Well personally i prefer to just keep sending a signal to the motors to let them up as long as the lift is not dropped to the bottom (identified by limit switches) or activated by any buttons (joystick digital input). But if you are not planning on hanging, use rubber bands! Very important way to keep your lift motors from overheating.
I would second this. Our lift has two sets of rubber bands on each side and its amazing how much those help us out.
Another good solution could be making your drive Arcade style (all of your drive on one joystick) and putting your lift on the other joystick. I have my drive on the right joystick and lift on the left. The benefits of this though is now you can have variations in the speed of your lift and can apply a very small amount of power at the top instead of full power like you would have with buttons. I was reluctant to change to this style at the beginning of the year because I liked tank style. However, as soon as I did switch to this, it simplified everything a ton for me and I love it. All of the teams in my class have copied that in some variation and they all seem to like it too.
These are just my suggestions though. You by no means have to listen to this at all. If you do though, I can help you program it. Good luck.
Thanks for the advice! I may try this after this competition. And I love arcade style driving too.
You could also make it so it will only hold power with the value of 10 when you press the power button, one for when the lift goes up and one for when it goes down! Otherwise, it’d be a lift without power when the buttons aren’t being pressed.
We are using Arcade style drive and Arcade style lift on the left joystick. And we programmed an arm hold on a button, but when I press my arm hold button I loose power to my arcade lift.
I can get it to work if I use buttons, but not the Joystick (arcade style)
This one has me stumped. Please help!
You need to make sure that both your arm-holding routine and the joystick routine are not running at the same time. If they both are going at once, then the bot is going to take the joystick input instead of what you are telling it to do autonomously. And since you aren’t touching the joystick while it is supposed to be holding, it doesn’t do anything. There may be other issues as well, but I do know that the joystick program doesn’t like setmotor inputs.
If that is the problem, try something like this:
int btn_hold=0;
int hold_last=0;
int hold=0;
int hold_memory=0;
while(1) // Driver Control
{
hold_last = btn_hold;
btn_hold = GetJoystickDigital(1,7,2);
if(btn_hold > hold_last) // Toggles the hold function on and off with each button press
{
if(hold_memory == 0){hold_memory=1;}
else{hold_memory=0;}
}
hold = hold_memory;
if((Abs(GetJoystickAnalog(1,2)))>10) // Checking if the stick is moved out of a small deadzone
{
hold = 0;
}
if(hold==1)
{
//Lift holding subroutine goes here
}
else
{
//Joystick lift routine goes here
}
}
The result of this is that the holding program should run whenever you let go of the stick.