Alright thank you so much magicode!!! If I have anymore questions or problems I will ask
No problem. You can PM me as well if you need something urgently.
Also, if you don’t want to go through all the pain of programming, (not tthat is’s a bad thing) then just use elastics. My arm can hold it’s position without programing and with just elastics, (rubber bands, or surgical tubing)and it weighs a good 3.8lbs.
I wanted to comment on this code block.
while(true){
if(abs(vexRT[Ch2]) > JOY_THRESH){
if(armPos < MAX_ARM && armPos > MIN_ARM){
armPos += sgn(vexRT[Ch2]);
}
wait1Msec(ARM_POS_CHANGE_RATE / vexRT[Ch2]);
}
endTimeSlice();
}
This code changes armPos by a fixed amount (+1 or -1) at a varying interval. In the case of this example the interval ranges from 1000mS (10000/10) to say 78mS (10000/127), also there should be an abs() around the vexRT value. Now I know this was just an example and the ARM_POS_CHANGE_RATE should probably be lower but in general I would recommend changing armPos by a varying amount at a fixed interval instead. The downside to the code as written is lack of responsiveness to joystick input when joystick output is small. Anyway, just my 2c.
I think you’re right Jpearman, on both counts. It should be an absolute value on the vexRT[Ch2], and having a varying amount on a fixed interval is probably a better idea. The code would then look something like this:
while(true){
if(abs(vexRT[Ch2]) > JOY_THRESH){
int setArmPos = armPos + (vexRT[Ch2] / ARM_POS_CHANGE_RATE);
if(setArmPos < MIN_POS) armPos = MIN_POS;
else if(setArmPos < MAX_POS) armPos = setArmPos;
else armPos = MAX_POS;
}
Wait1Msec(500);
}
Also, a quarter second of wait time is a lot in terms of lag for other functions of your robot, for example, driving. So this is a great place to use timers:
while(true){
if(time1[T1] > 200){
ClearTimer(T1);
if(abs(vexRT[Ch2]) > JOY_THRESH){
int setArmPos = armPos + (vexRT[Ch2] / ARM_POS_CHANGE_RATE);
if(setArmPos < MIN_POS) armPos = MIN_POS;
else if(setArmPos < MAX_POS) armPos = setArmPos;
else armPos = MAX_POS;
}
}
endTimeSlice();
}
I hope I addressed the issue with the code. Sorry for the screw-up, I was a bit distracted(college takes much more time than I thought it would).
Yes, but I was thinking about perhaps a 25-50mS delay. This would probably mean that setArmPos (and armPos) would need to be a float to keep ARM_POS_CHANGE_RATE reasonable.
If you are using separate tasks for arm and drive it would not be a problem.
It was not a screw up and I’m only adding an opinion of an alternative way of achieving the same goal. The OP needs to be able to understand the concepts presented and then make their own decision as to the best solution for their specific problem. The great/worst thing about software is that there are always choices and an individuals own style can be applied. Plus it’s a lot quicker to change than the mechanicals
We also included rubber bands to counter act the force weighing down the arm. Rubber Bands and Latex Tubing might help with this problem including the programming.
Hope this helps.