Search  
Monday, January 05, 2009 ..:: Forum ::.. Register  Login
 HomePage Minimize

 Print   

 Products Minimize

 Print   

 MSRS Minimize

 Print   

      
 RoboticsConnection Forum Minimize
SearchForum Home
  Discussions  Serializer Robot Controller  Erratic Serial ...
 Re: Erratic Serial Communication
 
 10/11/2007 4:55:34 AM
James
5 posts


Re: Erratic Serial Communication

Thanks for all the help, I updated my code and while it made operation of the servo more reliable it still has a few issues. The servo doesn't move every time a button is pushed, sometimes it does, sometimes it taks 3-4 pushes before it goes. Other times the board needs a reset or even a power cycle. I am going to get a RS232 female to male adapter tomorrow so I can try and get my other PC with a built in serial port to run it. My timer class is set to 100, is this correct? Its so close to working correctly however I am planing on realtime applications so I need it to run perfectly 100% of the time. I have included my new code just incase I have made any obvious mistakes. Thanks once again for all your guys help.

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using RoboticsConnection.Serializer;

using RoboticsConnection.Serializer.Components;

using RoboticsConnection.Serializer.Controllers;

using RoboticsConnection.Serializer.Ids;

using RoboticsConnection.Serializer.Sensors;

namespace SerializerControl

{

   public partial class Form1 : Form

   {

//public static ServoMotorId ServoMotor5;

      public Form1()

      {

      InitializeComponent();

      InitSerializerComponents();

      s_.StartCommunication();

      }

      private void Periodic_Timer_Tick(object sender, EventArgs e)

      {

      s_.PumpEvents();

      }

      private void btnLeft_Click(object sender, EventArgs e)

      {

         panServo.Position = -80;

      }

      private void btnRight_Click(object sender, EventArgs e)

      {

         panServo.Position = 80;

      }

      private void btnCenter_Click(object sender, EventArgs e)

      {

      panServo.Position = 0;

      }

   }

}

 

using RoboticsConnection.Serializer;

using RoboticsConnection.Serializer.Components;

using RoboticsConnection.Serializer.Controllers;

using RoboticsConnection.Serializer.Ids;

using RoboticsConnection.Serializer.Sensors;

namespace SerializerControl

{

   partial class Form1

   {

      #region SERIALIZER OBJECTS:

      // Serializer Objects:

      private static Serializer s_;

      private static ServoMotorController panServo;

      #endregion

      #region SERIALIZER INITIALIZATION

      private void InitSerializerComponents()

      {

      s_ = new Serializer();

      s_.PortName = "COM7";

      s_.BaudRate = 19200;

      panServo = new ServoMotorController(s_);

      panServo.ServoMotorId = ServoMotorId.ServoMotor5;

      }

      #endregion

 10/11/2007 10:56:46 AM
jason
158 posts
5th


Re: Erratic Serial Communication

Your source code looks correct now, although your serializer (s_) and ServoMotorController (panServo) don't have to be static, since they're class members.

A period of 100 is fine for just controlling servo motors, as the Serializer.PumpEvents() is used to fire outstanding events for sensor readings.  Since there are no sensors, you don't have to worry about a fast loop invoking PumpEvents().

This app should work perfectly.  Can you put a Console.WriteLine("XXX Button Click"); in the button event handlers, so you can verify that the handler is indeed getting invoked every time you press it?

Let us know what you find out regarding this app working on your PC w/ the serial port.


Jason Summerour
President,
Summerour Robotics Corp
Microsoft MVP
www.roboticsconnection.com
 10/13/2007 9:41:05 PM
jason
158 posts
5th


Re: Erratic Serial Communication

Okay, I just wrote a quick app to mimic what you are doing, and button & servo response works just fine for me.

Here's the source:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using RoboticsConnection.Serializer;

using RoboticsConnection.Serializer.Components;

using RoboticsConnection.Serializer.Controllers;

using RoboticsConnection.Serializer.Ids;

using RoboticsConnection.Serializer.Sensors;

 

namespace ServoTest

{

   public partial class Form1 : Form

   {

      private Serializer _s;

      private ServoMotorController _servo1;

      public Form1()

      {

         InitializeComponent();

         _s = new Serializer();

         _s.PortName = "COM11";

         _s.BaudRate = 19200;

         _servo1 = new ServoMotorController(_s);

         _servo1.ServoMotorId = ServoMotorId.ServoMotor2;

         _s.CommunicationStarted += new SerializerEventHandler(_s_CommunicationStarted);

         _s.StartCommunication();

      }

      void _s_CommunicationStarted(Serializer sender)

      {

         Console.WriteLine("Communications Started");

         timer1.Enabled = true;

         _servo1.Position = 0;

      }

      private void LeftButton_Click(object sender, EventArgs e)

      {

         _servo1.Position = -99;

         Console.WriteLine("Left");

      }

      private void CenterButton_Click(object sender, EventArgs e)

      {

         _servo1.Position = 0;

         Console.WriteLine("Center");

      }

      private void RightButton_Click(object sender, EventArgs e)

      {

         _servo1.Position = 100;

         Console.WriteLine("Right");

      }

      private void timer1_Tick(object sender, EventArgs e)

      {

         _s.PumpEvents();

      }

   }

}

 


Jason Summerour
President,
Summerour Robotics Corp
Microsoft MVP
www.roboticsconnection.com
 10/14/2007 8:16:49 AM
James
5 posts


Re: Erratic Serial Communication

Thanks for the test App Jason, very much appreciated! I copied the debug .exe of my application over to my older desktop PC that has a built in serial communication port. After resoldering my null modem cable into a straight communications cable I finally got it to work perfectly. This leads me to the conclusion that it has to be my USB to serial port adapter. (Part # 3902B568) I googled it and found others having similar problems with this model on:

http://www.lynxmotion.net/viewtopic.php?t=2781&sid=b83e01ef744d1ddb59d8297575ff68d9

I think for the time being I will have to develop applications on my laptop then test them on my desktop. I tried changing the transmit buffer to 1 and 3 down from 16 but this did not help any. This adapter does work well with hyperterminal however, just not with Visual Studio applications. I will do a bit more research to see if there are any better USB to serial port adapters or if there is anyway to fix my one. I will repost if I have any luck. What model USB to Serial works for you guys??

  Discussions  Serializer Robot Controller  Erratic Serial ...

SearchSearch  Forum HomeForum Home    Print   

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