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

showing status packet in LCD with atmega8535

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

showing status packet in LCD with atmega8535

Post by amboaco » Wed Mar 03, 2010 5:52 am

Post by amboaco
Wed Mar 03, 2010 5:52 am

hello all, please help mi for my project...

i want to control dynamixel with mikrokontroller atmega8535 but is constrained to display the status of packet (present load and present speed) on the LCD 16 * 2. I use the language with the compiler c codevision avr (hp.infotech.com). I use the serial interruptions.

following listing program..
------------------------
hitung = 0;
dp_kirim(); // direction port for send " instruction packet"
speed1(); // fungsi for read present speed dynamixel ID1
reset(); // not send instuction packet and receive packet
#asm("sei") // interupsi aktif
dp_terima(); // direction port for receive " status packet packet"
while (hitung == 7) // wait until status packet receive 7
tampilkan ( P1, P2, ID, lengh, error,parameter,CS); // showing LCD

------------------------

listing block interupsi serial
--------------
interrupt [USART_RXC] void usart_rx_isr(void)
{
hitung++;
if (hitung == 1)
{
P1=UDR;
lcd_gotoxy(15,0);
lcd_putsf("B");
}
else if (hitung == 2)
{
P2 = UDR;
}
else if (hitung == 3)
{
ID = UDR;
}
else if (hitung == 4)
{
lengh = UDR;
}
else if (hitung == 5)
{
error = UDR;
}
else if (hitung == 6)
{
parameter = UDR;
}
else if (hitung == 7)
{
CS = UDR;
}
else
{
#asm("cli")
reset();
};
}
--------------------------

problem: data received does not match the actual

thanks before
best regard
amboaco ( student in indonesia)
hello all, please help mi for my project...

i want to control dynamixel with mikrokontroller atmega8535 but is constrained to display the status of packet (present load and present speed) on the LCD 16 * 2. I use the language with the compiler c codevision avr (hp.infotech.com). I use the serial interruptions.

following listing program..
------------------------
hitung = 0;
dp_kirim(); // direction port for send " instruction packet"
speed1(); // fungsi for read present speed dynamixel ID1
reset(); // not send instuction packet and receive packet
#asm("sei") // interupsi aktif
dp_terima(); // direction port for receive " status packet packet"
while (hitung == 7) // wait until status packet receive 7
tampilkan ( P1, P2, ID, lengh, error,parameter,CS); // showing LCD

------------------------

listing block interupsi serial
--------------
interrupt [USART_RXC] void usart_rx_isr(void)
{
hitung++;
if (hitung == 1)
{
P1=UDR;
lcd_gotoxy(15,0);
lcd_putsf("B");
}
else if (hitung == 2)
{
P2 = UDR;
}
else if (hitung == 3)
{
ID = UDR;
}
else if (hitung == 4)
{
lengh = UDR;
}
else if (hitung == 5)
{
error = UDR;
}
else if (hitung == 6)
{
parameter = UDR;
}
else if (hitung == 7)
{
CS = UDR;
}
else
{
#asm("cli")
reset();
};
}
--------------------------

problem: data received does not match the actual

thanks before
best regard
amboaco ( student in indonesia)
amboaco
Newbie
Newbie
Posts: 5
Joined: Fri Feb 12, 2010 5:14 pm

Post by ryann2k1 » Mon Mar 29, 2010 4:49 am

Post by ryann2k1
Mon Mar 29, 2010 4:49 am

ryann2k1
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 154
Joined: Thu Nov 16, 2006 1:00 am

Post by Fritzoid » Mon Mar 29, 2010 12:23 pm

Post by Fritzoid
Mon Mar 29, 2010 12:23 pm

Sounds like a speed or parity issue. What's the setup on the USART? Also, what is the clock speed of the 8535?
Sounds like a speed or parity issue. What's the setup on the USART? Also, what is the clock speed of the 8535?
Fritzoid
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 331
Joined: Mon Dec 18, 2006 1:00 am

Post by amboaco » Tue Mar 30, 2010 11:58 am

Post by amboaco
Tue Mar 30, 2010 11:58 am

Thanks for the feedback.

In my project, my using microcontroller avr 8535 with eksternal clock 11,0592 Mhz. I am setting baudrate in microcontroller and dynamixel ax-12 as same is 115,2 kbps.

For sending data to the dyanamixel Ax-12 there is not problem, but only in the reading of data from dynamixel Ax-12 for reading ( USING INSTRUCTION "READ" ) internal temperatur and speed. I can just detect the two data and the rests are missing.

Any idea please?
Best regard..
Aco
Thanks for the feedback.

In my project, my using microcontroller avr 8535 with eksternal clock 11,0592 Mhz. I am setting baudrate in microcontroller and dynamixel ax-12 as same is 115,2 kbps.

For sending data to the dyanamixel Ax-12 there is not problem, but only in the reading of data from dynamixel Ax-12 for reading ( USING INSTRUCTION "READ" ) internal temperatur and speed. I can just detect the two data and the rests are missing.

Any idea please?
Best regard..
Aco
amboaco
Newbie
Newbie
Posts: 5
Joined: Fri Feb 12, 2010 5:14 pm

Post by i-Bot » Tue Mar 30, 2010 1:06 pm

Post by i-Bot
Tue Mar 30, 2010 1:06 pm

How fast are your LCD routines ? There are only a couple of bytes buffer in the USART and bytes arrive every 87 microseconds.

Does speed1() check all bytes are sent before changing direction ?
How fast are your LCD routines ? There are only a couple of bytes buffer in the USART and bytes arrive every 87 microseconds.

Does speed1() check all bytes are sent before changing direction ?
i-Bot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am

Post by amboaco » Tue Mar 30, 2010 2:52 pm

Post by amboaco
Tue Mar 30, 2010 2:52 pm

about fast myLCD routines, I am not known. I am using LCD 16X2 and using wizard from CodeWizardAVR V2.03.4 Standard to control it.

this example fungtion want to read and showing in LCD ( reading internal temperatur ID 1)

void temperatur ()
{
putchar(0xFF);
putchar(0xFF);
putchar(0x01);
putchar(0x04);
putchar(0x02);
putchar(0x2B);
putchar(0x01);
putchar(0xCC);
}

And I am sure, all byte has sent before changing direction. This can be evidenced from "alarm led" not blinks...

this listing to show in LCD

---------
lcd_clear();
lcd_gotoxy(0,0);
sprintf(buf1,"%x %x %x %x %x %x %x",datarx[1],datarx[2],datarx[3],datarx[4],datarx[5],datarx[6],datarx[7]);
lcd_puts(buf1);
-----------

Best regards..
Aco
about fast myLCD routines, I am not known. I am using LCD 16X2 and using wizard from CodeWizardAVR V2.03.4 Standard to control it.

this example fungtion want to read and showing in LCD ( reading internal temperatur ID 1)

void temperatur ()
{
putchar(0xFF);
putchar(0xFF);
putchar(0x01);
putchar(0x04);
putchar(0x02);
putchar(0x2B);
putchar(0x01);
putchar(0xCC);
}

And I am sure, all byte has sent before changing direction. This can be evidenced from "alarm led" not blinks...

this listing to show in LCD

---------
lcd_clear();
lcd_gotoxy(0,0);
sprintf(buf1,"%x %x %x %x %x %x %x",datarx[1],datarx[2],datarx[3],datarx[4],datarx[5],datarx[6],datarx[7]);
lcd_puts(buf1);
-----------

Best regards..
Aco
amboaco
Newbie
Newbie
Posts: 5
Joined: Fri Feb 12, 2010 5:14 pm

Post by amboaco » Tue Mar 30, 2010 3:02 pm

Post by amboaco
Tue Mar 30, 2010 3:02 pm

The new my program:
--------------------------------
void main(void)
{
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud Rate: 115200
UCSRA=0x00;
UCSRB=0x98; //98
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x05;

PORTA=0x00; DDRA=0x00;
PORTB=0x00; DDRB=0x00;
PORTC=0x00;DDRC=0x00;
PORTD=0x00;DDRD=0x00;

lcd_init(16);

while (1)
{
i = 0;
dp_kirim();
temperatur();
#asm("sei")
dp_terima();
if ( i > 6)
{
lcd_clear();
lcd_gotoxy(0,0);
sprintf(buf1,"%x %x %x %x %x %x %x",datarx[1],datarx[2],datarx[3],datarx[4],datarx[5],datarx[6],datarx[7]);
lcd_puts(buf1);
};
};
}

--------------------

and routin receiver interupsi is

----------------
//USART Receiver interrupt service routine
interrupt [USART_RXC] void usart_rx_isr(void)
{
lcd_gotoxy(0,0);
lcd_putsf("cek");
i++;
datarx [i] = UDR;
lcd_gotoxy(8,1); // for cek how many interuption
sprintf(buf2,"%d",i);
lcd_puts(buf2);
delay_ms(1000);
lcd_clear();
}

best regard
amboaco
The new my program:
--------------------------------
void main(void)
{
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud Rate: 115200
UCSRA=0x00;
UCSRB=0x98; //98
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x05;

PORTA=0x00; DDRA=0x00;
PORTB=0x00; DDRB=0x00;
PORTC=0x00;DDRC=0x00;
PORTD=0x00;DDRD=0x00;

lcd_init(16);

while (1)
{
i = 0;
dp_kirim();
temperatur();
#asm("sei")
dp_terima();
if ( i > 6)
{
lcd_clear();
lcd_gotoxy(0,0);
sprintf(buf1,"%x %x %x %x %x %x %x",datarx[1],datarx[2],datarx[3],datarx[4],datarx[5],datarx[6],datarx[7]);
lcd_puts(buf1);
};
};
}

--------------------

and routin receiver interupsi is

----------------
//USART Receiver interrupt service routine
interrupt [USART_RXC] void usart_rx_isr(void)
{
lcd_gotoxy(0,0);
lcd_putsf("cek");
i++;
datarx [i] = UDR;
lcd_gotoxy(8,1); // for cek how many interuption
sprintf(buf2,"%d",i);
lcd_puts(buf2);
delay_ms(1000);
lcd_clear();
}

best regard
amboaco
amboaco
Newbie
Newbie
Posts: 5
Joined: Fri Feb 12, 2010 5:14 pm

Post by i-Bot » Tue Mar 30, 2010 7:25 pm

Post by i-Bot
Tue Mar 30, 2010 7:25 pm

Interrupt routine have to be short if you want to avoid losing data. This is why I asked about the LCD routines. The long delay you now have in the interrupt routine is crazy. Take all LCD printing and delays out of the interrupt routine. I you can't get out and back into the interrupt routine in less than 100 microseconds, you will lose data.
Interrupt routine have to be short if you want to avoid losing data. This is why I asked about the LCD routines. The long delay you now have in the interrupt routine is crazy. Take all LCD printing and delays out of the interrupt routine. I you can't get out and back into the interrupt routine in less than 100 microseconds, you will lose data.
i-Bot
Savvy Roboteer
Savvy Roboteer
User avatar
Posts: 1142
Joined: Wed May 17, 2006 1:00 am

Post by amboaco » Wed Mar 31, 2010 9:36 am

Post by amboaco
Wed Mar 31, 2010 9:36 am

thanks all and special thanks for "i-Bot"

I have completed problem my program. Your are right., the problem is delay-time in routine interupsi too long.

amboaco...
thanks all and special thanks for "i-Bot"

I have completed problem my program. Your are right., the problem is delay-time in routine interupsi too long.

amboaco...
amboaco
Newbie
Newbie
Posts: 5
Joined: Fri Feb 12, 2010 5:14 pm


9 postsPage 1 of 1
9 postsPage 1 of 1