Respected members
i have scs 32 serco controller and i am talking serially to it , my code is
it is not working , it doesnot show any error but also servo is not rotating plz help me
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO.Ports;
using System.Threading;
namespace cConsoleAppMonitorServoCompletion
{
class Program
{
static SerialPort _serialPort;
static void Main(string[] args)
{
try
{
_serialPort = new SerialPort();
_serialPort.PortName = "COM1";
_serialPort.Open();
_serialPort.Write("#27 P1600 S750\r");
Console.WriteLine("#27 P1500 S750\r");
string output;
output = "";
//Example: "Q <cr>"
//This will return a "." if the previous move is complete, or a "+" if it is still in progress.
while (!(output == ".")) //loop until you get back a period
{
_serialPort.Write("Q \r");
output = _serialPort.ReadExisting();
Console.WriteLine(output);
Thread.Sleep(10);
}
_serialPort.Close();
}
catch (TimeoutException) { }
}
}
}
Topic is about serial coomunication
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
George2 pointsPosted Jul 10, 2011, 6:11 AM EDT
...
_serialPort = new SerialPort(comPort, baudRate, parity, dataBits, stopBits);
_serialPort.Handshake = Handshake.None;
_serialPort.ReadTimeout = 500;
_serialPort.WriteTimeout = 500;
_serialPort.Open();
...
deepender singla70 pointsPosted Jul 10, 2011, 8:22 AM EDT
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO.Ports; using System.Threading; namespace cConsoleAppMonitorServoCompletion { class Program { static SerialPort _serialPort; static void Main(string[] args) { try { _serialPort = new SerialPort("COM1",15200,Parity.None, 8, StopBits.One); //[color=#0080BF]this is the change[/color] _serialPort.Open(); _serialPort.Write("#27 P1600 S750\r"); Console.WriteLine("#27 P1500 S750\r"); string output; output = ""; //Example: "Q <cr>" //This will return a "." if the previous move is complete, or a "+" if it is still in progress. while (!(output == ".")) //loop until you get back a period { _serialPort.Write("Q \r"); output = _serialPort.ReadExisting(); Console.WriteLine(output); Thread.Sleep(10); } _serialPort.Close(); } catch (TimeoutException) { } } } }and when i try this led blink once, but no servo movement
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO.Ports; using System.Threading; namespace cConsoleAppMonitorServoCompletion { class Program { static SerialPort _serialPort; static void Main(string[] args) { _serialPort = new SerialPort("COM1",15200,Parity.None, 8, StopBits.One); _serialPort.Open(); _serialPort.Write("#27 P1600 S750\r"); Console.WriteLine("#27 P1500 S750\r"); Thread.Sleep(10); _serialPort.Close(); } } }help me out