|Seeking Sample Code To Use Encoder to Limit Arm Movement
|Page 1 of 1|
|Author:||bjohns5 [ Thu May 19, 2016 5:46 pm ]|
|Post subject:||Seeking Sample Code To Use Encoder to Limit Arm Movement|
I am a mentor for an FTC team in the Los Angeles region. With the switch to Android/Java this past season, we have NXTs and HiTechnic controllers that aren't being used so we created a pair of demonstration bots to take to schools and public events where we want to let children drive them. Each bot has a scoop on it powered by an AndyMark 40 motor to raise and lower it. We programmed the arm to raise and lower from the 0 and 4 buttons on the controller hat which works fine, but we did an outreach event last weekend and found that kids would hold down the buttons unknowingly and try to drive the mechanism past the mechanical limits, damaging it.
I theorize it should be possible to use the AndyMark built-in encoder to control the motor by treating it like a servo and running the motor to a specific encoder value. What we would like to do is have the hat button act as a toggle where a press on "up" would cause the motor to bring the scoop to a preset raised position and no further, and then a press on "down" would return it to the lowered position each time. This way the scoop would only have two defined positions, and could not be pushed past the stops to cause damage.
I hope some of you might have addressed this problem before in RobotC and might be willing to share your code with us. Our team does not have a lot of programming strength, and what we have is in Java, not RobotC. If we were trying to do this in Java I would have the team figure it out for themselves but since we aren't using RobotC in competition any more I'd rather have them spend their time on other things.
Thanks in advance for any help or suggestions you might have.
|Page 1 of 1||All times are UTC - 5 hours [ DST ]|
|Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group