Go to Post bedtime? there's no bedtime while chief delphi is up and running! - Alex Cormier [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 11-02-2007, 19:00
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
Please help me with this sensor

Hi everyone, I'm using a metal sensor to track the height at which my forklift is at. There will be 4 pieces of metallic tape on a rope (using a winch system), one for each level of the rack and one for the ground. So, when the rope passes through the sensor and the sensor passes a piece of tape, lights will go on on the OI and the motor will stop. If I want to go to the next level I want to just keep holding the joystick for that winch motor. If I want it to stop at the level, the pwm03 value will equal 127 and hopefully if I let go of the joystick really fast, the motor will actually turn off. How do I make it so there is a small pause, enough time for me to let go of the motor before pwm03 value is remapped to the joystick in the next 26ms loop so the motor will stop? I want to see these (relay2) lights to go on when the forklift is going up, and I want to stop the motor from lifting the forklift at each level. I don't think what I have in my code will work though, what can I do to pause at pwm03 = 127 so that it wont continue moving?

Code:
void Default_Routine(void)
{
 	int count = 0;
	int now;
	int last;
	now = last;
	rc_dig_in04 = now;
blah blah blah...map joysticks to pwm..

Code:
                  /***************
                  * Sensor Code *
                  ***************/
 
 	if((pwm03 < 125) || (pwm03 > 129))
 	{
 		if((now == 1) && (last == 0)) //If sensor, which connects to Dig In/Out port 4, goes off...
		{
			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)
		{
			case 2:
		
				Relay2_green = 1;
				Relay2_red = 0;
				pwm03 = 127; //Motor stops when it reaches 1st level.
				break;
			
			case 3:
			
				Relay2_green = 1;
				Relay2_red = 0;
				pwm03 = 127; //Motor stops when it reaches 2nd level.
				break;

			case 4:
					
				Relay2_green = 1;
				Relay2_red = 1;
				pwm03 = 127; //Motor stops when it reaches top level.
				break;

			case 5:

				Relay2_green = 0;
				Relay2_red = 1;
				//pwm03 does not equal 127 because it must pass the tape in order to go beneath the top level.
				break;

			case 6:
			
				Relay2_green = 0;
				Relay2_red = 1;
				pwm03 = 127; //Motor stops when it retreats to 2nd level.
				break;
			
			case 7:
			
				Relay2_green = 0;
				Relay2_red = 1;
				pwm03 = 127; //Motor stops when it retreats to 1st level.
				break;

			case 8:
			
				Relay2_green = 0;
				Relay2_red = 0;
				pwm03 = 127; //Motor stops when it retreats to ground level.
				count = 0;
				break;

		//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.
		}
	}
Any suggestions as to how I can stop the motor at each location?

I'm the only programmer and electrician on my team and my team is made up of 5 people, so any help would be fantastic!
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help. I've had it with this camera Inverted Programming 6 14-01-2007 22:35
Help with sonar sensor supertw Electrical 3 24-01-2006 23:41
Light Sensor Type, Please Help! Alexander McGee Electrical 7 20-11-2004 21:48
What is wrong with this code???? It won't Compile and I don't know why? Please Help CrashZero Programming 23 26-03-2004 09:44
hey need some help with writing a code please help me here magical hands Programming 9 01-01-2004 21:46


All times are GMT -5. The time now is 04:54.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi