Connecting SSC-32 to STK500

hi,
can you please help me?
i wants to connect my SSC-32 to the STK500 with Atmeg 8515(the stk500 has two serial cables RS232)and i wants to program my hexapod in C.
my question, can i first connect the STK500 with the serial cable to the pc and from second serial cable from STK 500 to the SSC-32???

Yes, you should be able to connect the second serial port to the SSC-32 without any problems. The SSC-32 accepts ASCII text commands, so it does not care where the input comes from. :slight_smile: The SSC-32 does not use or require flow control, so keep this in mind when you are sending commands to it.

8-Dale

thanks for the answer:-)
when i send now the command from pc to the SSC-32 he will send it directly to the seros to move??
waht muss i do to write the pwm commands in c?? muss i initialize first the SSC-32 in my Programm??
have you a C CODE example to initialize SSC-32 ??

I guess the real question is what all do you want to do. i.e. it really depends on what you wish each piece to do. What functionality do you want the ATMega to do versus what functionality do you want the PC to do.

In all cases you will need to initilaize the serail ports on the ATmega to have the right baud rates and the like. Then you simply have to output ASCII text with the appropriate commands to the SSC32. These commands are shown in the SSC32 manual that is up on the website. There are several examples of Basic Atom code in the forums that can show you examples of the types of commands.

One option would be to have the ATMega to replace the functionality of the Atom or Atom Pro that several of us on our Hex robots. A starting point would be to download the powerpod program which will generate Basic code for the hexapod and simply convert this to C.

Another option would be to have majority of the processing associated with the gait on the PC and develop a communication protocal between the PC and your board with information on what you want all of the several to do next. Your Atom code could then format this into the appropriate Ascii text to send to the SSC32.

You could have the PC generate the actual sequences and then write code on the Atmega that simply forwards the commands to the PC.

There are many possibilitys.

Good Luck

if you take a look at the ssc-32 users manual this might not all seem so complicated… unless you’ve never written any code at all for your stk500 in which case you might want to work through some basic concepts like configuring the serial port, connecting the serial port to something that can display what you send over it (like a PC running hyperterminal), and sending “hello world” out of it to verify you have all the basics working. once you can send a character string out the serial port and know it is going to arrive correctly at the destination you basically replace “hello world” with your ssc-32 command strings. it’s pretty straight forward.

ooohh yeah… by the way… before we get too carried away can we correctly assume that you have connected the second rs-232 port of the stk500 to the uart output as described in section 3.5 of the users guide?

and having accomplished that can we also assume that you are using a null-modem cable to connect that second port to the ssc-32?

just fyi, figure 3-10 of the stk500 users manual shows TXD on pin 2 and RXD on pin 3. The ssc-32 schematic on page 14 of its user manual also shows its TXD on pin 2 and RXD on pin 3 so you need a null-modem cable to flip the connections between pins 2 and 3.

Have you ever converted BASIC or any BASIC like language to C? I had to do this a couple of times at a former job - converting MS BASIC compiler code to C. I had to keep the results produced by the C code within a couple significant digits (closer if possible) to what the BASIC code produced.

I did not work longer than 6 hour days while I was working on this and almost always left with a headache because I would have to switch back and forth between the BASIC and C contexts several times during the day.

Oc course, I was converting mathematical code, which is probably a lot more difficult to convert. Simple I/O type code should not be nearly as difficult to convert, but when it comes to servo control, that will probably be more difficult.

It should be possible to use the SSC-32 firmware code as an example when writing code for another microcontroller. When using an Atmega chip, it should be even easier of course. :smiley:

8-Dale

thnks,for your answers.
i have try it to send at first some commands to the servo motors and it work,i have calibrate all motors at 1500ms:.)
but i dont know how to send this cammands from the stk500??
can you please help me,

I am fairly certain we are trying to help you. Please answer the questions we have asked above. Here are most of the major points asked again in a more condensed form:

a. have you examined the ssc-32 user manual so you understand its ASCII commands and how to power and configure it properly?

b. have you configured your stk500 board to enable the second communications port, and are you using a null-modem cable to connect the stk500 to the ssc-32?

c. does the software you have written for your stk500 properly configure the its uart for the same baud rate and communications settings your ssc-32 is set to? have you tested this using something other than the ssc-32?

d. how proficient are your programming skills, how much experience do you have working with the stk500 tool set? are you able to understand and translate the MBASIC sample code available through the Lynxmotion site to C for the STK500 compiler?

I will second EddieB on this. It is hard to help you when we don’t know what you need help with…

but I see I forgot to answer Dale’s response.

Yes, I have converted Basic Code to other languages before. I believe I have done to C as well as fortran, PL1 and Databus (Datapoint computers) But that was a long time ago.

I found it much easier to not do a line for line translation, but instead understand the functionality and then recode this in whatever language I was using. But that is sort of off the main topic here.

Again I am not sure where you need help. But for example I do have some C and C++ code that I used to run on some ATMEga32 chips including on the STK500. I have a C++ Comm class that I used to output to a serial port. It was specific to my setup at the time (which comm port, MHZ of the processor, which baud rate…). Assuming as Eddie mentioned you have the hardware set up properly, this is one place that I would start at. I have included the code and definition for this class below. But again it is only for example and you weed need to change all of the initialization code/defines for your processor and setup. Also note it is hacked up code that could easily be improved on…

// First the class definition
#pragma once

class COMM
{
public:
	/* constructor for setting the registers ('A', 'B', etc)
	   and pin/port (0-7) for serial transmit and receive;
	   use '-' for Rx or Tx reg if corresponding communication
	   isn't needed (e.g. regRx = '-' means no receiving) */
	COMM(char regRx, char pinRx, char regTx, char portTx);

	/* transmits text via serial connection */
	void Print(const char *psz) const;
	
	/* returns true if there is unread data in the receive buffer */
	bool IsCharWaiting() const;
	
	/* returns the (next) character in the receive buffer (0 if none) */
	char InKey() const;

	// Output one character
	void TxCh(char ch) const;

private:
	void Init(bool fRx, bool fTx) const;
	
	/* static variable: one per class, not instance */
	static bool m_fInit;
};
//
//
// Now the class code
/*	Comm.cpp
*
*	Serial communications
*	- assumes internal clock is running at 8MHz
*	- communicates at 19.2k baud, 8-N-1
*	- Rx expected to be on PD0
*	- Tx expected to be on PD1
*/

#include <avr/io.h>
#include "Util.h"
#include "Comm.h"
#include "Debug.h"

bool COMM::m_fInit = false;

COMM::COMM(char regRx, char pinRx, char regTx, char portTx)
{
	if (!m_fInit)
		Init(regRx != '-', regTx != '-');

	/* this code uses Rx and Tx for output; make sure caller knows that! */
	/* (can't show asserts [via ser
ial] until it's set up!) */
	Assert(regRx == 'D' || regRx == 'd' || regRx == '-');
	Assert(pinRx == 0 || regRx == '-');
	Assert(regTx == 'D' || regTx == 'd' || regTx == '-');
	Assert(portTx == 1 || regTx == '-');
}

/* initializes serial transmit and receive at 19.2k baud, 8-N-1 */
void COMM::Init(bool fRx, bool fTx) const
{
	m_fInit = true;

	if (fRx)
		SetBit(UCSRB, RXEN);	// enable receive
	else
		ClearBit(UCSRB, RXEN);	// disable receive

	if (fTx)
		SetBit(UCSRB, TXEN);	// enable transmit
	else
		ClearBit(UCSRB, TXEN);	// disable transmit

	/* UBRR = 25 gives us 19.2k baud */
	UBRRH = 0;
	UBRRL = 25;		// change to 12 for 38.4k baud

	/* set UCSRC (not UBRRH), asynch, no parity, 1 stop bit, 8 data bits */
	UCSRC = (1<<URSEL) | (1<<UCSZ1) | (1<<UCSZ0);
}

/* transmits text via serial connection */
void COMM::Print(const char *psz) const
{
	const char *pch;

	for (pch = psz; *pch != 0; ++pch)
		TxCh(*pch);
}

/* helper function: transmits a single character (after waiting
   for any prev transmission to complete) */
void COMM::TxCh(char ch) const
{
	while (bit_is_clear(UCSRA, UDRE))
		;
	UDR = ch;
}

/* returns true if there is unread data in the receive buffer */
bool COMM::IsCharWaiting() const
{
	return bit_is_set(UCSRA, RXC);
}

/* returns the (next) character in the receive buffer (0 if none) */
char COMM::InKey() const
{
	if (bit_is_clear(UCSRA, RXC))
		return 0;
	return UDR;
}

Now assuming you had something like the above code working, you could write a function that looked something like:

void All1500()
{
    int     i; 
    char  sz[80];

    for (i=0; i < 32; i++)
    {
        sprintf(sz, "# %d P1500", i);
        commSSC32.Print(sz);
    }

    sprintf(sz, "#T576\n");
    commSSC32.Print(sz);
};

Note: I did not try to compile this and I may have missed something, but I think this shows sortof the general idea, where commSSC32 would be the instance of the comm class that is properly initialized to talk to your SSC32.

I hope this helps

hey EddieB,
to your question,
a:yesi have examined the ssc-32 user manual and i have tested it only with the servo motors and Pc and it works.i can move from the lynxmtion Terminal all motors.
b:i dont have try to move the motors with the STK 500 but i have configureted it and tested with assembler programm to switch the leds and it working.
c: i have not yet written any programin my stk500, i dont know how to initialize it:—(((
d:i am not so fit in programming but i am learning it,i can understand theMBASIC but i can not translate it to C.

Hey kurte,
thanks it will be help me:-)))
i am trainig to understand it and to translate it to C:-)))