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/7/2007 9:19:53 AM
rpg
35 posts


Re: Odd .Net PID motor problem
Ooops--here is the code.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using RoboticsConnection.Serializer;
using RoboticsConnection.Serializer.Components;
using RoboticsConnection.Serializer.Controllers;
using RoboticsConnection.Serializer.Ids;
using RoboticsConnection.Serializer.Sensors;

namespace TestSerializer
{
    public partial class Form1 : Form
    {
        static Serializer Serializer;
        static PIDMotorController pidDrive;

        public Form1()
        {
            InitializeComponent();

            Serializer = new Serializer();

            Serializer.PortName = "COM30";
            Serializer.BaudRate = 19200;

            Serializer.CommunicationStarted += new SerializerEventHandler(serializer_CommunicationStarted);
            Serializer.StartCommunication();
        }


        static void serializer_CommunicationStarted(Serializer sender)
        {
            Console.WriteLine("Communication started");

            pidDrive = new PIDMotorController(Serializer);

            Serializer.Units = Units.English;

            // Set velocity and distance PID parameters:
            pidDrive.VelProportional = 10;
            pidDrive.VelIntegral = 0;
            pidDrive.VelDerivative = 5;
            pidDrive.VelLoop = 5;
            pidDrive.DistProportional = 1;
            pidDrive.DistIntegral = 0;
            pidDrive.DistDerivative = 0;
            pidDrive.DistAcceleration = 1;

            // Set Physical drivetrain configuration parameters.
            pidDrive.EncoderResolution = 5500;
            pidDrive.TicksPerRevolution = 5500;
            pidDrive.GearReduction = 1.0;
            pidDrive.WheelDiameter = 6.25;
            pidDrive.WheelTrack = 12.58;
            pidDrive.VelocityDivider = 0.67;
        }

        private void Forward_Click(object sender, EventArgs e)
        {
            pidDrive.Speed = 10;
            pidDrive.Distance = 12;
            pidDrive.TravelDistance();
            Thread.Sleep(3000);
            pidDrive.Stop();
        }


        private void Reverse_Click(object sender, EventArgs e)
        {
            pidDrive.Speed = 10;
            pidDrive.Distance = -12;
            pidDrive.TravelDistance();
            Thread.Sleep(3000);
            pidDrive.Stop();

        }

        private void Left_Click(object sender, EventArgs e)
        {
           pidDrive.Speed = 10;
           pidDrive.RotationAngle = -30;
           pidDrive.Rotate();
           Thread.Sleep(3000);
           pidDrive.Stop();
        }

        private void Right_Click(object sender, EventArgs e)
        {
            pidDrive.Speed = 10;
            pidDrive.RotationAngle = 30;
            pidDrive.Rotate();
            Thread.Sleep(3000);
            pidDrive.Stop();
        }

        private void StopMotors_Click(object sender, EventArgs e)
        {
            pidDrive.Stop();
        }
    }
}
 11/8/2007 10:50:07 AM
rpg
35 posts


Re: Odd .Net PID motor problem
Since no one else seems to be having this problem, but I really, really need to get it fixed, I continued banging my head against it last night.  Finally I found a work around: if I make the left and right rotation angles different, even by a little bit, then the problem goes away.  For example, in the code above, if I make the left rotate angle -30 degrees and the right rotate angle 31 degrees (instead of 30), then I get the correct PID control behavior when clicking the buttons on the form.  So if there is a bug in the Serializer API or firmware behind my problem, it seems to be this: if you rotate left a number of degrees X, then try to rotate right the same number of degrees X, then the PID controller actually rotates left again through X degrees.  It's as if the sign of the RotationAngle parameter is being ignored (or getting stuck on a negative value) whenever the two angles have the same magnitude.  Note again that I don't see this problem when using the MOGO and DIGO commands directly at the firmware prompt.

Go figure.  In the meantime, I have ordered a new Serializer board to rule out a hardware problem.

--patrick

P.S. I'd be really grateful if someone else could try my simple form (assuming you are using the Serializer's PID drive control with encoders) to see if you get the same weird behavior that I am seeing.



 11/8/2007 11:14:44 AM
jywilson
35 posts


Re: Odd .Net PID motor problem

Hey Patrick,

I will definitely give your form a try with my new Stinger robot.  Unfortunately, I am still assembling my Stinger (has encoders), and I won't be able to get to it till this weekend.  I will let you know what I learn.


James Y. Wilson
http://www.learningce.com
Fortudine Vincimus!

 11/8/2007 11:17:39 AM
jason
158 posts
5th


Re: Odd .Net PID motor problem

Hey Patrick,

Sorry to take so long to respond...I've had a large workload this week.

I'm guessing the problem lies in the .NET Library.   This weekend, I will be releasing a new firmware version (w/ some enhancments and fixes), and I'll put a new Serializer .NET lib out too if I find the problems lies there.  I'm about to look at the .NET lib right now.

Thank you for your detailed debugging information, that helps tremendously!

I don't think it's your Serializer, but I can go ahead and ship one out.  If you want to wait until this weekend to get the latest code and see if it works, I can refund your money for the Serializer you just purchased...Up to you. :)

Best Regards!


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


Re: Odd .Net PID motor problem
Thanks for the replies James and Jason.  Jason, yes please ship out the new Serializer anyway since I like it so much I might want to use two of them in my project.  And besides,  I don't want to be a day without at least one of them should I blow one up or otherwise inadvertently damage it!  Looking forward to the firmware/library updates.

--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