Hey,
We need to look at a sample piece of the main part of somebodys arm code thanks! We are using C Programming and we need just an idea on how we are gonna program it thanks
-chris
Hey,
We need to look at a sample piece of the main part of somebodys arm code thanks! We are using C Programming and we need just an idea on how we are gonna program it thanks
-chris
it all depends on what you want to do…
These are easily modifiable in the given default code… just goto user_routines.c in the workspace, then find where it shows the mappings of inputs (joysticks) to outputs (pwm outouts, controlling motors)
What do you want your arm to do? How is it wired up? Do you have any sensors doing anything? I’ll post some sample code later, but the chances that it will be right for your arm are slim…
the only thing the arm does that excludes the grippers is move 270 degrees. And we are using the van door motor!
then you are going to want to control the motor using a Victor, and thus a PWM. set the variable pwmXX (XX being the number of the output the victor is connected to) to a number from 0 to 255 - 0 is full reverse, 255 is full forward, and 127 is neutral (stopped).
If you want it to move exactly 270 degrees, you will need some sort of feedback system. I would recommend a pot - do you know how to wire one up?
You need to read the 2004 Programming Reference guide located here:
http://www.innovationfirst.com/FIRSTRobotics/pdfs/2004_Programming_Reference_Guide_10-29-2003.pdf
You also need to read the 2004 FRC Default Code Reference Guide:
http://www.innovationfirst.com/FIRSTRobotics/pdfs/FRC_RC_Default_Software_Ref_Guide_2004-1-7.pdf
The second PDF document explains in detail what’s going on in the default code that Innovation First provides.
heres a very helpful power point presentation by the people at Innovation First http://www.usfirst.org/robotics/C_help.htm
This may be oversimplified, but all you have to do is use a PWM output as a function of a joystick input. something like pwm(#)=p2_y; (or whatever port your joystick is in). U can even use the Limit_Mix function so that it reads pwm(#)=Limit_Mix(2000+p2_y);
edit: Actually if you are using a joystick, all you have to do is plug it into port2 on the OI, and ur speed controller for the globe into PWM OUT 2 and you are set to go. The y-axis controls the arm. (Default code can do wonders lol)
{
static long timeCounter = 0; //this will count the number of 26.2ms ticks that have passed
while (autonomous_mode) /* DO NOT CHANGE! /
{
if (statusflag.NEW_SPI_DATA) / 26.2ms loop area /
{
Getdata(&rxdata); / DO NOT DELETE, or you will be stuck here forever! */
if(timeCounter <= 115) //3 seconds / 26.2ms = 114.5
{
pwm13 = pwm15 = 30;
}
else if(timeCounter <= 134) //we'll give the relays about .5 seconds to switch
{
pwm13 = pwm15 = 0;
relay1_fwd = relay2_fwd = 1;
}
else
{
//put stuff to do after the other things here
//you can also add more else-if statements to time other things
}
Putdata(&txdata); /* DO NOT DELETE, or you will get no PWM outputs! */
timeCounter++; //add one to the tick count
}
}
}
this should work fine - hope it helps!
mmy motoors don’t move
shs, i already sent you a PM answering that question that you PMed me before you posted it here - check your PMs. but in the name of simplicity…
you need to add a call to Generate_Pwms() after the Putdata() line, like this:
void User_Autonomous_Code(void)
{
static long timeCounter = 0; //this will count the number of 26.2ms ticks that have passed
while (autonomous_mode) /* DO NOT CHANGE! */
{
if (statusflag.NEW_SPI_DATA) /* 26.2ms loop area */
{
Getdata(&rxdata); /* DO NOT DELETE, or you will be stuck here forever! */
if(timeCounter <= 115) //3 seconds / 26.2ms = 114.5
{
pwm13 = pwm15 = 30;
}
else if(timeCounter <= 134) //we'll give the relays about .5 seconds to switch
{
pwm13 = pwm15 = 0;
relay1_fwd = relay2_fwd = 1;
}
else
{
//put stuff to do after the other things here
//you can also add more else-if statements to time other things
}
Putdata(&txdata); /* DO NOT DELETE, or you will get no PWM outputs! */
Generate_Pwms(pwm13,pwm14,pwm15,pwm16);
timeCounter++; //add one to the tick count
}
}
}