Would this be a good way to create a multi level lifting system?
int kLiftNum = 11;
int kCurrLiftVal = 0;
/* Lift Values */
// 0 = Starting Pos(Set to 0)
// 1 = Skyrise Holder
// 2 = First Level Drop Height
// 3 = Second Level Drop Height
// 4 = Third Level Drop Height
// 5 = Fourth Level Drop Height
// 6 = Fifth Level Drop Height
// 7 = Sixth Level Drop Height
// 8 = Seventh Level Drop Height
// 9 = Lowest Tower
// 10 = Medium Tower
// 11 = Tallest Tower
// Toggle System
while(kCurrLiftValue < kLiftNum)
{
if(vexRT[Btn5U] == 1)
{
kCurrLiftValue++;
}
if(kCurrLiftValue == 0)
{
// Bring Lift To Starting/Gathering Pos
armTargTop = 0;
armTargBot = 0;
// Set Encoders To Zero
nMotorEncoder[m_lftLB] = 0;
nMotorEncoder[m_lftLT] = 0;
nMotorEncoder[m_rtLB] = 0;
nMotorEncoder[m_rtLT] = 0;
// Bring Lift To Zero
armTargTop = 0;
armTargBot = 0;
}
}
It’s a start, needs a bunch more code.
I think I may have gotten this working
int kLiftNum = 11;
int kCurrLiftVal = 0;
task userLiftRD4B()
{
// Toggle System
while(kCurrLiftValue < kLiftNum)
{
// Lift Up
if(vexRT[Btn5U]==1)
{
kCurrLiftValue++;
while(vexRT[Btn5U]{}
}
// Lift Down
if(vexRT[Btn5D]==1)
{
kCurrLiftValue--;
while(vexRT[Btn5D]{}
}
// Normalize Values
if(kCurrValue < 0)
{
kCurrValue == 0;
}
if(kCurrLiftValue == 0)
{
// Bring Lift To Starting/Gathering Pos
lift(0, 0);
// Set Encoders To Zero
if(s_lftZero == 1 && s_rtZero == 1)
{
nMotorEncoder[m_lftLB] = 0;
nMotorEncoder[m_lftLT] = 0;
nMotorEncoder[m_rtLB] = 0;
nMotorEncoder[m_rtLT] = 0;
}
else if(s_lftZero == 0 || s_rtZero == 0)
{
arm(-127);
}
// Bring Lift To Zero
lift(0, 0);
}
if(kCurrLiftValue == 1)
{
lift(100 , 100);
}
if(kCurrLiftValue == 2)
{
lift(0, 0);
}
if(kCurrLiftValue == 3)
{
lift(110, 110);
}
if(kCurrLiftValue == 4)
{
lift(250, 250);
}
if(kCurrLiftValue == 5)
{
lift(360, 360);
}
if(kCurrLiftValue == 6)
{
lift(480, 480);
}
if(kCurrLiftValue == 7)
{
lift(500, 500);
}
wait1Msec(25);
}
/* Lift Values */
// 0 = Starting Pos(Set to 0)
// 1 = Skyrise Holdfer
// 2 = First Level Drop Height
// 3 = Second Level Drop Height
// 4 = Third Level Drop Height
// 5 = Fourth Level Drop Height
// 6 = Fifth Level Drop Height
// 7 = Sixth Level Drop Height
// 8 = Seventh Level Drop Height
// 9 = Lowest Tower
// 10 = Medium Tower
// 11 = Tallest Tower
// Control Buttons
int power = vexRT[Btn6U]*127 - vexRT[Btn6D]*127;
arm(power);
}
You should add a limit on the up like you did with 0. Why the while loop? I’m afraid its doing some thing you don’t want.
Not yet, have you tried compiling it?
No I haven’t, I kinda use my mac to program. ← Bad Habits… And I’m to scared too try out ConVex. It seems pretty hard to use.
Well, there are a few bugs, for instance, this…
while(vexRT[Btn5U]{}
Will need to be changed to this. (it’s mising closing “)” and should really have a delay to keep ROBOTC happy)
while( vexRT[Btn5U] )
wait1Msec(10);
It was never intended for beginners, I am thinking of creating an installer like PROS just for Mac users sometime to make things a little easier.
4149G
December 9, 2014, 5:52am
8
I’ve seen this suggested many times and built into many codes that I view on the forums. Could you please explain why it is important to have a delay?
I don’t understand why waiting a small fraction of time, say 25 ms, is a good thing to have in a loop that you want to run continuously. (I am just a science teacher trying to learn all this coding stuff on the side to teach my students!)
4149G:
I’ve seen this suggested many times and built into many codes that I view on the forums. Could you please explain why it is important to have a delay?
I don’t understand why waiting a small fraction of time, say 25 ms, is a good thing to have in a loop that you want to run continuously. (I am just a science teacher trying to learn all this coding stuff on the side to teach my students!)
PWM signals are on 20ms bursts so anything you do adjust within it just waits for it to be sent to the motor anyway.
Looping endlessly fast can hog the CPU in a loop prevents other tasks from running. In competition code, even if you don’t call another task, you are the user control task and the main task is out there looking for the on/off actions from the judges table. I am unsure if you loop too much if background things like interrupts for sensors or timers will act funky.
jpearman can opine better on this topic if he is reading the thread. He was author of this one linked below. You can see the pulse lengths sent to the motor for various values.
VEX V5 General Discussion
Technical Discussion
When testing motors to determine their speed-torque curves in this thread, it has been noticed that motors are reaching their maximum unloaded speed before the maximum possible control value. This can be seen in this post where there is a graph...
Reading time: 4 mins 🕑
Likes: 9 ❤