Legacy Forum: Preserving Nearly 20 Years of Community History - A Time Capsule of Discussions, Memories, and Shared Experiences.

Working without Robot Terminal

Bioloid robot kit from Korean company Robotis; CM5 controller block, AX12 servos..
8 postsPage 1 of 1
8 postsPage 1 of 1

Working without Robot Terminal

Post by bergere » Sun May 25, 2008 4:04 pm

Post by bergere
Sun May 25, 2008 4:04 pm

I want to send Chars to the CM5 without Robot Terminal.
Do somebody wrote such a software which i can use?
I want to send Chars to the CM5 without Robot Terminal.
Do somebody wrote such a software which i can use?
Für Fehler und Schrift haftet der Stift. Palim Palim
bergere
Savvy Roboteer
Savvy Roboteer
Posts: 28
Joined: Thu Nov 29, 2007 10:18 pm

Post by AlphA » Sun May 25, 2008 4:34 pm

Post by AlphA
Sun May 25, 2008 4:34 pm

That's pretty much what my wireless control script does.
http://robosavvy.com/forum/viewtopic.php?t=2424
That's pretty much what my wireless control script does.
http://robosavvy.com/forum/viewtopic.php?t=2424
AlphA
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 48
Joined: Mon Jan 07, 2008 6:12 am
Location: Ohio

Post by bergere » Sun May 25, 2008 7:36 pm

Post by bergere
Sun May 25, 2008 7:36 pm

Oh THX i will take a look at this. But before a little question to the following code. The problem is that UDR0 doesn´t work. UDR1 is working but not UDR0.


Code: Select all
#include <avr>

typedef unsigned char byte;


void printHex(byte bSentData);
void printHex2(byte bSentData);
void TxD80(byte bTxdData);
void TxD81(byte bTxdData);


void printHex(byte bSentData)//UDR1
{
  byte bTmp;

  bTmp =((byte)(bSentData>>4)&0x0f) + (byte)'0';
  if(bTmp > '9') bTmp += 7;
  TxD81(bTmp);
  bTmp =(byte)(bSentData & 0x0f) + (byte)'0';
  if(bTmp > '9') bTmp += 7;
  TxD81(bTmp);
}

void printHex2(byte bSentData)//UDR0
{
  byte bTmp;

  bTmp =((byte)(bSentData>>4)&0x0f) + (byte)'0';
  if(bTmp > '9') bTmp += 7;
  TxD80(bTmp);
  bTmp =(byte)(bSentData & 0x0f) + (byte)'0';
  if(bTmp > '9') bTmp += 7;
  TxD80(bTmp);
}

void TxD80(byte bTxdData)
{
  while(!(bit_is_set(UCSR0A,5)));
  UDR0 = bTxdData;
}


void TxD81(byte bTxdData)
{
  while(!(bit_is_set(UCSR1A,5)));
  UDR1 = bTxdData;
}



I was a little bit surprised that my UDR1 function works without any initialise. For my UDR0 function I wrote a little initialisation function:

Code: Select all
#define FOSC 16000000// Clock Speed
#define BAUD 57600
#define MYUBRR FOSC/16/BAUD-1

void USART_Init( unsigned int ubrr )
{
/* Set baud rate */
UBRR0H = (unsigned char)(ubrr>>8);
UBRR0L = (unsigned char)ubrr;
/* Enable receiver and transmitter */
UCSR0A = (1<<RXEN)|(1<<TXEN);
/* Set frame format: 8data, 2stop bit */
UCSR0C = (1<<USBS)|(3<<UCSZ0);


This function change nothing. After that i looked in the iom128.h because of my Atmega128(L).

Code: Select all
/* USART1 I/O Data Register */
#define UDR1      _SFR_MEM8(0x9C)


/* USART0 I/O Data Register */
#define UDR0      _SFR_IO8(0x0C)


But i couldn´t say what this means. I just see that they are different :-)

I hope U can help me :-)
(Maybe its just a mistake to send data on UDR0).
Oh THX i will take a look at this. But before a little question to the following code. The problem is that UDR0 doesn´t work. UDR1 is working but not UDR0.


Code: Select all
#include <avr>

typedef unsigned char byte;


void printHex(byte bSentData);
void printHex2(byte bSentData);
void TxD80(byte bTxdData);
void TxD81(byte bTxdData);


void printHex(byte bSentData)//UDR1
{
  byte bTmp;

  bTmp =((byte)(bSentData>>4)&0x0f) + (byte)'0';
  if(bTmp > '9') bTmp += 7;
  TxD81(bTmp);
  bTmp =(byte)(bSentData & 0x0f) + (byte)'0';
  if(bTmp > '9') bTmp += 7;
  TxD81(bTmp);
}

void printHex2(byte bSentData)//UDR0
{
  byte bTmp;

  bTmp =((byte)(bSentData>>4)&0x0f) + (byte)'0';
  if(bTmp > '9') bTmp += 7;
  TxD80(bTmp);
  bTmp =(byte)(bSentData & 0x0f) + (byte)'0';
  if(bTmp > '9') bTmp += 7;
  TxD80(bTmp);
}

void TxD80(byte bTxdData)
{
  while(!(bit_is_set(UCSR0A,5)));
  UDR0 = bTxdData;
}


void TxD81(byte bTxdData)
{
  while(!(bit_is_set(UCSR1A,5)));
  UDR1 = bTxdData;
}



I was a little bit surprised that my UDR1 function works without any initialise. For my UDR0 function I wrote a little initialisation function:

Code: Select all
#define FOSC 16000000// Clock Speed
#define BAUD 57600
#define MYUBRR FOSC/16/BAUD-1

void USART_Init( unsigned int ubrr )
{
/* Set baud rate */
UBRR0H = (unsigned char)(ubrr>>8);
UBRR0L = (unsigned char)ubrr;
/* Enable receiver and transmitter */
UCSR0A = (1<<RXEN)|(1<<TXEN);
/* Set frame format: 8data, 2stop bit */
UCSR0C = (1<<USBS)|(3<<UCSZ0);


This function change nothing. After that i looked in the iom128.h because of my Atmega128(L).

Code: Select all
/* USART1 I/O Data Register */
#define UDR1      _SFR_MEM8(0x9C)


/* USART0 I/O Data Register */
#define UDR0      _SFR_IO8(0x0C)


But i couldn´t say what this means. I just see that they are different :-)

I hope U can help me :-)
(Maybe its just a mistake to send data on UDR0).
Für Fehler und Schrift haftet der Stift. Palim Palim
bergere
Savvy Roboteer
Savvy Roboteer
Posts: 28
Joined: Thu Nov 29, 2007 10:18 pm

Post by StuartL » Fri May 30, 2008 7:44 am

Post by StuartL
Fri May 30, 2008 7:44 am

Always always always change the low (L) register before the high (H) register. The register locking is done in hardware so that works. Incidentally if you do a 16-bit assignment the compiler knows to change them (or read them) in the right order to avoid problems.
Always always always change the low (L) register before the high (H) register. The register locking is done in hardware so that works. Incidentally if you do a 16-bit assignment the compiler knows to change them (or read them) in the right order to avoid problems.
StuartL
Savvy Roboteer
Savvy Roboteer
Posts: 350
Joined: Mon Jun 04, 2007 3:46 pm
Location: Thatcham, Berkshire, UK

Post by bergere » Fri May 30, 2008 11:43 am

Post by bergere
Fri May 30, 2008 11:43 am

Are you sure that i have to change first the Low Register?
Because in Bioloid User Guide on Page 133 is used:

Code: Select all
UBRR0H = 0; UBRR0L = bBaudrate;
Are you sure that i have to change first the Low Register?
Because in Bioloid User Guide on Page 133 is used:

Code: Select all
UBRR0H = 0; UBRR0L = bBaudrate;
Für Fehler und Schrift haftet der Stift. Palim Palim
bergere
Savvy Roboteer
Savvy Roboteer
Posts: 28
Joined: Thu Nov 29, 2007 10:18 pm

Post by le fatumbi » Fri May 30, 2008 5:33 pm

Post by le fatumbi
Fri May 30, 2008 5:33 pm

bergere wrote:Are you sure that i have to change first the Low Register?
Because in Bioloid User Guide on Page 133 is used:

Code: Select all
UBRR0H = 0; UBRR0L = bBaudrate;

I have only 125 pages in "my" Bioloid User Guide :?

But I had no problem doing that way... chance ?

I'm not sure it's important while Rx & Tx are not yet enabled.
And, as default value of high register is always 0, you change nothing in fact when you write there.
bergere wrote:Are you sure that i have to change first the Low Register?
Because in Bioloid User Guide on Page 133 is used:

Code: Select all
UBRR0H = 0; UBRR0L = bBaudrate;

I have only 125 pages in "my" Bioloid User Guide :?

But I had no problem doing that way... chance ?

I'm not sure it's important while Rx & Tx are not yet enabled.
And, as default value of high register is always 0, you change nothing in fact when you write there.
le fatumbi
Robot Builder
Robot Builder
User avatar
Posts: 15
Joined: Sun May 04, 2008 9:07 am
Location: france

Post by StuartL » Sat May 31, 2008 7:54 am

Post by StuartL
Sat May 31, 2008 7:54 am

I stand corrected on my original comment.

The 16-bit logic I remembered is from the ATMega128 reference manual in relation to the timers.

As the CPU internally uses a temporary register per timer you have to do the read/writes in a specific order, and frustratingly it's not even the same order :D

I quote from the reference guide:

To do a 16-bit write, the high byte must be written before the low byte. For a 16-bit read, the low byte must be read before the high byte.

In all cases I strongly recommend 16-bit operations for 16-bit registers when using C, that way the compiler has to get it right for the context you're setting the register in.

So apologies for the mis-guidance earlier, and yes you're right in that it hardly matters if the serial interface isn't running, but it is a bad habit to get into.
I stand corrected on my original comment.

The 16-bit logic I remembered is from the ATMega128 reference manual in relation to the timers.

As the CPU internally uses a temporary register per timer you have to do the read/writes in a specific order, and frustratingly it's not even the same order :D

I quote from the reference guide:

To do a 16-bit write, the high byte must be written before the low byte. For a 16-bit read, the low byte must be read before the high byte.

In all cases I strongly recommend 16-bit operations for 16-bit registers when using C, that way the compiler has to get it right for the context you're setting the register in.

So apologies for the mis-guidance earlier, and yes you're right in that it hardly matters if the serial interface isn't running, but it is a bad habit to get into.
StuartL
Savvy Roboteer
Savvy Roboteer
Posts: 350
Joined: Mon Jun 04, 2007 3:46 pm
Location: Thatcham, Berkshire, UK

Post by bergere » Sat May 31, 2008 9:32 am

Post by bergere
Sat May 31, 2008 9:32 am

OK Thx :-)
OK Thx :-)
Für Fehler und Schrift haftet der Stift. Palim Palim
bergere
Savvy Roboteer
Savvy Roboteer
Posts: 28
Joined: Thu Nov 29, 2007 10:18 pm


8 postsPage 1 of 1
8 postsPage 1 of 1