Newbie programming problems with SSC-32

Hello All

I have just signed up and am having a couple of problems with my robot.

It is controlled with SSC-32 and i have downloaded and used the lynx terminal with no problems but there’s only so much you can do with it. my question is how do i write program to the SSC-32. i have been taught C and Java and would quite like to program in C (or Java if necessary). i just don’t know where to start. Ideally what i want to get of this is be able to have a program running on the computer continually checking to see if i have pressed a button on the keyboard (or if not the keyboard a button on the screen), if a button is pressed then move a servo or set of servo’s on the SSC-32 in a particular way. How can i do this? Do i need to purchase a botboard? special software?

Any help or ideas would be greatly appreciated :smiley:

You need to write a program that sends characters out the serial port (typically COM1 on a Windows PC).

Here is an example of the critical code for Windows using Microsoft Visual C++. Java might make this easier, but I don’t have any examples for you:

void setupSerial()
{
	m_hSerialComm = CreateFile("COM1:", 
            GENERIC_READ | GENERIC_WRITE, 
            0, 
            NULL, 
            OPEN_EXISTING, 
            0, 
            NULL);

	if (m_hSerialComm == INVALID_HANDLE_VALUE)
	{
		//Handle Error Condition
	}

	if (GetCommState(m_hSerialComm, &dcbConfig))
	{
		dcbConfig.BaudRate = 38400;
		dcbConfig.ByteSize = 8;
		dcbConfig.Parity = NOPARITY;
		dcbConfig.StopBits = ONESTOPBIT;
		dcbConfig.fBinary = TRUE;
		dcbConfig.fParity = TRUE;
	}
	else
	{
		//Handle Error Condition
	}

	if (!SetCommState(m_hSerialComm, &dcbConfig))
	{
		//Handle Error Condition
	}

	if (GetCommTimeouts(m_hSerialComm, &commTimeout))
	{
		commTimeout.ReadIntervalTimeout     = 1000;
		commTimeout.ReadTotalTimeoutConstant     = 1000;
		commTimeout.ReadTotalTimeoutMultiplier     = 1000;
		commTimeout.WriteTotalTimeoutConstant     = 1000;
		commTimeout.WriteTotalTimeoutMultiplier = 1000;
	}
	else
	{
		//Handle Error Condition
	}

	if (!SetCommTimeouts(m_hSerialComm, &commTimeout))
	{
		//Handle Error Condition
	}
} // setupSerial()


void sendSerial(string str)
// Send the string to the SSC-32.
{
	printf("%s\n", str.c_str()); // echo the string
	str = str + "\n\r";
	sprintf(pszBuf, str.c_str());
	dwNumberOfBytesSent = 0;
	while(dwNumberOfBytesSent < str.size())
	{
		if(WriteFile(m_hSerialComm, &pszBuf[dwNumberOfBytesSent], 1, 
								&dwNumberOfBytesWritten, NULL) != 0)
		{
			if(dwNumberOfBytesWritten > 0)
				++dwNumberOfBytesSent;
			else
			{
				//Handle Error Condition
			}
		}
		else
		{
			//Handle Error Condition
		}
	}
} // sendSerial()

Pete

Thanks for the reply.

From what i understand this code creates the initial set up required to communicate with the SSC-32 but how exactly do you send this to the SSC-32 do I just need to compile and execute it on the computer for it to work?

And if anyone else has any examples in C or Java examples I would happily bow down before your Kindness.

Thanks

The example I posted is not complete - it was just supposed to give you the idea of what you need to do. It is from a program I wrote last year when I got my SSC-32. I wanted a ‘scripting tool’ for trying out gait algorithms.
I can send you a ZIP of the complete program project if you want.

Inside a complete program, you would call the sendSerial() function with something like this:
sendSerial("#1 P1500");
This call would move servo #1 to its center position.
The SSC-32 docs explain the syntax of the commands.

The Lynx terminal works the same way - it sends commands like the above example out the serial port. That’s all there is to it.

You might be better off researching “how to send ASCII data to a serial port in a Java app”.

Pete

Thanks again for your post.

I have decided to take your advice and try using java instead. I have found a way of doing what I wanted, the only problem being that it requires javax.comm to be used and I am unsure of where i need to put it in order to use its functions. I know it should go with the other library stuff i just don’t know were that is.

I have also just started to learn C++ so if every thing else fails, could you perhaps send me that zip file, please. Then maybe in a few weeks I’ll be able to understand and use it.

Thanks