Respected members
i have scs 32 serco controller and i am talking serially to it , my code is in visual studio
it is not working , it doesnot show any error but also servo is not rotating plz help me
[code]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) { }
}
}
not sure how that open of the comm port is setting the baud rate and what rate is it defaulting to… My VB code looks like:
[code] Try
Using com1 As IO.Ports.SerialPort = _
My.Computer.Ports.OpenSerialPort(g_sCommPort, g_sBaudRate, IO.Ports.Parity.None)
com1.Handshake = IO.Ports.Handshake.None
com1.DtrEnable = False
com1.NewLine = Chr(13)
com1.ReadTimeout = 200 'wait a maximum of .2 seconds for a complete line
…
[/code]
Not sure how well your Q loop works as you immediately do a read existing after your output of the Q command. My code does a read after setting a timeout value and catch the excption…
Note: please only post your question in one place… That is many of us read all new posts…
Also please post as complete of a description as possible. Things like:
a) How is the SSC-32 powered? Do you have power running to both VS and VL?
b) What jumpers are installed on the board.
c) When you turn on the SSC-32 does the LED light up? When you run your program does the LED on the board flash…
but the c-console applcation here is not working also when i run this code the yellow light blow off it does not even blink so this show the board is not recieving any data , basically can you provide your full vb code i am a beginner i want to control motors using speech , i have done speech program in c# thats why i was going for c# , but i am converting then to vb as it looks like it has more support basically i need code in vb like when i my computer detect my speech like hello through my speech code then he give this serial data to controller"#0 P577 S775",
this is just a example if i get this then rest i can do myself, thanks for your sugeestion once again as i am a started dont have so much knowledge about postings in forum
I have posted a few different VB apps in different threads, including a version of the simple terminal program, which you can find: viewtopic.php?t=6700&p=67058#p67058
sir i have made some changes in my c# code , i suppose previously i was not opening port correctly now i a, doing this when i use this code then serial data led once starts and dont end : the new code is
[code]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); //this is the change
_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) { }
}
}
}[/code]
and when i try this led blink once:
[code]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;
also i am using simple terminal program , i have this type of program but i want one in which i can give command to controller inside my code like the above code and one more question when i send a valid command to simple terminal after movement of servo why not led blinks off it remain on