|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Limit switch in easy c?
I've only messed around with easy c a couple of times and i was able to get a 2 motor tank drive system up and running in no time... i love it! however, I'd like to get my limit switches working to prevent an arm motor from going too far (either up or down)... I know how to do this by handing coding in MP lab but I am not sure how to do it within the constraints of Easy C. Any suggestions?
CHAD |
|
#2
|
|||||
|
|||||
|
Re: Limit switch in easy c?
well i don't know how different the easy c from vex is to FRC but i did make a code for two limit switches on one motor.
if you want the code email me at michaelleicht@gmail.com and i will get you that code for the limit switch. |
|
#3
|
||||
|
||||
|
1. Map Analog to OI Input to a variable
2. Map PWM Control to a variable 3. Make a few "IF" statements 4. Make a few Assignments Thats pretty much the gist of it. We will be releasing samples in the future on how to perform these activities. ![]() Also, EasyC for FRC and VEX work pretty much the same way for driver control. Last edited by Kingofl337 : 13-01-2006 at 17:00. |
|
#4
|
|||||
|
|||||
|
Re: Limit switch in easy c?
Quote:
Here is how this sample arm/elevator is set up. There is an upper and a lower limit switch. The PWM signal for moving the arm up must be between 127 and 255. The PWM signal for moving the arm down will be between 0 and 127. Here is a diagram of this setup: ![]() And here is the code: (from EasyC 2.0) Code:
#include "Main.h"
void main ( void )
{
char upperlimit;
char lowerlimit;
unsigned char arm;
while ( 1 )
{
upperlimit = GetDigitalInput ( 1 ) ; //Upper limit Switch is plugged into I/O Port 1
lowerlimit = GetDigitalInput ( 2 ) ; //Lower limit Switch is plugged into I/O Port 2
arm = GetRxInput ( 1 , 1 ) ; //Arm control is coming from RX port 1, Channel 1
if ( upperlimit == 0 && arm > 127 )
{
arm = 127 ;
}
if ( lowerlimit == 0 && arm < 127 )
{
arm = 127 ;
}
SetPWM ( 1 , arm ) ; //Set PWM port 1 to 'arm' variable
}
}
|
|
#5
|
||||
|
||||
|
Re: Limit switch in easy c?
In FRC you would substitute "GetRXInput" with "GetOIAInput".
Thanks artdutra04 for the example. |
|
#6
|
|||
|
|||
|
Re: Limit switch in easy c?
Thanks everybody! This information was very helpful. I had forgotten that I can use the joystick value as a representation of what my PWM output will be. I was stuck because I couldn't find a way to look up what the PWM value was and didn't realize that I didn't even need it!
|
|
#7
|
|||
|
|||
|
Re: Limit switch in easy c?
Be careful not to use a while loop for this, I did that and the limit switch essentially acted as a "kill switch" for the robot
![]() |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| limit switches | stephenthe1 | Programming | 28 | 11-05-2005 16:37 |
| How do you wire a limit switch? | JMH | Electrical | 1 | 16-02-2005 17:44 |
| LEDs in switch box. | ZZII 527 | Electrical | 5 | 06-03-2004 19:39 |
| sample limit switch code??? | tml240 | Programming | 5 | 17-02-2004 17:13 |
| Need help with 255 Variable | Joseph F | Programming | 18 | 26-02-2002 14:49 |