View unanswered posts | View active topics It is currently Wed Nov 21, 2018 4:28 am

 Page 1 of 1 [ 2 posts ]
 Print view Previous topic | Next topic
Using the average of two motor encoders to move the robot?
Author Message
Rookie

Joined: Mon Dec 15, 2014 9:48 pm
Posts: 16
Using the average of two motor encoders to move the robot?
Right now our robot has two motors on the right side and two on the left side. Both motors on each side were connected to the same port in the motor controller. So the program could just move the left or right side and it would move both motors on that side. We have decided to connect all four motors separately so that we can use the average of both motor's encoders to make encoder movement more accurate.

How our encoder movement code was before to move the robot straight:

while (nMotorEncoder[motorE] > -360)
{
motor[motorE] = -20;//left side of robot

motor[motorG] = 20;//right side of robot
}
motor[motorE] = 0;
motor[motorG] = 0;

How we want to code our new motors using the average of two encoders:

while (nMotorEncoder[motorE] + nMotorEncoder[motorF] / 2 > -360)
{
motor[motorE] = -20;//left side of robot
motor[motorF] = -20;//------

motor[motorG] = 20;//------
motor[motorH] = 20;//right side of robot
}
motor[motorE] = 0;
motor[motorG] = 0;

Is it possible to use the average value of two encoders to move the robot like this? If so, could someone please provide an example of how you would code that? Thank you!

Tue Jan 13, 2015 5:24 pm
Professor

Joined: Sat Aug 31, 2013 9:15 am
Posts: 256
Re: Using the average of two motor encoders to move the robo
It looks like you've pretty much got it, except that you're missing a set of parenthesis. You need your loop condition to be
 Code:while ((nMotorEncoder[motorE] + nMotorEncoder[motorF]) / 2 > -360)

because otherwise it's adding half of the encoder value of motorF to the full encoder value of motorE, which is definitely not what you want!!

_________________
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
FTC Team 7468 Blue Chariots of Fire - Mentor (2014-2015)
Check out our team website at http://bluechariotsoffire.com/.

Tue Jan 13, 2015 5:52 pm
Display posts from previous:  Sort by
 Page 1 of 1 [ 2 posts ]

#### Who is online

Users browsing this forum: No registered users and 2 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ ROBOTC Applications    ROBOTC for LEGO MINDSTORMS       Third-party sensors    ROBOTC for CORTEX & PIC    ROBOTC for VEX IQ    ROBOTC for Arduino    Robot Virtual Worlds    Multi-Robot Communications    Issues and Bugs Competitions & Partners    Mini Urban Challenge    CS2N Robot Virtual Worlds Competitions       VEX Skyrise Competition 2014-2015       VEX Toss Up 2013-2014       FTC Block Party! 2013-2014    Competitions using VEX - BEST, TSA, VEX, and RoboFest!    FTC Programming    RoboCup Junior and Other ROBOT Competitions Virtual Brick Robotics Discussions    General Discussions    Project Discussions Off-Topic ROBOTC Forum & ROBOTC.net Suggestions/Feedback    ROBOTC Forums Suggestions/Comments    ROBOTC.net Suggestions/Comments       NXT Programming: Tips for Beginning with ROBOTC       VEX Programming: Tips for Beginning with ROBOTC    2013 Robotics Summer Of Learning       VEX Toss Up Programming Challenge       FTC Ring It Up! Programming Challenge    International Forums       Spanish Forums          ROBOTC for MINDSTORMS          ROBOTC for VEX       French Forums          ROBOTC pour Mindstorms          ROBOTC pour IFI VEX       Japanese Forums （日本語のフォーラム）       German Forums    2015 Spring Carnival Event    PLTW (Project Lead The Way)    Robotics Merit Badge    2014 Robotics Academy Summer of Learning