![Bioloid Robotis User Manual Download Page 133](http://html1.mh-extra.com/html/bioloid/robotis/robotis_user-manual_2753949133.webp)
User’s Guide
{
TxDString("\r\n [Error:Wrong CheckSum]");
CLEAR_BUFFER;
return 0;
}
}
}
return bLength;
}
/*
PrintBuffer() print data in Hex code.
PrintBuffer() needs two parameter; name of Pointer(gbpTxBuffer,
gbpRxBuffer)
*/
void PrintBuffer(byte *bpPrintBuffer, byte bLength)
{
byte bCount;
for(bCount = 0; bCount < bLength; +)
{
TxD8Hex(bpPrintBuffer[bCount]);
TxD8(' ');
}
TxDString("(LEN:");TxD8Hex(bLength);TxD8(')');
}
/*
Print value of Baud Rate.
*/
void PrintBaudrate(void)
{
TxDString("\r\n
RS232:");TxD32Dec((16000000L/8L)/((long)UBRR1L
+1L) ); TxDString(" BPS,");
TxDString(" RS485:");TxD32Dec((16000000L/8L)/((long)1L) );
TxDString(" BPS");
}
/*Hardware Dependent Item*/
#define TXD1_READY
bit_is_set(UCSR1A,5)
//(UCSR1A_Bit5)
#define TXD1_DATA
(UDR1)
#define RXD1_READY
bit_is_set(UCSR1A,7)
#define RXD1_DATA
(UDR1)
#define TXD0_READY
bit_is_set(UCSR0A,5)
#define TXD0_DATA
(UDR0)
#define RXD0_READY
bit_is_set(UCSR0A,7)
#define RXD0_DATA
(UDR0)
/*
SerialInitialize() set Serial Port to initial state.
Vide Mega128 Data sheet about Setting bit of register.
SerialInitialize() needs port, Baud rate, Interrupt value.
*/
void SerialInitialize(byte bPort, byte bBaudrate, byte bInterrupt)
{
if(bPort == SERIAL_PORT0)
{
UBRR0H = 0; UBRR0L = bBaudrate;
UCSR0A = 0x02; UCSR0B = 0x18;
if(bInterrupt&RX_INTERRUPT) sbi(UCSR0B,7); // RxD interrupt
enable
UCSR0C = 0x06; UDR0 = 0xFF;
sbi(UCSR0A,6);//SET_TXD0_FINISH; // Note. set 1, then 0 is read
}
else if(bPort == SERIAL_PORT1)
{
UBRR1H = 0; UBRR1L = bBaudrate;
UCSR1A = 0x02; UCSR1B = 0x18;
if(bInterrupt&RX_INTERRUPT) sbi(UCSR1B,7); // RxD interrupt
enable
UCSR1C = 0x06; UDR1 = 0xFF;
sbi(UCSR1A,6);//SET_TXD1_FINISH; // Note. set 1, then 0 is read
}
}
/*
TxD8Hex() print data seperatly.
ex> 0x1a -> '1' 'a'.
*/
void TxD8Hex(byte bSentData)
{
byte bTmp;
bTmp =((byte)(bSentData>>4)&0x0f) + (byte)'0';
if(bTmp > '9') bTmp += 7;
TxD8(bTmp);
bTmp =(byte)(bSentData & 0x0f) + (byte)'0';
if(bTmp > '9') bTmp += 7;
TxD8(bTmp);
}
/*
TxD80() send data to USART 0.
*/
void TxD80(byte bTxdData)
{
while(!TXD0_READY);
TXD0_DATA = bTxdData;
}
/*
TXD81() send data to USART 1.
*/
void TxD81(byte bTxdData)
{
while(!TXD1_READY);
TXD1_DATA = bTxdData;
}
/*
TXD32Dex() change data to decimal number system
*/
void TxD32Dec(long lLong)
{
byte bCount, bPrinted;
long lTmp,lDigit;
bPrinted = 0;
if(lLong < 0)
{
lLong = -lLong;
TxD8('-');
}
lDigit = 1000000000L;
for(bCount = 0; bCount < 9; +)
{
lTmp = (byte)(lLong/lDigit);
if(lTmp)
{
TxD8(((byte)lTmp)+'0');
bPrinted = 1;
}
else if(bPrinted) TxD8(((byte)lTmp)+'0');
lLong -= ((long)lTmp)*lDigit;
lDigit = lDigit/10;
}
lTmp = (byte)(lLong/lDigit);
/*if(lTmp)*/ TxD8(((byte)lTmp)+'0');
}
/*
TxDString() prints data in ACSII code.
*/
void TxDString(byte *bData)
133
Summary of Contents for Robotis
Page 1: ...Ver 1 00 BIOLOID User s Guide Closer to Real...
Page 55: ...User s Guide Portion that will be ignored Enable Disable Code Portions that will be ignored 55...
Page 73: ...User s Guide Move routine Stop Backward Left turn Right turn Melody sound routine 73...
Page 100: ...User s Guide Transmitter behavior control program Receiver behavior control program 100...