View Single Post
  #6   Spotlight this post!  
Unread 14-02-2007, 13:06
Ianuser Ianuser is offline
Registered User
FRC #0570
 
Join Date: Feb 2007
Location: new york
Posts: 64
Ianuser is an unknown quantity at this point
Re: Where do I begin to get the robot to move using the camera?

Thanks. I made these changes, hopefully it will work:

At the top of user_Routines.c I declared this
Code:
int pwm03_On_Off = 1;
Then in the Default_Routine() where I map to the joysticks I put this
Code:
if(pwm03_On_Off == 1)
  {
	pwm03 = p3_y; //ForkLift
  }
An example of my switch-case statements (for a metal sensor that increments the 'count' variable each time it passes...and there each time it passes certain things happen in the CASE...) is this
Code:
if((pwm03 < 125) || (pwm03 > 129))  //if py_3 is being used (forklift going up or down)
 	{
		if((now == 1) && (last == 0)) //If sensor, which connects to Dig In/Out port 4, sends a signal...
		{
			count++; //Number of times tape passes through the sensor.
			Switch1_LED = 1; //Switch01 goes on when the tape passes the sensor.
		}
		else
		{
			Switch1_LED = 0;
		}

		switch(count) //for sensor module
		{
			case 1:			//if count = 1 then that just means that it passed through the first piece of tape which will be used to show that it is in full DOWN position.

				Relay2_green = 1;
				Relay2_red = 0;
				printf("count = 1");
				break;

			case 2:
		
				Relay2_green = 1;
				Relay2_red = 0;
				pwm03 != p3_y;
				pwm03_On_Off = 0;
				pwm03 = 127; //Motor stops when it reaches 1st level of rack.
				printf("count = 2");
				break;
There are more cases, but those are the basic formats of the others anyway. Basically for case 2: I want to have he motor pwm03 stop and the joystick not mapped to pwm03 anymore. I have this in my code that allows me to reset the counter and to remap pwm03 to the joystick (so we can move it again):
This is all still in Default_Routine()
Code:
             last = now;
	now = rc_dig_in04;

	last2 = now2;
	now2 = p3_sw_trig;

	last3 = now3;
	now3 = p3_sw_aux1;

//some other stuff, but then:

if((now3 == 1) && (last3 == 0)) //p3_sw_aux1 sets counter to 0 in case forklift needs to be reset.
	{
		count = 0;
	}


	if((now2 == 1) && (last2 == 0)) //p3_sw_trig sets joystick 3 y-axis to forklift motor. Use after each level.
	{
		pwm03_On_Off = 1;
	}
So, think this will work? there is a snowday at my school today and they wont let us in to work on the robot, so I have to wait another day before I can test any of this. Thanks