![]() |
Re: limit switches
Quote:
The RC digital inputs have a pullup resistor to +5 volts. Reading them will return a 1 when the switch is open, and a 0 when the switch is closed to ground. |
Re: limit switches
Quote:
Both the %d and (for our RC compiler) the cast to int are important... |
Re: limit switches
Heh, yeah sorry about that. It is %d not %f. It's little (seemingly) trivial things like that that always get me.
eugene: I've never used (int) before, and my printf's work fine. |
Re: limit switches
I am not sure if the question has been answered or not but I can't really diagnose the problem with out the code but what my first idea would be is that there is not an else statement following his if statement to turn the motor off when the switch is not pressed.
if (button8 == 1) {pwm01 = 254;} else {pwm01 = 127;} Wait, after rereading some of the posts maybe this is not the problem. Please post your code so we can further diagnose it. |
Re: limit switches
thanks for all your help. I've got it working now. the problem was just in how I was accessing the limit switch in the code. there was a variable that wasn't being reset when the switch changed its state. thanks for all your help. Originally, this wasn't the only problem, we had problems wth our buttons that kept messing me up too. but now that's all solved. thanks for the help!!!
the code you posted worked fine. thanks again. |
Re: limit switches
I searched and couldn't find and couldn't think through the code for:
I have a motor and 2 Limit Switches that sets the upper and lower limits of an arm from our 2003 Robot. I want to have it so when I hit a Trigger on the joystick it sends the motor forward until it hits the Top limit switch or if it is already at the top to reverse the motor until it hits the Bottom Limit Switch. I have: #define T_DRIVE pwm01 #define Up_T_Limit rc_dig_in01 /* Limit Switch on Full Up Set */ #define Down_T_Limit rc_dig_in02 /* Limit Switch on Full Down Set */ #define T_BUTTON_BTN p2_sw_trig /* Button to change T state. */ /* T state variable. */ int intTState = 0; Thanks in advance <slightly off topic> This is for an off season project to convert our PBASIC 2003 robot into a vision robot for presentations </slightly off topic> |
Re: limit switches
Quote:
Somewhere at top of file: Code:
// Your stuffCode:
if(T_BUTTON_BTN == OI_SWITCH_ON) |
Re: limit switches
Ryan, I don't think that your code is going to do what was requested. With your code, every time it gets called you will change your intTState. I think what you're trying to do is as follows...(This is uncompiled and untested, so be sure to understand the code before trying to run it)
Code:
#define T_DRIVE pwm01 |
Re: limit switches
Yep, you're right. I didn't think to include a "the press is from the last time through!" check. Your code should work, but just for the sake of completeness... :) (new stuff in bold)
Somewhere at top of file: Code:
// Your stuffCode:
if(T_BUTTON_BTN == OI_SWITCH_ON) |
Re: limit switches
Thanks for the help. I partly finished rewiring and converting it to 2004 last night. I will finish up this weekend and let you all know.
One question: When you say SWITCH_OFF that isn't defined. Is that suppose to be RC_SWITCH_OFF?? |
Re: limit switches
Quote:
|
Re: limit switches
Quote:
|
Re: limit switches
Y'all need to change !SWITCH_ON to !RC_SWITCH_ON as well.
|
Re: limit switches
Quote:
|
| All times are GMT -5. The time now is 20:20. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi