Search  
Tuesday, January 06, 2009 ..:: Forum ::.. Register  Login
 HomePage Minimize

 Print   

 Products Minimize

 Print   

 MSRS Minimize

 Print   

      
 RoboticsConnection Forum Minimize
SearchForum Home
  Discussions  Serializer Robot Controller  Odd .Net PID mo...
 Re: Odd .Net PID motor problem
 
 11/8/2007 11:36:35 AM
jason
158 posts
5th


Re: Odd .Net PID motor problem

Patrick,

I see the problem...I'm always storing the absolute value of the RotationAngle when this property gets set.  Thus, if you had previously set the value to -30, it would have store the value 30 in the RotationAngle's private 'angle' member.  Then, when you set the RotationAngle property to 30, you can see that nothing will get set, since it thinks the last value (angle) is 30.  Thus, when you invoke Rotate(), it uses the last value stored, and it keeps using that.  Thus, when you set a slightly different angular value, then Rotate() works as desired.  Dohh!!  I'll get this fixed asap. :)

public double RotationAngle

{

      get { return angle; }

      set

      {

            if (angle != value)

            {

                  int fractionalRotation = 0;

                  double angularDistancePercentage = 0;

                  angle = Math.Abs(value);

                  if (angle == 0)

                        return;

                  // Figure out how far in ticks the motors need to turn...

                  // Number of complete rotations:

                  int fullRotations = (int)angle / 360;

                  // Fractional Rotation left over:

                  if ((angle%360) != 0)

                        fractionalRotation = (int)(360 / (angle - (fullRotations * 360)));

                  // Fractional Distance:

                  if (fractionalRotation > 0)

                        angularDistancePercentage = trackCircumference / fractionalRotation;

                  // Final Distance:

                  double finalDistance = (trackCircumference * fullRotations) + angularDistancePercentage;

                  // Determine how many ticks it'll take to go the specified distance:

                  double revolutions = finalDistance / wheelCircumference;

                  distanceTicks = (int)(revolutions * ticksPerRevolution);

                  // Set the distance (in ticks) for each motor to travel...

                  if (value > 0)

                  {

                        // Right Turn Clyde!

                        motor1Distance = distanceTicks; // Left Motor

                        motor2Distance = -distanceTicks; // Right Motor

                  }

                  else

                  {

                        // Left Turn Clyde!

                        motor1Distance = -distanceTicks; // Left Motor

                        motor2Distance = distanceTicks; // Right Motor

                  }

            }

      }

}


Jason Summerour
President,
Summerour Robotics Corp
Microsoft MVP
www.roboticsconnection.com
 11/8/2007 11:40:05 AM
jason
158 posts
5th


Re: Odd .Net PID motor problem

Patrick,

Okay, it'll be on it's way this afternoon. :)

Thank you for your order!


Jason Summerour
President,
Summerour Robotics Corp
Microsoft MVP
www.roboticsconnection.com
 11/8/2007 11:43:18 AM
rpg
35 posts


Re: Odd .Net PID motor problem
Hi Jason,

This is really good news--I thought I was going nuts or doing something really daft.  Glad to hear it will be an easy fix.  In the meantime, I can live with my workaround.

--patrick

 11/8/2007 11:47:29 AM
jason
158 posts
5th


Re: Odd .Net PID motor problem

Patrick,

Nope, just a bug added one late night from one very overly worked programmer/business man/engineer/daddy/husband. :)

 


Jason Summerour
President,
Summerour Robotics Corp
Microsoft MVP
www.roboticsconnection.com
 11/8/2007 12:09:28 PM
rpg
35 posts


Re: Odd .Net PID motor problem
Hey Jason,

It's our job to find the bugs. :)  Just keep up the great work!

--patrick

  Discussions  Serializer Robot Controller  Odd .Net PID mo...

SearchSearch  Forum HomeForum Home    Print   

Copyright 2004-2007 Summerour Robotics Corp   Terms Of Use  Privacy Statement
DotNetNuke® is copyright 2002-2009 by DotNetNuke Corporation