![]() |
UI Buttons
Hi,
We have buttons we want to use to automatically bring our arm to three different positions, using a limit switch (to bring the arm to position zero) and an encoder to accurately "guess" the middle and drop positions. Here is the code we will be using with three buttons on the ui. We are having trouble getting these buttons to work. they seem to turn to 1 instead of 0 when some of them are pressed, because we tested a joystick in the same port, and that is the behavior the exhibited. here is the code we are using, please let me know of possible problems. thanks!!! Code:
static unsigned int desired_position = 1; thanks in advance. |
Re: UI Buttons
Your code looks fine to me. (but if I'm wrong... talk to my lawyer. ;))
I'm always confused about this, but I think that the buttons on the OI are reversed. (1/high for released, 0/low for pressed) But... my whole post could be wrong. :o |
Re: UI Buttons
Quote:
|
Re: UI Buttons
Quote:
The RC is reversed and will be 1 if unpushed, 0 if pushed. (because of the pull-up) |
Re: UI Buttons
Quote:
...yep! and to muddy the waters a bit: Limit switches can usually be wired "normally open" or " normally closed". If you don't like the fact that the RC is "1 if unpushed and 0 if pushed", wire the limit switch "normally closed" and it will behave as the OI ;) ...and a few random musings: for your desiredposition == 2, I'd suggest giving yourselves some "room to maneuver" when it comes to setting the motors to neutral. Hitting and holding exactly 1280, may result in a lot of racheting. You may want to make that a band...say > 1278 and < 1282 or something like that Whenever you are in the home position, re-zero your encoder counter. There is always the chance of being off a few counts as the arm moves up and down and error can build up over a lot of use. ...just my 2cents Eric |
| All times are GMT -5. The time now is 09:38. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi