Search the web
Sign In
New User? Sign Up
bestinc · Best Inc.
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
2 servos going opposite directions?   Message List  
Reply | Forward Message #562 of 1079 |
Re: 2 servos going opposite directions?

--- In bestinc@yahoogroups.com, "joeymarshall@..." <joeymarshall@...> wrote:
>
> Hello everyone!
>
> I am actually coming down to the wire on this one, and I really would
appreciate someone bailing me out!
>
> I need a program for the Brain that has 3 motors: channel 1,2,and 4
>
> and then channel 3 would have 2 servos going opposite directions of each
other. (one clockwise the other counter clockwise)
>
> Has anyone already done this program for their robot, or already have a
completed program they could just share with me?
>
> I need to use this program Friday, and I ran out of time to learn c
programming :)
>
> Just FYI, I'm not a student, I'm an official working on next years game :)
>
> You can just reply to me personally if you prefer, you don't have to share the
program with the whole group if you don't want to!
> Thanks very much! -Joey

Hey Joey,
I'm glad to see I won't be the only one there without much driving practice.
I previously posted this whole program under subjects including the word
remap. I'll followup with you in email as well.
This does arcade drive with parabolic scaling.
The Brain wizard would probably be able to do what you want.
Note that this uses raw C numbering, starting at 0, instead of 1.
I've added some servo reverse code to the bottom.
It is untested so far, but it should get you started.
--Joel

// OK, I'll just post the whole thing here in every topic list.
// Click IAR, do Create new project, type C, subtype Brain
// edit main.c, paste in this text instead.
#include <msp430x14x.h>
#include <bestapi.h>
int main( void ) {
unsigned short inval;
int xInput, yInput, rightValue,leftValue;
InitBrain(); // initialize the system
while(1) { // do this forever, remap start
yInput=parabolicScale(getRcValue(1,16,100),125)-RCIDLEVAL; //speed
xInput=parabolicScale(getRcValue(0,16,100),125)-RCIDLEVAL; //steer
leftValue = yInput + xInput; // combine the inputs
rightValue = yInput - xInput; // to create output deltas
// bound the delta values (remember RCIDLEVAL is half RCMAXVAL)
if (leftValue > RCIDLEVAL) leftValue = RCIDLEVAL;
if (leftValue < -RCIDLEVAL) leftValue = -RCIDLEVAL;
if (rightValue > RCIDLEVAL) rightValue = RCIDLEVAL;
if (rightValue < -RCIDLEVAL) rightValue = -RCIDLEVAL;
// protobot: m0 = lift, m1=leftw, m2 = rightw
inval = parabolicScale( getRcValue(3,50,100), 125); // c4=c3 left
side to side stick
setMotor(0,inval); // set lift motor, needs limit switch!
// output the values and include the idle offset
setMotor(1,rightValue+RCIDLEVAL); // right wheel is m1 = 2
setMotor(2,leftValue+RCIDLEVAL); // left wheel is m2 = 3
// end remap
// add Joey reversable servo code from channel3 = enum2
inval = parabolicScale( getRcValue(2,50,100), 125); // c3=2 left
updown stick
setServo(0, inval); // servo1 follow left updown stick
setServo(1, RCMAXVAL - inval ); // invert servo 2
}
}





Thu May 28, 2009 8:51 pm

joel.graber1
Offline Offline
Send Email Send Email

Forward
Message #562 of 1079 |
Expand Messages Author Sort by Date

Hello everyone! I am actually coming down to the wire on this one, and I really would appreciate someone bailing me out! I need a program for the Brain that...
joeymarshall@...
joeymarshall...
Offline Send Email
May 28, 2009
2:18 pm

... Hey Joey, I'm glad to see I won't be the only one there without much driving practice. I previously posted this whole program under subjects including the...
joel.graber1
Offline Send Email
May 28, 2009
8:51 pm

... Hi, I am a student for the Rio Rancho Robo Runners robotics team, and I was just wondering if our team may use this code for our brain, and modify the code...
seancsnm
Offline Send Email
Sep 28, 2009
12:38 am

... You have my permission, and it is posted on a public site available to all teams, so it seems reasonable. ... That would be a good idea, since that is how...
joel.graber1
Offline Send Email
Sep 30, 2009
6:09 pm

Just off the top of my head, I would replace the event loop in the default program with the following: while(1){ for(chan=0;chan<4;++chan) { ...
dmgauntt2002
Offline Send Email
Sep 28, 2009
1:44 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help