Hi, I have a problem with Serial 8- Servo controller. I am trying to send a postion to 4 servos, which is connected to same servo controller.
I got example codes from your web site. it is working great if I control one servo. But If I control 4 servo, servo controller does not send position to servos at the same time. It is so slow for me. Because I am going to control a helicopter. so I needed to send positions faster…
And then I changed your codes. I open a serial port, and then I dont close it until I get out from program. Now, servo controller sends positions to 4 servos at the same time, it is what I want. But the problem is positions are not correct. Also, servos does not turn full way. let s say current position is 0, and I want to make the positioin 250. When I send the data, servos just turns half-way and stop. Here is my codes, .
//Note : myPort, speedGlobal, baudGlobal are glocal variables…
/* public void connect(string port, int baud)
{
myPort = new SerialPort(port, baud, Parity.None, 8, StopBits.One);
myPort.Open();
}
private void sendBtn_Click_1(object sender, EventArgs e)
{
getData();
send(speedGlobal, 0, portGlobal, baudGlobal); //speed, pin number
send(speedGlobal, 1, portGlobal, baudGlobal); //speed, pin number
send(speedGlobal, 2, portGlobal, baudGlobal); //speed, pin number
send(speedGlobal, 3, portGlobal, baudGlobal); //speed, pin number
}
public void send(int speed, int pin, string port, int baud) // Mini SSC II mode...
{
const int MIN_ANGLE = 0
, MAX_ANGLE = 255;
if (speed < MIN_ANGLE)
{
speed = 0;
}
else if (speed > MAX_ANGLE)
{
speed = 254;
}
//convert speed into hex string
string speedHex = speed.ToString("X");
//convert speed into single byte
byte speedByte = byte.Parse(speedHex, System.Globalization.NumberStyles.HexNumber);
//convert pin number into hex string
string pinHex = pin.ToString("X");
//convert pin number into single byte
byte pinByte = byte.Parse(pinHex, System.Globalization.NumberStyles.HexNumber);
//start byte, servo number, position
myPort.Write(new byte[] { 0xFF, pinByte, speedByte }, 0, 3);
}
Thank you so much…
Benjamin