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

Need help! Rx64 not working

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

Need help! Rx64 not working

Post by kakashimaru2 » Sun Mar 13, 2016 5:05 am

Post by kakashimaru2
Sun Mar 13, 2016 5:05 am

Homemade atmega328p,max485 to drive rx64.

I want to Power up the servo and run the simplest program turning the LED on and off but not working.
I don't know how to troubleshoot it.

I have already checked Voltage It may be ok (18v) . but The motor blinks so long times(6 sec) when powered up.
i was check baudrate and ID by USB2DYNAMIXEL .
baud 500000,Id:3

My program

Code: Select all
#include <stdio.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <compat/deprecated.h>
#include <util/delay.h>

#define F_CPU 16000000UL
void Init_Serial(unsigned int baudrate);
void put_command(uint8_t c,FILE *stream);
unsigned int p;
static FILE uart_str=FDEV_SETUP_STREAM(put_command,NULL,_FDEV_SETUP_WRITE);
void delay_ms(unsigned int i)
{
   for(;i>0;i--)
   {
      _delay_ms(1);
   }
}
void put_command(uint8_t c,FILE *stream)
{
   while(!(UCSR0A & (1<<UDRE0)));
   UDR0 = c;
        while ( ( UCSR0A & TXC0 ) != 0 ) ;
}
static void USART_Init(unsigned int baud)
{
   UBRR0H = (unsigned char)(baud>>8);
   UBRR0L = (unsigned char)baud;      
   
   UCSR0B |= (1<<TXEN0);
   
   UCSR0C |= (0<<UMSEL00)|(0<<UMSEL01)|(0<<UPM00)|(0<<UPM01)|(0 << USBS0)|(1 << UCSZ00) | (1 << UCSZ01)| (0 << UCSZ02)| (0 << UCPOL0);
   stdout=&uart_str;
}

static void Motor_LED_ON()
{
   fputc(0xFF,&uart_str);
   fputc(0xFF,&uart_str);
   fputc(0xFE,&uart_str);
   fputc(0x04,&uart_str);
   fputc(0x03,&uart_str);
   fputc(0x19,&uart_str);
   fputc(0x01,&uart_str);
   fputc(0xE0,&uart_str);
}

int main(void)
{
   DDRC = 0x0C;

   USART_Init(1);
   while(1)
   {         
      delay_ms(500);
      sbi(PORTC,3);
      sbi(PORTD,2); // enable txd disable rxd
      UCSR0B |= (1<<TXEN0)|(0<<RXEN0)|(0<<RXCIE0);
      cli();
      delay_ms(5);
      Motor_LED_ON();
      delay_ms(3);
      cbi(PORTD,2); // enable rxd disable txd
      UCSR0B |= (0<<TXEN0)|(1<<RXEN0)| (1<<RXCIE0) ;
      sei();      
      delay_ms(500);
   }
   return 0;
}

ISR(USART_RX_vect)
{
   while ( !(UCSR0A & (1<<RXC0)) );
      if(UDR0 == 0x03){
         sbi(PORTC,2);
         delay_ms(300);
      }
   return;
}


i follow circuit from rx64 datasheet

Can someone advice me plz
Homemade atmega328p,max485 to drive rx64.

I want to Power up the servo and run the simplest program turning the LED on and off but not working.
I don't know how to troubleshoot it.

I have already checked Voltage It may be ok (18v) . but The motor blinks so long times(6 sec) when powered up.
i was check baudrate and ID by USB2DYNAMIXEL .
baud 500000,Id:3

My program

Code: Select all
#include <stdio.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <compat/deprecated.h>
#include <util/delay.h>

#define F_CPU 16000000UL
void Init_Serial(unsigned int baudrate);
void put_command(uint8_t c,FILE *stream);
unsigned int p;
static FILE uart_str=FDEV_SETUP_STREAM(put_command,NULL,_FDEV_SETUP_WRITE);
void delay_ms(unsigned int i)
{
   for(;i>0;i--)
   {
      _delay_ms(1);
   }
}
void put_command(uint8_t c,FILE *stream)
{
   while(!(UCSR0A & (1<<UDRE0)));
   UDR0 = c;
        while ( ( UCSR0A & TXC0 ) != 0 ) ;
}
static void USART_Init(unsigned int baud)
{
   UBRR0H = (unsigned char)(baud>>8);
   UBRR0L = (unsigned char)baud;      
   
   UCSR0B |= (1<<TXEN0);
   
   UCSR0C |= (0<<UMSEL00)|(0<<UMSEL01)|(0<<UPM00)|(0<<UPM01)|(0 << USBS0)|(1 << UCSZ00) | (1 << UCSZ01)| (0 << UCSZ02)| (0 << UCPOL0);
   stdout=&uart_str;
}

static void Motor_LED_ON()
{
   fputc(0xFF,&uart_str);
   fputc(0xFF,&uart_str);
   fputc(0xFE,&uart_str);
   fputc(0x04,&uart_str);
   fputc(0x03,&uart_str);
   fputc(0x19,&uart_str);
   fputc(0x01,&uart_str);
   fputc(0xE0,&uart_str);
}

int main(void)
{
   DDRC = 0x0C;

   USART_Init(1);
   while(1)
   {         
      delay_ms(500);
      sbi(PORTC,3);
      sbi(PORTD,2); // enable txd disable rxd
      UCSR0B |= (1<<TXEN0)|(0<<RXEN0)|(0<<RXCIE0);
      cli();
      delay_ms(5);
      Motor_LED_ON();
      delay_ms(3);
      cbi(PORTD,2); // enable rxd disable txd
      UCSR0B |= (0<<TXEN0)|(1<<RXEN0)| (1<<RXCIE0) ;
      sei();      
      delay_ms(500);
   }
   return 0;
}

ISR(USART_RX_vect)
{
   while ( !(UCSR0A & (1<<RXC0)) );
      if(UDR0 == 0x03){
         sbi(PORTC,2);
         delay_ms(300);
      }
   return;
}


i follow circuit from rx64 datasheet

Can someone advice me plz
Attachments
ex1.jpg
from rx64 datasheet
ex1.jpg (52.84 KiB) Viewed 30300 times
kakashimaru2
Newbie
Newbie
Posts: 1
Joined: Sun Mar 13, 2016 4:25 am

1 postPage 1 of 1
1 postPage 1 of 1