View Single Post
  #9   Spotlight this post!  
Unread 14-03-2008, 13:33
Racer26 Racer26 is offline
Registered User
no team
Team Role: Alumni
 
Join Date: Apr 2003
Rookie Year: 2003
Location: Beaverton, ON
Posts: 2,229
Racer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond reputeRacer26 has a reputation beyond repute
Re: General question.

Quote:
Originally Posted by XXShadowXX
#define pwm1 = Rmotor1
#define pwm2 = Rmotor2
#define pwm3 = Lmotor3
#define pwm4 = Lmotor4
#define digital_input_1 = func1
#define digital_input_2 = func2
#define digital_input_3 = func3
#define digital_input_4 = func4
#define analog_input_1 = Rgear
#define analog_input_2 = Lgear
this should look like

Code:
#define Rmotor1 pwm01
#define Rmotor2 pwm02
#define Lmotor3 pwm03
#define Lmotor4 pwm04
#define func1 rc_dig_in01
#define func2 rc_dig_in02
#define func3 rc_dig_in03
#define func4 rc_dig_in04
#define Rgear Get_Analog_Value(rc_ana_in01) //if this is a GTS, it should be a digital input that's capable of interrupts (i recommend dig01/02)
#define Lgear Get_Analog_Value(rc_ana_in02)
Quote:
Originally Posted by XXShadowXX
If (func1=1)
/*idk, how to program for raising and locking arm.*/
/*But, the arm has to be raised here. */
If (func4=1)
Rmotor1 = 127
Rmotor2 = 127
Lmotor3 = 127
Lmotor4 = 127
this part looks fine, just remember to curly brace your if blocks

Quote:
Originally Posted by XXShadowXX
switch (Set):
Case0:
If (Rgear = 0
Lgear = 0)
Rmotor1 = 254
Rmotor2 = 254
Lmotor3 = 254
Lmotor4 = 254
Case1:
If (Rgear =
Lgear = ) /* gear count unknown at this time */
Rmotor1 = 254
Rmotor2 = 254
Lmotor3 = 0
Lmotor4 = 0
Case2:
If (Rgear =
Lgear = )
Rmotor1 = 127
Rmotor2 = 127
Lmotor3 = 127
Lmotor4 = 127
Switch (Func2 = 0
Func3 = 0)
Case0:
If (Rgear =
Lgear = )
Rmotor1 = 254
Rmotor2 = 254
Lmotor3 = 254
Lmotor4 = 254
Case1:
If (Rgear =
Lgear = )
Rmotor1 = 254
Rmotor2 = 245
Lmotor3 = 0
Lmotor4 = 0
Case2:
If (Rgear =
Lgear = )
Rmotor1 = 254
Rmotor2 = 254
Lmotor3 = 254
Lmotor4 = 254
Case3:
If (Rgear =
Lgear = )
Rmotor1 = 127
Rmotor2 = 127
Lmotor3 = 127
Lmotor4 = 127
I think what you're trying to do here is a dead reckoning type autonomous mode.

It appears you're trying to build a state machine (variable set is your state counter)

I think you want something along this line, although, personally, I would just use an if-elseif structure:

Code:
switch(autostate){
  case 0:
    if(Lgear < 200 && Rgear < 200){ // && is the logical AND operator
      //drive forward
    }else{
      autostate++;
    }
    break;
  case 1:
    if(Rgear < 500 && Lgear < 500){
      //Turn Left
    }else{
      autostate++;
    }
    break;
}
and so on.