![]() |
Using Limit Switches with the Arm
This is a little urgent because the robot needs to be shipped tomorrow and it would be ideal to have a working code before that...
I am coding in EasyC and I'm having some problems with coding the limit switches to limit the arm movements so it doesn't hit the bottom of the robot when extended. This image will provide you with more information about what we want: ![]() When our Limit Switches equal 1, it is pushed down. Otherwise, they equal 0. The rotator motor of the arm is a PWM. The extender is a relay switch. VARIABLES USED: Code:
unsigned char LimitSwitch1;Code:
// Joystick Y-Axis Movement controls Arm Rotation Motor Forward / Backward PWM Please, any comments will help me, especially since I need to get this working by tomorrow... Thanks :) |
Re: Using Limit Switches with the Arm
We've had similar problems with understanding what certain parts are supposed to do - it can get very confusing. Just tonight i tried a different tactic with one of the students and it seemed to make everything a LOT clearer. Set everything up in a big truth table, and then build your conditionals from that. I'm not sure i understand your situation well enough to help with a truth table for you specifically, but here's the situation that we have:
two buttons on the controller: B1 spins a wheel in to suck up a ball, while B2 spins it out to spit out a ball. In both cases, we only want the wheel spinning as long as the button is pressed. If both buttons are pressed at once, we don't care what is happening. a limit switch: When the ball hits the limit switch, we know the ball is in our traveling position, so we don't want the motors to be able to spin inwards anymore (but they CAN spin outwards). so the truth table would be: Code:
B1 | B2 | S1 | wheelsCode:
if (B1 is pressed and S1 is not pressed) |
Re: Using Limit Switches with the Arm
have you considered just using an encoder?
|
Re: Using Limit Switches with the Arm
Thank you both for your help. I'm pretty sure that I have a working limit switch code now :)
I took your eagle and made a truth table. This helped me out a lot while I was coding... L1|L2|L3|L4|Disallow| --------------------- T F F F Retraction - CHECK T T F F Retraction - NOT INCLUDED T F T F Retraction - NOT INCLUDED T F F T Extention, Retraction, Rotation from where it came F T F F Forward Rotation, Extention - CHECK F F T F Reverse Rotation, Extention - F F F T Extention, Retraction, Rotation from where it came F F F F Allow all movement - NOT INLCUDED I also found that my code was overcomplicated, and could have been simplified to the ones posted here: http://www.chiefdelphi.com/forums/sh...ad.php?t=60186 And popo, yeah I could have probably used an encoder, but this is my first year in FIRST (lol) and it is my team's second year, so we've not yet had to chance to use those, and with one day left we probably won't get to this season. I also didn't want to let my team down, they did a lot of work cutting stuff to hold the limit switches in place :P With every year comes advancement... |
| All times are GMT -5. The time now is 08:59. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi