Arduino Forum

Forum 2005-2010 (read only) => Software => Interfacing => Topic started by: whatevernot on Oct 21, 2010, 01:17 am

Title: Strangeness with Serial and pololu
Post by: whatevernot on Oct 21, 2010, 01:17 am
Hi -

I'm using a pololu servo controller via Serial - I have pin #1 (tx) on the arduino connected to "logic-level serial input" pin #3 on the pololu. Power and gnd is wired okay, I'm using 3 servos - it all works.

Sort of.

If I power up the arduino, and connect a terminal (can see the text equivalent of the commands sent to the pololu) everything works great. I can then quit the terminal app, unplug the usb cable, and the servos continue to work fine.

But if I don't hook up the terminal app, it doesn't work. In other words, if I just power up the board with no usb or terminal app, the servos don't move - there is something that the polulo doesn't like (?). As soon as a terminal app is connected, the servos start turning (and the app can be killed and usb unplugged).

I can't figure out what the heck is going on.

Can anyone shed any light? Seems that the act of connecting the terminal somehow "makes it work".

Cheers, and thanks.

b...
Title: Re: Strangeness with Serial and pololu
Post by: zoomkat on Oct 21, 2010, 03:30 am
How are you powering your setup when it is not connected to the USB port?
Title: Re: Strangeness with Serial and pololu
Post by: whatevernot on Oct 21, 2010, 03:38 am
Hello- I have 5v power supply- it doesn't seem to be power related, as it works with just the 5v supply.

The weird part is that the terminal program needs to be connected to serial, if only briefly- it can be disconnected and the servos continue to work.

b...
Title: Re: Strangeness with Serial and pololu
Post by: zoomkat on Oct 21, 2010, 04:24 am
May be code that expects some type of terminal interaction.
Title: Re: Strangeness with Serial and pololu
Post by: PaulS on Oct 21, 2010, 11:52 am
Sounds more like the Arduino is not properly initializing serial communication with the controller. Post a link to the controller (and data sheet) and your code.
Title: Re: Strangeness with Serial and pololu
Post by: whatevernot on Oct 21, 2010, 02:47 pm
The user's guide for the pololu is here:

http://www.pololu.com/file/0J37/ssc03a_guide.pdf

My code is straightforward - here's my setup function:

void setup()
{
     Serial.begin(9600);
}

And the commands to control the servo take place here:

void servoSet(int servo, int angle)
{
     unsigned char buff[6];

     unsigned int temp;
     unsigned char pos_hi,pos_low;

     temp = angle & 0x1f80;
     pos_hi = temp >> 7;
     pos_low = angle & 0x7f;

     buff[0] = 0x80; //start byte
     buff[1] = 0x01; //device id
     buff[2] = 0x04; //command number
     buff[3] = servo; //servo number
     buff[4] = pos_hi; //data1
     buff[5] = pos_low; //data2

     for(int i = 0; i < 6; i++) Serial.print(buff, BYTE);
}

And so a call to servoSet sets the position of the servo.

As stated, all works fine as long as a terminal connection has been connected briefly.

There is a possibly similar thread here, but it doesn't address my issue:

http://forum.pololu.com/viewtopic.php?t=745
Title: Re: Strangeness with Serial and pololu
Post by: whatevernot on Oct 21, 2010, 04:41 pm
ARG. Arg arg arg - I apologize - I am an idiot - I went down a rabbit hole - still have the issue, but it's not related to the pololu - this is a red herring.

The way I am sending messages to the arduino is via the ethernet shield - have a little http server. If I connect the terminal app, then everything works, if I don't connect the terminal app via serial, then nothing.

So, something to do with how Serial and Ethernet are behaving - I am still stumped, but know a bit more.

Hmmmm... Frustrating....

Thanks.
Title: Re: Strangeness with Serial and pololu
Post by: whatevernot on Oct 21, 2010, 06:43 pm
Closing this thread out, and starting a new one, as the problem still persists, in that I need a serial connection before the server works.