Problems connecting to SSC32

Hi,

I have some problems connecting to my SSC32 using the Win32 API. Whenever I open my RS-232 port and send “ver\r” to verify the connection the program is unable to read from the port (the LED is flashing, so it seems to receive the data). I always have to start LynxTerm, send something, close LynxTerm again, from this time on it works. If I reboot Windows or unplug/plug my Wiretek USB-to-RS232-cable I have to repeat this (sometimes also in random situations as it seems). Here’s the code:

[code] char buffer[1024];

	HANDLE hf = CreateFile( "\\\\.\\COM3", GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL );

	if( hf == INVALID_HANDLE_VALUE )
		throw std::runtime_error( "opening handle failed" );

	if( !SetupComm( hf, sizeof( buffer ), sizeof( buffer ) ) )
		throw std::runtime_error( "setting up comm failed" );

	DWORD bytesWritten = 0;
	if( !WriteFile( hf, "ver\r",  sizeof( "ver\r" ), &( bytesWritten ), NULL ) )
		throw std::runtime_error( "writing comm port failed" );

	std::cout << bytesWritten << " bytes written" << std::endl;

	DWORD bytesRead = 0;
	if( !ReadFile( hf, buffer, sizeof( buffer ), &( bytesRead ), NULL ) )
		throw std::runtime_error( "reading comm port failed" );
	std::cout << bytesRead << " bytes read" << std::endl;

	buffer[bytesRead] = 0;

	std::cout << buffer << std::endl;[/code]

Simple enough, I don’t realize what’s the problem here. I found some C# code which does basicly the same – but works:

[code] TempController.ServoController sc = new TempController.ServoController( 3 );

	SerialPort port = new SerialPort( "COM3", 115200 );
	port.Open();
	port.NewLine = "\r";

	port.WriteLine( "ver\r" );

	System.Diagnostics.Debug.WriteLine( "received: \"" + port.ReadLine() + "\"" );[/code]

Seems like the only difference is the assignment of the NewLine character – if i remove this line the C# code acts the same as the C++ code, it hangs when it comes to reading from the port. Given this behaviour I am pretty sure that I am missing something in the initialization, but I couldn’t find a NewLine or some similar property in Win32.

Unfortunately I couldn’t find C++ sample code. How do you set up your COM handle in LynxTerm or in RIOS?

Thanks!

You are digging into code but there are plenty of hardware (power supply) issues that can cause the SSC-32 to act erratic. Do you have problems with no servos connected? Can you provide a picture of your wiring and connections?

Hi, thanks for your reply.

Yes, I was digging into the code – since there’s no problem with the C# application (as long as I set the NewLine property) nor with LynxTerm I deduced the only reason for failure could be the way I open the COMM handle in the C++ program.

But you were right, when I unplugged all servos I had no problem connecting. After plugging them in again everything was as before.

Not sure if the pictures holds everything you need to know:

www3.pic-upload.de/06.07.10/y3h52b16vk14.jpgwww3.pic-upload.de/06.07.10/zt8d1rmyn5xy.jpg

Yes there is a problem…

You have the jumper VS1 = VL installed. This connects the servo voltage to the VL terminal (input of the 5vdc regulator). So you can power the microcontroller from the servo supply. This will work as long as the servo power supply has ample current. When you use this option you must only provide power on the VS terminal.

You have 6vdc coming in from the wall pack for the VS supply.

You have a 9vdc battery connected to VL.

Because you left the VS1 = VL jumper installed, you have directly connected 6vdc to 9vdc. The result is the 9vdc battery is quickly depleted. The arm will not operate correctly with a single supply (6vdc wall pack) and we recommend powering up VL separately by removing the VS1 = VL jumper. :unamused:

Thanks again for your support.

I knew there was something I missed in my post, sorry. What you cannot see on the photos is that I am NOT using a battery. I changed the jumpers yesterday as my battery went empty. In the SSC32 manual I read that it was possible to power the microcontroller from the servo supply and I didn’t see the point of using both a battery and a power supply so I changed this.

Before yesterday I had a 9VDC battery connected and the jumper VS1=VL was NOT installed, the problem I described is present for some weeks now. (Also both VS1=VS2 jumpers were present back then, if that matters.)

I went back and reread the problem description from above. There should be no need to run LynxTerm to get your program to work. You do realize windows will only allow one program to have control of the serial port at a time. Serial port or Virtual Com Port (VCP) with a USB adapter is the same thing. Make sure no other program is using the serial port when starting your application. Also remember that the commands sent to the SSC-32 will not be acted on until it receives the CR. I’m not certain if it requires CR/LF or just CR. Hope this helps.

Thanks again for your reply.

Yes, I am aware of that. Are there any other things to consider when opening a serial port (Baudrates, Stopbits, Parity, I don’t know…)?

My program is the only one using this port. I first run LynxTerm, send some commands so I can hear the servos buzzing, then I close LynxTerm and run my application.

The manual says CR, I tried both.

Hi,

I have a bit of a different problem. I broke off the VSI connector while trying to jam the too large braided cords into the jumper. I have connected the power to the VS2 terminal instead. I had the serial port to USB going before this, (using VS1) but now keep getting an error (WriteFile function failed) when trying to type in the ‘ver’ command in the Lynx terminal. It throws the error as soon as I type the first letter. My serial-to-USB adapter is a TrippLite Keyspan USA-19HS and it’s own connection test passes. The green light by the D1 marked Com port is solid green.

Questions: Can I use the VS2 terminal to connect to instead of the VS1?

If so, what jumpers do I need to remove/have in place in order for this to work?

I’ve tried connecting with both a servo attached and without. I’ve kept the negative/positive (red/black) wires aligned in the same way as VS1 diagram shows.

Yes, and you can keep the VS1=VS2 jumpers in place so that the VS1 line shares the same power supply as VS2. The VL=VS jumper should be removed.