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

Problems with a program!

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

Problems with a program!

Post by zildjiansam » Mon Aug 10, 2009 6:51 pm

Post by zildjiansam
Mon Aug 10, 2009 6:51 pm

Hello everybody!, I have a problem, i'm doing a program to move differents dinamyxels. I don't know how to get values in a variable by my program!. I mean, i wanna write a value in the robot terminal and save it in a variable in my C program in the win avr, I need your help!.
There are lots of examples in the manuals, but anyone explain how to save a value of the robot terminal in a variable in my program.
Hello everybody!, I have a problem, i'm doing a program to move differents dinamyxels. I don't know how to get values in a variable by my program!. I mean, i wanna write a value in the robot terminal and save it in a variable in my C program in the win avr, I need your help!.
There are lots of examples in the manuals, but anyone explain how to save a value of the robot terminal in a variable in my program.
zildjiansam
Newbie
Newbie
Posts: 3
Joined: Wed Apr 15, 2009 5:37 am

Post by clusher » Wed Aug 12, 2009 2:44 pm

Post by clusher
Wed Aug 12, 2009 2:44 pm

There are a few examples of C programming around, so you should manage with some guidelines.

Basically, you have to do the same that you do with communications with AX-12. Make an interrupt function like:

Code: Select all
#define RXD1_DATA         (UDR1)
unsigned char your_var;
SIGNAL (SIG_UART1_RECV){
    your_var =RXD1_DATA;
}


I'm assuming your just trying to save one char. If you need more, then your var should be an array, you need another variable to define the array index you're writing to and do exactly like AX-12 communication:

Code: Select all
#define RXD1_DATA         (UDR1)
unsigned char your_var[128];
unsigned int index=0;
SIGNAL (SIG_UART1_RECV){
    your_var[index++] =RXD1_DATA;
}


Don't forget to restart your index variable when you're done reading! Save all the memory you can :wink:

EDIT: you also need to enable the Interrupt bit for the PC USART. If you're using the example.c code, you should see
Code: Select all
cbi(UCSR1B,7); // RxD interrupt disable

You need to change this to sbi(UCSR1B,7).[/code]
There are a few examples of C programming around, so you should manage with some guidelines.

Basically, you have to do the same that you do with communications with AX-12. Make an interrupt function like:

Code: Select all
#define RXD1_DATA         (UDR1)
unsigned char your_var;
SIGNAL (SIG_UART1_RECV){
    your_var =RXD1_DATA;
}


I'm assuming your just trying to save one char. If you need more, then your var should be an array, you need another variable to define the array index you're writing to and do exactly like AX-12 communication:

Code: Select all
#define RXD1_DATA         (UDR1)
unsigned char your_var[128];
unsigned int index=0;
SIGNAL (SIG_UART1_RECV){
    your_var[index++] =RXD1_DATA;
}


Don't forget to restart your index variable when you're done reading! Save all the memory you can :wink:

EDIT: you also need to enable the Interrupt bit for the PC USART. If you're using the example.c code, you should see
Code: Select all
cbi(UCSR1B,7); // RxD interrupt disable

You need to change this to sbi(UCSR1B,7).[/code]
clusher
Savvy Roboteer
Savvy Roboteer
Posts: 57
Joined: Thu Jul 17, 2008 12:27 pm


2 postsPage 1 of 1
2 postsPage 1 of 1